test_testrun_jsonimport.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import pytest
  2. import os
  3. from pathlib import Path
  4. from baangt.base.TestRun.TestRun import TestRun
  5. @pytest.fixture
  6. def testrun_obj():
  7. """ This function return instance of TestRun object
  8. which will be used by other test methods
  9. """
  10. from baangt.base.TestRun.TestRun import TestRun
  11. return TestRun("examples/SimpleTheInternet.xlsx", "globals.json", executeDirect=False)
  12. def test_with_globalsHeadless(testrun_obj):
  13. lTestRun = TestRun("examples/SimpleTheInternet.xlsx",
  14. globalSettingsFileNameAndPath= \
  15. Path(os.getcwd()).joinpath("tests").joinpath("jsons").joinpath("globals_headless.json"),
  16. executeDirect=False)
  17. lTestRun._initTestRunSettingsFromFile()
  18. assert lTestRun.globalSettings["TC.BrowserAttributes"]
  19. assert isinstance(lTestRun.globalSettings["TC.BrowserAttributes"], dict)
  20. def test_with_globalsHeadlessVersion2(testrun_obj):
  21. lTestRun = TestRun("examples/SimpleTheInternet.xlsx",
  22. globalSettingsFileNameAndPath= \
  23. Path(os.getcwd()).joinpath("tests").joinpath("jsons").joinpath("globals_headless2.json"),
  24. executeDirect=False)
  25. lTestRun._initTestRunSettingsFromFile()
  26. assert lTestRun.globalSettings["TC.BrowserAttributes"]
  27. assert isinstance(lTestRun.globalSettings["TC.BrowserAttributes"], dict)
  28. def tests_with_fullGlobalsFile(testrun_obj):
  29. lTestRun = TestRun("examples/SimpleTheInternet.xlsx",
  30. globalSettingsFileNameAndPath= \
  31. Path(os.getcwd()).joinpath("tests").joinpath("jsons").joinpath("globalsFullExample.json"),
  32. executeDirect=False)
  33. lTestRun._initTestRunSettingsFromFile()
  34. assert not lTestRun.globalSettings["TC.Lines"]
  35. assert lTestRun.globalSettings["TX.DEBUG"] == True # Was converted from string "True" to boolean True
  36. assert lTestRun.globalSettings["TC.RestartBrowser"] == False # Was converted from string "False" to boolean False
  37. assert lTestRun.globalSettings["TC.NetworkInfo"] == True # Was converted from string "X" to boolean True
  38. assert lTestRun.globalSettings["CL.browserFactory"] == 'zzbaangt.base.BrowserFactory.BrowserFactory'
  39. assert lTestRun.classesForObjects.browserFactory == 'zzbaangt.base.BrowserFactory.BrowserFactory'