test_TestStepMaster.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from baangt.TestSteps.TestStepMaster import TestStepMaster
  2. from baangt.base.Timing.Timing import Timing
  3. import pytest
  4. from unittest.mock import patch, MagicMock
  5. class FakeTestRun:
  6. def __init__(self):
  7. self.testRunName = ""
  8. self.testRunUtils = MagicMock()
  9. self.globalSettings = {}
  10. @pytest.fixture(scope="module")
  11. def testStepMaster():
  12. return TestStepMaster(TimingClassInstance=Timing(), TESTRUNINSTANCE=FakeTestRun(), data={})
  13. @pytest.mark.parametrize("lComparison, value1, value2",[("=", True, True), ("=", "True", "None"), ("!=", True, True),
  14. ("!=", True, "None"), (">", 1, 2), (">", 2, 1), ("<", 1, 2), ("<", 2, 1), (">=", 1, 2), (">=", 2, 1), ("<=", 1, 2),
  15. ("<=", 2, 1), ("!!", True, True), ("", True, True)])
  16. def test_doComparison(lComparison, value1, value2, testStepMaster):
  17. if lComparison != "!!":
  18. result = testStepMaster._TestStepMaster__doComparisons(lComparison, value1, value2)
  19. assert type(result) == bool
  20. else:
  21. with pytest.raises(BaseException):
  22. testStepMaster._TestStepMaster__doComparisons(lComparison, value1, value2)
  23. assert 1 == 1
  24. @pytest.mark.parametrize("command, locator", [("SETTEXTIF", ""), ("FORCETEXT", ""), ("FORCETEXTIF", ""), ("FORCETEXTJS", ""),
  25. ("SETANCHOR", ""), ("HANDLEIFRAME", ""), ("APIURL", ""), ("ENDPOINT", ""),
  26. ("POST", ""), ("GET", ""), ("HEADER", ""), ("SAVE", ""), ("CLEAR", ""),
  27. ("ADDRESS_CREATE", ""), ("ASSERT", ""), ("PDFCOMPARE", ""), ("CHECKLINKS", ""),
  28. ("ZZ_", ""), ("TCStopTestCase".upper(), ""), ("TCStopTestCaseError".upper(), ""),
  29. ("SETANCHOR", "temp")])
  30. def test_executeDirectSingle(command, locator, testStepMaster):
  31. if command == "SAVE":
  32. testStepMaster.doSaveData = MagicMock()
  33. testStepMaster.browserSession = MagicMock()
  34. testStepMaster.apiSession = MagicMock()
  35. testStepMaster.executeDirectSingle(0, {
  36. "Activity": command, "LocatorType": "", "Locator": locator, "Value": 'temp',
  37. "Value2": '', "Comparison": '', "Optional": '', 'Release': '', "Timeout": ''
  38. })
  39. assert 1 == 1