Ejemplo n.º 1
0
 def test_get_throws_exception(self, get_from_cache):
     get_from_cache.get_infographics_data_from_cache.side_effect = RuntimeError
     res = get_infographics_data(7, 1, "he")
     get_from_cache.get_infographics_data_from_cache.assert_called_with(
         7, 1)
     self.assertEqual(
         res, {}, f"returned value in case of exception should be None")
Ejemplo n.º 2
0
 def test_get_existing(self, get_from_cache):
     expected = {"data": "data", "widgets": []}
     get_from_cache.get_infographics_data_from_cache.return_value = expected
     create_infographics_data = Mock()
     res = get_infographics_data(7, 1, "he")
     get_from_cache.get_infographics_data_from_cache.assert_called_with(7, 1)
     get_from_cache.create_infographics_data.assert_not_called()
     create_infographics_data.assert_not_called()
     self.assertEqual(res, expected, f"got:{str}, but {expected} should be found in cache")
Ejemplo n.º 3
0
 def test_get_throws_exception(self, get_from_cache, utils):
     expected = {'data': "created"}
     get_from_cache.get_infographics_data_from_cache.side_effect = RuntimeError
     utils.return_value = expected
     # create_infographics_data = Mock()
     res = get_infographics_data(7, 1)
     get_from_cache.get_infographics_data_from_cache.assert_called_with(
         7, 1)
     utils.assert_called_with(7, 1)
     self.assertEqual(res, expected, f'{expected} should be found in cache')
Ejemplo n.º 4
0
 def test_get_not_existing(self, get_from_cache, utils):
     expected = {'data': "created"}
     get_from_cache.get_infographics_data_from_cache.return_value = {}
     utils.return_value = expected
     # create_infographics_data = Mock()
     res = get_infographics_data(7, 1)
     get_from_cache.get_infographics_data_from_cache.assert_called_with(
         7, 1)
     utils.assert_called_with(7, 1)
     self.assertEqual(res, expected, f'{expected} should be found in cache')
Ejemplo n.º 5
0
 def test_get_existing(self, get_from_cache):
     expected = {'data': 'data'}
     get_from_cache.get_infographics_data_from_cache.return_value = expected
     create_mock_infographics_data = Mock()
     res = get_infographics_data(7, 1)
     get_from_cache.get_infographics_data_from_cache.assert_called_with(
         7, 1)
     get_from_cache.create_mock_infographics_data.assert_not_called()
     create_mock_infographics_data.assert_not_called()
     self.assertEqual(res, expected, f'{expected} should be found in cache')
Ejemplo n.º 6
0
 def test_get_not_existing(self, get_from_cache):
     get_from_cache.get_infographics_data_from_cache.return_value = {}
     res = get_infographics_data(7, 1)
     get_from_cache.get_infographics_data_from_cache.assert_called_with(
         7, 1)
     self.assertEqual(res, {}, f"(7,1) should not be found in cache")