from unittest.mock import patch from tests.test_utils import FixtureLoader from models import models from tests import BaseTestCase, mock_for_user from tests.labels.fixtures.labels_fixture import fixture from config import LABEL_IMAGE_SERVICE_URL user1Mock = mock_for_user(1, "user-1@example.com", "sme-dna|user-1") class TestGetLabels(BaseTestCase): url = "/labels" def setUp(self): super().setUp() FixtureLoader(models=models).import_as_sql(fixture) @patch("auth.atlas.atlas_token_decoder.jwt.decode", user1Mock.jwt_decode) def test_get_default_label(self): response = self.execute_get(self.url, headers=self.headers) self.assertEqual(200, response.status_code) response_data = response.json self.soft_assert_equal( response_data, [ { "id": 1, "name": "Columbia Records", "externalId": "123456", "country": "USA", "abbreviation": "CLMBRCRDS", 'imageUrl': LABEL_IMAGE_SERVICE_URL.format(id=1) }, { "id": 2, "name": "Epic Records", "externalId": "223456", "country": "USA", "abbreviation": "PCRCRDS", 'imageUrl': LABEL_IMAGE_SERVICE_URL.format(id=2) }, { "id": 3, "name": "RCA Records", "externalId": "323456", "country": "USA", "abbreviation": "RCRCRDS", 'imageUrl': LABEL_IMAGE_SERVICE_URL.format(id=3) }, { "id": 4, "name": "CMG", "externalId": "423456", "country": "USA", "abbreviation": "CMG", 'imageUrl': LABEL_IMAGE_SERVICE_URL.format(id=4) }, { "id": 5, "name": "Nashville", "externalId": "523456", "country": "USA", "abbreviation": "NSHVLL", 'imageUrl': LABEL_IMAGE_SERVICE_URL.format(id=5) }, ] ) self.assert_all()