def test_verification_default_ordered_list_mock(self, unordered_set_mock: MagicMock): verified_list_data = {'items': [1, 2, 3]} task = AbstractTask(info={'url': 'https://bla.pl'}) unordered_set_mock.side_effect = [([1, 2, 3], 1)] task.cross_check([verified_list_data, verified_list_data]) unordered_set_mock.assert_called_with([[1, 2, 3], [1, 2, 3]])
def test_verification_default_equals_mock(self, equals_mock: MagicMock): verified_dict_data = {'fld': 'val1'} task = AbstractTask(info={'url': 'https://bla.pl'}) equals_mock.return_value = (1, verified_dict_data) task.cross_check([verified_dict_data, verified_dict_data]) equals_mock.assert_called_with(['val1', 'val1'])
def test_verification_default_complex(self, equals_mock: MagicMock): verified_dict_data = {'cars': [{'model': 'A', 'year': 2011}, {'model': 'B', 'year': 2012}]} task = AbstractTask(info={'url': 'https://bla.pl'}) equals_mock.side_effect = lambda values: (values[0], 1) task.cross_check([verified_dict_data, verified_dict_data]) # equals_mock.assert_not_called_with([verified_dict_data, verified_dict_data]) calls = [call(['A', 'A']), call([2011, 2011]), call(['B', 'B']), call([2012, 2012])] equals_mock.assert_has_calls(calls, any_order=True)
def test_verification_default_ordered_list_true(self): verified_list_data = {'items': [1, 2, 3]} task = AbstractTask(info={'url': 'https://bla.pl'}) (result, confidence) = task.cross_check( [verified_list_data, verified_list_data]) self.assertEquals(result, verified_list_data)
def test_verification_default_equals_true(self): verified_dict_data = {'fld': 'val1'} task = AbstractTask(info={'url': 'https://bla.pl'}) (result, confidence) = task.cross_check( [verified_dict_data, verified_dict_data]) self.assertEquals(result, verified_dict_data)
def test_verification_default_complex_true(self): verified_dict_data = {'cars': [{'model': 'A', 'year': 2011}, {'model': 'B', 'year': 2012}]} task = AbstractTask(info={'url': 'https://bla.pl'}) (result, confidence) = task.cross_check([verified_dict_data, verified_dict_data]) self.assertEquals(confidence, 1) self.assertEquals(result, verified_dict_data)