Skip to content

Commit

Permalink
update locator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
David Glick committed Aug 19, 2021
1 parent 1af1868 commit d2c8fbe
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions cumulusci/core/tests/test_salesforce_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ class TestLocators(unittest.TestCase):
@mock.patch("cumulusci.robotframework.Salesforce.Salesforce.get_latest_api_version")
def test_locators_in_robot_context(self, get_latest_api_version):
"""Verify we can get locators for the current org api version"""
get_latest_api_version.return_value = 50.0
get_latest_api_version.return_value = 53.0

# This instantiates the robot library, mimicking a robot library import.
# We've mocked out the code that would otherwise throw an error since
# we're not running in the context of a robot test. The library should
# return the latest version of the locators.
sf = Salesforce()

expected = "cumulusci.robotframework.locators_50"
expected = "cumulusci.robotframework.locators_53"
actual = sf.locators_module.__name__
message = "expected to load '{}', actually loaded '{}'".format(expected, actual)
self.assertEqual(expected, actual, message)

pass

@mock.patch(
"robot.libraries.BuiltIn.BuiltIn.get_library_instance",
side_effect=RobotNotRunningError(),
Expand All @@ -50,8 +48,8 @@ def test_locators_outside_robot_context(self, builtin_mock):
message = "expected to load '{}', actually loaded '{}'".format(expected, actual)
self.assertEqual(expected, actual, message)

def test_locators_51(self):
"""Verify that locators_51 is a superset of the locators_50
def test_locators_53(self):
"""Verify that locators_53 is a superset of the locators_52
This test is far from perfect, but it should at least flag a
catastrophic error in how locators for a version that augments
Expand All @@ -61,16 +59,16 @@ def test_locators_51(self):
keys from 50.
"""
import cumulusci.robotframework.locators_50 as locators_50
import cumulusci.robotframework.locators_51 as locators_51
import cumulusci.robotframework.locators_52 as locators_52
import cumulusci.robotframework.locators_53 as locators_53

keys_50 = set(locators_50.lex_locators)
keys_51 = set(locators_51.lex_locators)
keys_50 = set(locators_52.lex_locators)
keys_51 = set(locators_53.lex_locators)

self.assertNotEqual(
id(locators_50.lex_locators),
id(locators_51.lex_locators),
"locators_50.lex_locators and locators_51.lex_locators are the same object",
id(locators_52.lex_locators),
id(locators_53.lex_locators),
"locators_52.lex_locators and locators_53.lex_locators are the same object",
)
self.assertTrue(len(keys_50) > 0)
self.assertTrue(keys_50.issubset(keys_51))

0 comments on commit d2c8fbe

Please sign in to comment.