diff --git a/tests/me/test_metagenomics_exchange.py b/tests/me/test_metagenomics_exchange.py index f387618df..320de1f5d 100644 --- a/tests/me/test_metagenomics_exchange.py +++ b/tests/me/test_metagenomics_exchange.py @@ -2,14 +2,10 @@ # -*- coding: utf-8 -*- import pytest -from unittest import mock from emgapi.metagenomics_exchange import MetagenomicsExchangeAPI import requests -import responses -import settings - class TestME: def test_check_existing_analysis(self): @@ -28,19 +24,3 @@ def test_post_existing_analysis(self): # Should return -> https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 with pytest.raises(requests.HTTPError, match="409 Client Error"): me_api.add_record(mgya=source_id, run_accession="ERR3063408", public=True).json() - - @responses.activate - def test_mock_post_new_analysis(self): - me_api = MetagenomicsExchangeAPI() - endpoint = "datasets" - url = settings.ME_API + f"/{endpoint}" - - responses.add(responses.POST, url, json={'success': True}, status=201) - - response = me_api.add_record(mgya="MGYA00593709", run_accession="SRR3960575", public=True) - - assert response.status_code == 201 - assert response.json() == {'success': True} - - - diff --git a/tests/me/test_mgx_api.py b/tests/me/test_mgx_api.py index a219747a7..9d86973c4 100644 --- a/tests/me/test_mgx_api.py +++ b/tests/me/test_mgx_api.py @@ -15,14 +15,31 @@ # limitations under the License. import pytest +import responses from unittest.mock import patch from django.core.management import call_command +import settings from test_utils.emg_fixtures import * # noqa +from emgapi.metagenomics_exchange import MetagenomicsExchangeAPI from emgapi.models import AnalysisJob, MetagenomicsExchange, ME_Broker +class TestMockResponse: + @responses.activate + def test_mock_post_new_analysis(self): + me_api = MetagenomicsExchangeAPI() + endpoint = "datasets" + url = settings.ME_API + f"/{endpoint}" + + responses.add(responses.POST, url, json={'success': True}, status=201) + + response = me_api.add_record(mgya="MGYA00593709", run_accession="SRR3960575", public=True) + + assert response.status_code == 201 + assert response.json() == {'success': True} + @pytest.mark.django_db class TestMeAPI: @patch("emgapi.metagenomics_exchange.MetagenomicsExchangeAPI.post_request")