Tests para get_recording
This commit is contained in:
@@ -360,3 +360,31 @@ class CacheTest(TestCase):
|
||||
self.assertEquals(result, payload)
|
||||
|
||||
mock_jobs.load_entities_of_release.delay.assert_not_called()
|
||||
|
||||
@patch('fetcher.cache.jobs')
|
||||
@patch('fetcher.cache.get_redis_connection')
|
||||
def test_get_recording_not_exists(self, mock_connection, mock_jobs):
|
||||
"""Testear get recording cuando no existe"""
|
||||
mock_redis = CacheTest.mock_redis(mock_connection)
|
||||
mock_redis.get = Mock(return_value=None)
|
||||
|
||||
response = cache.get_recording('mbid')
|
||||
self.assertEquals(response, None)
|
||||
|
||||
mock_redis.get.assert_called_with('recording:mbid')
|
||||
mock_jobs.load_entities_of_recording.delay.assert_called_with('mbid')
|
||||
|
||||
@patch('fetcher.cache.jobs')
|
||||
@patch('fetcher.cache.get_redis_connection')
|
||||
def test_get_recording_exists(self, mock_connection, mock_jobs):
|
||||
"""Testear get recording cuando existe"""
|
||||
payload = {'id': 'mbid', 'title': 'ohno'}
|
||||
|
||||
mock_redis = CacheTest.mock_redis(mock_connection)
|
||||
mock_redis.get = Mock(return_value=json.dumps(payload))
|
||||
|
||||
response = cache.get_recording('mbid')
|
||||
self.assertEquals(response, payload)
|
||||
|
||||
mock_redis.get.assert_called_with('recording:mbid')
|
||||
mock_jobs.load_entities_of_recording.delay.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user