-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactored the cli wrapper - Refactored the settings to be in line with the rest - Modified the unit tests
- Loading branch information
1 parent
b6ec7cc
commit c51ed5d
Showing
5 changed files
with
79 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from emgapi import metagenomics_exchange as ME | ||
from django.conf import settings | ||
import pytest | ||
from unittest import mock | ||
|
||
class TestME: | ||
from emgapi.metagenomics_exchange import MetagenomicsExchangeAPI | ||
|
||
from requests import HTTPError | ||
|
||
test_ME = ME.MetagenomicsExchangeAPI() | ||
|
||
class TestME: | ||
def test_check_existing_analysis(self): | ||
sourceID = "MGYA00293719" | ||
broker = 'EMG' | ||
url = settings.ME_API['dev'] + f'brokers/{broker}/datasets' | ||
token = settings.ME_TOKEN | ||
assert self.test_ME.check_analysis(url, sourceID, True, token) | ||
me_api = MetagenomicsExchangeAPI() | ||
source_id = "MGYA00293719" | ||
assert me_api.check_analysis(source_id, True) | ||
|
||
def test_check_not_existing_analysis(self): | ||
sourceID = "MGYA00293719" | ||
broker = 'MAR' | ||
url = settings.ME_API['dev'] + f'brokers/{broker}/datasets' | ||
token = settings.ME_TOKEN | ||
assert not self.test_ME.check_analysis(url, sourceID, True, token) | ||
me_api = MetagenomicsExchangeAPI(broker="MAR") | ||
source_id = "MGYA00293719" | ||
assert not me_api.check_analysis(source_id, True) | ||
|
||
def test_post_existing_analysis(self): | ||
sourceID = "MGYA00293719" | ||
broker = 'EMG' | ||
url = settings.ME_API['dev'] | ||
token = settings.ME_TOKEN | ||
assert not self.test_ME.add_record(url=url, mgya=sourceID, run_accession="ERR3063408", public=True, | ||
broker=broker, token=token) | ||
me_api = MetagenomicsExchangeAPI() | ||
source_id = "MGYA00293719" | ||
# Should return -> https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 | ||
with pytest.raises(HTTPError, match="409 Client Error"): | ||
me_api.add_record(mgya=source_id, run_accession="ERR3063408", public=True) |