Пример #1
0
    def test_update_cache_with_invalidation(self):
        results = [
            [('Maturity', self.mat.id, 'v1')],
            [],
        ]

        def side_effect(*args, **kwargs):
            return results.pop(0)

        self.mock_cache.update_instance.side_effect = side_effect
        update_cache_for_instance('Specification', self.spec.id)
        expected_calls = [
            mock.call(
                'Specification', self.spec.id, None, None, update_only=False),
            mock.call('Maturity', self.mat.id, None, 'v1', update_only=False)]
        actual_calls = self.mock_cache.update_instance.call_args_list
        self.assertEqual(expected_calls, actual_calls)
Пример #2
0
    def test_update_cache_with_invalidation(self):
        results = [
            [('Maturity', self.mat.id, 'v1')],
            [],
        ]

        def side_effect(*args, **kwargs):
            return results.pop(0)

        self.mock_cache.update_instance.side_effect = side_effect
        update_cache_for_instance('Specification', self.spec.id)
        expected_calls = [
            mock.call('Specification',
                      self.spec.id,
                      None,
                      None,
                      update_only=False),
            mock.call('Maturity', self.mat.id, None, 'v1', update_only=False)
        ]
        actual_calls = self.mock_cache.update_instance.call_args_list
        self.assertEqual(expected_calls, actual_calls)
Пример #3
0
 def test_update_cache_no_invalidation(self):
     self.mock_cache.update_instance.return_value = []
     update_cache_for_instance('Maturity', self.mat.id)
     self.mock_cache.update_instance.assert_called_once_with(
         'Maturity', self.mat.id, None, None, update_only=False)
Пример #4
0
 def test_update_cache_no_invalidation(self):
     self.mock_cache.update_instance.return_value = []
     update_cache_for_instance('Maturity', self.mat.id)
     self.mock_cache.update_instance.assert_called_once_with(
         'Maturity', self.mat.id, None, None, update_only=True)