def test_compare_wfn_returns_25_percent_of_coincidence(self): wfn_a = { 'part': 'a', 'vendor': 'adobe_', 'product': 'connect_', 'version': '9.5.', 'update': 'u96_', 'edition': '2016_', 'language': 'ANY', 'sw_edition': 'ANY', 'target_sw': 'ANY', 'target_hw': 'ANY', 'other': 'ANY' } wfn_b = { 'vendor': 'adobe', 'product': 'connect', 'version': '9.5', 'update': 'u96', 'edition': '2016', 'language': '*', 'sw_edition': '*', 'target_sw': '*', 'target_hw': '*', 'other': '*' } result = compare_wfn(wfn_a, wfn_b) # verify not_matches = ['vendor', 'product', 'version', 'update', 'edition'] self.assertEqual(25, result.get('coincidence_rate')) self.assertListEqual(sorted(not_matches), sorted(result.get('not_matches')))
def create_context(self): wfn_a = self.get_wfn_from_get_request('uri_binding_a') wfn_b = self.get_wfn_from_get_request('uri_binding_b') result = compare_wfn(wfn_a, wfn_b) return { 'wfn_a': wfn_a, 'wfn_b': wfn_b, 'coincidence': result.get('coincidence_rate'), 'not_matches': result.get('not_matches') }
def test_compare_wfn_returns_100_percent_of_coincidence(self): wfn_a = { 'part': 'a', 'vendor': 'adobe', 'product': 'connect', 'version': '9.5', 'update': '*', 'edition': '*', 'language': '*', 'sw_edition': '*', 'target_sw': '*', 'target_hw': '*', 'other': '*' } result = compare_wfn(wfn_a, wfn_a) # verify expected_result = {'coincidence_rate': 100, 'not_matches': []} self.dict_tester.assertEqualKeys(expected_result, result) self.dict_tester.assertEqualValues(expected_result, result)
def compare_and_verify_not_equal_version(self, wfn_a, wfn_b): result = compare_wfn(wfn_a, wfn_b) # verify self.assertEqual(85, result.get('coincidence_rate')) self.assertListEqual(['version'], result.get('not_matches'))
def test_compare_wfn_any_case(self): wfn_a = { 'part': 'a', 'vendor': 'adobe', 'product': 'connect', 'version': '9.5', 'update': 'u96', 'edition': '2016', 'language': 'ANY', 'sw_edition': 'ANY', 'target_sw': 'ANY', 'target_hw': 'ANY', 'other': 'ANY' } wfn_b = { 'vendor': 'adobe', 'product': 'connect', 'version': '9.5', 'update': 'u96', 'edition': '2016', 'language': 'DE', 'sw_edition': '2015', 'target_sw': 'windows', 'target_hw': 'x85', 'other': 'bla' } result = compare_wfn(wfn_a, wfn_b) # verify self.assertEqual(100, result.get('coincidence_rate')) self.assertEqual([], result.get('not_matches')) # ANY value with asterisk wfn_a = { 'part': 'a', 'vendor': 'adobe', 'product': 'connect', 'version': '9.5.2', 'update': 'u96', 'edition': '2016', 'language': '*', 'sw_edition': '*', 'target_sw': '*', 'target_hw': '*', 'other': '*' } wfn_b = { 'part': 'a', 'vendor': 'adobe', 'product': 'connect', 'version': '9.5', 'update': '*', 'edition': '*', 'language': '*', 'sw_edition': '*', 'target_sw': '*', 'target_hw': '*', 'other': '*' } result = compare_wfn(wfn_a, wfn_b) # verify not_matches = ['version'] self.assertEqual(85, result.get('coincidence_rate')) self.assertListEqual(not_matches, result.get('not_matches')) wfn_a = { 'part': 'a', 'vendor': 'adobe', 'product': 'connect', 'version': '9.5', 'update': 'u96', 'edition': '2016', 'language': 'ANY', 'sw_edition': 'ANY', 'target_sw': 'ANY', 'target_hw': 'ANY', 'other': '*' } wfn_b = { 'part': 'a', 'vendor': 'adobe', 'product': 'connect', 'version': '9.5', 'update': 'ANY', 'edition': 'ANY', 'language': 'ANY', 'sw_edition': 'ANY', 'target_sw': 'ANY', 'target_hw': 'ANY', 'other': '-' } result = compare_wfn(wfn_a, wfn_b) # verify ANY is not equal to - not_matches = ['other'] self.assertEqual(95, result.get('coincidence_rate')) self.assertListEqual(not_matches, result.get('not_matches')) wfn_b.update({'other': 'NA'}) # verify ANY is not equal to NA not_matches = ['other'] self.assertEqual(95, result.get('coincidence_rate')) self.assertListEqual(not_matches, result.get('not_matches'))