def test_not_extending_pact_helper(): consumer_tests_path = os.path.join(os.getcwd(), 'tests', 'resources', 'pact_helper_no_super_class') pact_helper = load_pact_helper(consumer_tests_path).value error_message = 'Pact Helper class must extend pact_test.PactHelper' assert pact_helper == error_message
def test_load_user_class_missing_tear_down(): consumer_tests_path = os.path.join(os.getcwd(), 'tests', 'resources', 'pact_helper_no_tear_down') pact_helper = load_pact_helper(consumer_tests_path).value error_message = 'Missing "tear_down" method in "pact_helper.py".' assert pact_helper == error_message
def test_path_to_pact_helper(monkeypatch): monkeypatch.setattr(os.path, 'isfile', lambda _: True) consumer_tests_path = '/consumer_tests/' pact_helper = load_pact_helper(consumer_tests_path).value msg = 'Missing "pact_helper.py" at "/consumer_tests/pact_helper.py".' assert pact_helper == msg
def verify(self): print('') debug('Verify consumers: START') pact_helper = load_pact_helper(self.config.consumer_tests_path) if type(pact_helper) is Right: self.pact_helper = pact_helper.value tests = self.collect_tests() if type(tests) is Right: debug(str(len(tests.value)) + ' test(s) found.') debug('Execute Pact Helper setup: START') self.pact_helper.setup() debug('Execute Pact Helper setup: DONE') test_results = Right(list(map(self.verify_test, tests.value))) debug('Execute Pact Helper tear down: START') self.pact_helper.tear_down() debug('Execute Pact Helper tear down: DONE') debug('Verify consumers: DONE') return test_results error('Verify consumers: EXIT WITH ERRORS:') error(tests.value) return tests error('Verify consumers: EXIT WITH ERRORS:') error(pact_helper.value) return pact_helper
def test_load_pact_helper(): consumer_tests_path = os.path.join(os.getcwd(), 'tests', 'resources', 'pact_helper') pact_helper = load_pact_helper(consumer_tests_path).value assert issubclass(pact_helper.__class__, PactHelper)
def test_load_module_missing(): consumer_tests_path = '/consumer_tests/' pact_helper = load_pact_helper(consumer_tests_path).value assert pact_helper == 'Missing "pact_helper.py" at "/consumer_tests/".'
def test_path_to_pact_helper_missing(): consumer_tests_path = '/consumer_tests/' pact_helper = load_pact_helper(consumer_tests_path).value msg = 'Missing "pact_helper.py" at "/consumer_tests/".' assert pact_helper == msg