from unittest.mock import patch import json from tests.test_utils import FixtureLoader from models import models from tests import BaseTestCase, mock from tests.linkfire.fixtures.linkfire_campaigns_fixture import fixture @patch("auth.atlas.atlas_token_decoder.jwt.decode", mock.jwt_decode) class TestCrudCampaign(BaseTestCase): url = "/projects/500/campaigns/34ed4c22-e1f9-4184-a06d-f04cbdb97455/linkfire" def setUp(self): super().setUp() FixtureLoader(models=models).import_as_sql(fixture) def test_update_campaign_linkfire_links(self): update_linkfire_data = { "linkfireLinks": [ {"linkId": "2b190f7c-cf68-4741-9c06-2718c473f6e5", "linkUrl": "lnk.to/Blink_182"}, {"linkId": "ca98fcdd-61ae-43df-b973-765c1ed9143f", "linkUrl": "lnk.to/blink-182_BIOMY"}, {"linkId": "90708787-46a8-4d38-8f5f-4b730951e395", "linkUrl": "Blink182.lnk.to/Quarantine"}, ] } response = self.execute_put(self.url, data=json.dumps(update_linkfire_data), headers=self.headers) result = response.json links = result["linkfireLinks"] self.assertEqual(200, response.status_code) self.assertEqual(len(links), 3) self.assertEqual( links[0], { "id": 3, "linkId": "2b190f7c-cf68-4741-9c06-2718c473f6e5", "linkUrl": "lnk.to/Blink_182", "deletable": True, }, ) self.assertEqual( links[1], { "id": 4, "linkId": "ca98fcdd-61ae-43df-b973-765c1ed9143f", "linkUrl": "lnk.to/blink-182_BIOMY", "deletable": True, }, ) self.assertEqual( links[2], { "id": 5, "linkId": "90708787-46a8-4d38-8f5f-4b730951e395", "linkUrl": "Blink182.lnk.to/Quarantine", "deletable": True, }, )