import unittest
import datetime
import pytz
import time
from utils.WDriver import WDriver
from utils.HelperJson import HelperJson
from page_models.HomePage import HomePage
from page_models.AddNewComputerPage import AddNewComputerPage

class test_add_new_computer_data_missing(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.start_ts_pst = ''

    def setUp(self):
        self.start_ts_pst = str(datetime.datetime.now(pytz.timezone('US/Pacific')).strftime('"%m-%d %H:%M:%S.%f"'))

    def tearDown(self):
        end_ts_pst = str(datetime.datetime.now(pytz.timezone('US/Pacific')).strftime('"%m-%d %H:%M:%S.%f"'))
        print("Test start time: {}".format(self.start_ts_pst))
        print("Test end time  : {}".format(end_ts_pst))

    def test_add_new_computer_data_missing(self):

        print('*****************TC:test_add_new_computer_data_missing *******************')

        callHelperJson = HelperJson()
        dataComputer = callHelperJson.read('dataComputer.json')

        self.webdriver = dataComputer['webdriver']
        self.web_url = dataComputer['web_url']
        self.new_computer = dataComputer['new_computer_data_missing']

        # call driver
        callWDriver = WDriver(self.webdriver, self.web_url)
        callWDriver.call_chrome_webdriver()

        # home page
        callHomePage = HomePage(callWDriver.driver, '')
        callHomePage.validate_home_page_title()
        val_click_add_new_computer = callHomePage.click_add_new_computer()

        # ADD A COMPUTER PAGE
        callAddNewComputerPage = AddNewComputerPage(callWDriver.driver, self.new_computer, '', '')
        callAddNewComputerPage.validate_add_new_computer_title_css()
        # input values
        callAddNewComputerPage.add_new_computer_name()
        #callAddNewComputerPage.add_new_computer_introduce_date_random()
        #callAddNewComputerPage.add_new_computer_discontinued_date_random()
        #callAddNewComputerPage.add_new_computer_company_random()

        val_create_computer = callAddNewComputerPage.create_computer_data_missing()
        # assert is != to False, expecting True to check true of test value as computer created
        assert val_create_computer != False, 'Error Msg Require fields not displayed'

        callAddNewComputerPage.print_log_create_computer_msg_errors()
        time.sleep(2)

        callWDriver.quit_chrome_webdriver()

if __name__ == '__main__':
    unittest.main()
