-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporarily redacted multple conditions tests
- Loading branch information
Showing
7 changed files
with
317 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# tests/test_analysis_study.py | ||
import pytest | ||
from ena_portal_api.ena_api_requests import ENAAPIRequest, ENAPortalResultType | ||
from ena_portal_api.models.analysis_study import AnalysisStudyFields, AnalysisStudyQuery | ||
|
||
@pytest.mark.integration | ||
def test_analysis_study_fields_query(): | ||
"""Test analysis study fields and query with real API request""" | ||
try: | ||
request = ENAAPIRequest( | ||
result=ENAPortalResultType.ANALYSIS_STUDY, | ||
query=AnalysisStudyQuery(study_accession="PRJEB12345"), | ||
fields=[ | ||
AnalysisStudyFields.STUDY_ACCESSION, | ||
AnalysisStudyFields.STUDY_TITLE, | ||
AnalysisStudyFields.ANALYSIS_TYPE, | ||
AnalysisStudyFields.SCIENTIFIC_NAME, | ||
AnalysisStudyFields.TAX_ID, | ||
], | ||
limit=5 | ||
) | ||
response = request.get() | ||
assert response.status_code == 200 | ||
data = response.json() | ||
assert isinstance(data, list) | ||
if len(data) > 0: | ||
assert "study_accession" in data[0] | ||
assert "analysis_type" in data[0] | ||
|
||
@pytest.mark.integration | ||
def test_analysis_study_no_query(): | ||
"""Test analysis study request without query""" | ||
try: | ||
request = ENAAPIRequest( | ||
result=ENAPortalResultType.ANALYSIS_STUDY, | ||
fields=[ | ||
AnalysisStudyFields.STUDY_ACCESSION, | ||
AnalysisStudyFields.STUDY_TITLE, | ||
AnalysisStudyFields.ANALYSIS_TYPE, | ||
], | ||
limit=5 | ||
) | ||
response = request.get() | ||
assert response.status_code == 200 | ||
data = response.json() | ||
assert isinstance(data, list) | ||
assert len(data) <= 5 | ||
if len(data) > 0: | ||
assert "study_accession" in data[0] | ||
|
||
@pytest.mark.integration | ||
def test_analysis_study_comprehensive_fields(): | ||
"""Test analysis study request with comprehensive field set""" | ||
try: | ||
request = ENAAPIRequest( | ||
result=ENAPortalResultType.ANALYSIS_STUDY, | ||
fields=[ | ||
AnalysisStudyFields.STUDY_ACCESSION, | ||
AnalysisStudyFields.STUDY_TITLE, | ||
AnalysisStudyFields.STUDY_ALIAS, | ||
AnalysisStudyFields.ANALYSIS_TYPE, | ||
AnalysisStudyFields.CENTER_NAME, | ||
AnalysisStudyFields.PIPELINE_NAME, | ||
AnalysisStudyFields.PIPELINE_VERSION, | ||
AnalysisStudyFields.SCIENTIFIC_NAME, | ||
AnalysisStudyFields.SAMPLE_ACCESSION, | ||
AnalysisStudyFields.TAX_ID, | ||
], | ||
query=AnalysisStudyQuery(analysis_type="SEQUENCE_ASSEMBLY"), | ||
limit=5 | ||
) | ||
response = request.get() | ||
assert response.status_code == 200 | ||
data = response.json() | ||
assert isinstance(data, list) | ||
if len(data) > 0: | ||
first_record = data[0] | ||
assert "study_accession" in first_record | ||
assert "analysis_type" in first_record | ||
assert first_record["analysis_type"] == "SEQUENCE_ASSEMBLY" | ||
|
||
# @pytest.mark.integration | ||
# def test_analysis_study_multiple_conditions(): | ||
# """Test analysis study request with multiple query conditions""" | ||
# try: | ||
# request = ENAAPIRequest( | ||
# result=ENAPortalResultType.ANALYSIS_STUDY, | ||
# query=( | ||
# AnalysisStudyQuery(analysis_type="SEQUENCE_ASSEMBLY") & | ||
# AnalysisStudyQuery(center_name="EMBL-EBI") | ||
# ), | ||
# fields=[ | ||
# AnalysisStudyFields.STUDY_ACCESSION, | ||
# AnalysisStudyFields.CENTER_NAME, | ||
# AnalysisStudyFields.ANALYSIS_TYPE, | ||
# AnalysisStudyFields.STUDY_TITLE, | ||
# ], | ||
# limit=5 | ||
# ) | ||
# response = request.get() | ||
# assert response.status_code == 200 | ||
# data = response.json() | ||
# assert isinstance(data, list) | ||
# if len(data) > 0: | ||
# assert "study_accession" in data[0] | ||
# assert data[0]["center_name"] == "EMBL-EBI" | ||
# assert data[0]["analysis_type"] == "SEQUENCE_ASSEMBLY" |
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 |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# tests/test_coding.py | ||
import pytest | ||
from ena_portal_api.ena_api_requests import ENAAPIRequest, ENAPortalResultType | ||
from ena_portal_api.models.coding import CodingFields, CodingQuery | ||
|
||
@pytest.mark.integration | ||
def test_coding_fields_query(): | ||
"""Test coding sequence fields and query with real API request""" | ||
try: | ||
request = ENAAPIRequest( | ||
result=ENAPortalResultType.CODING, | ||
query=CodingQuery(coding_length="1000-2000"), # Query for coding sequences between 1-2kb | ||
fields=[ | ||
CodingFields.ACCESSION, | ||
CodingFields.DESCRIPTION, | ||
CodingFields.CODING_LENGTH, | ||
CodingFields.SCIENTIFIC_NAME, | ||
CodingFields.TAX_ID, | ||
], | ||
limit=5 | ||
) | ||
response = request.get() | ||
assert response.status_code == 200 | ||
data = response.json() | ||
assert isinstance(data, list) | ||
if len(data) > 0: | ||
assert "accession" in data[0] | ||
assert "coding_length" in data[0] | ||
length = int(data[0]["coding_length"]) | ||
assert 1000 <= length <= 2000 | ||
|
||
@pytest.mark.integration | ||
def test_coding_no_query(): | ||
"""Test coding sequence request without query""" | ||
try: | ||
request = ENAAPIRequest( | ||
result=ENAPortalResultType.CODING, | ||
fields=[ | ||
CodingFields.ACCESSION, | ||
CodingFields.DESCRIPTION, | ||
CodingFields.CODING_LENGTH, | ||
CodingFields.SCIENTIFIC_NAME, | ||
], | ||
limit=5 | ||
) | ||
response = request.get() | ||
assert response.status_code == 200 | ||
data = response.json() | ||
assert isinstance(data, list) | ||
assert len(data) <= 5 | ||
if len(data) > 0: | ||
assert "accession" in data[0] | ||
|
||
@pytest.mark.integration | ||
def test_coding_comprehensive_fields(): | ||
"""Test coding sequence request with comprehensive field set""" | ||
try: | ||
request = ENAAPIRequest( | ||
result=ENAPortalResultType.CODING, | ||
fields=[ | ||
CodingFields.ACCESSION, | ||
CodingFields.DESCRIPTION, | ||
CodingFields.CODING_LENGTH, | ||
CodingFields.SCIENTIFIC_NAME, | ||
CodingFields.TAX_ID, | ||
CodingFields.GENE_NAME, | ||
CodingFields.PROTEIN_NAME, | ||
CodingFields.EC_NUMBER, | ||
CodingFields.ORGANISM, | ||
CodingFields.STRAIN, | ||
CodingFields.MOLTYPE, | ||
CodingFields.TOPOLOGY, | ||
], | ||
query=CodingQuery( | ||
moltype="mRNA", | ||
organism="Escherichia coli" | ||
), | ||
limit=5 | ||
) | ||
response = request.get() | ||
assert response.status_code == 200 | ||
data = response.json() | ||
assert isinstance(data, list) | ||
if len(data) > 0: | ||
first_record = data[0] | ||
assert "accession" in first_record | ||
assert "moltype" in first_record | ||
assert first_record["moltype"] == "mRNA" | ||
assert first_record["organism"].lower() == "escherichia coli" | ||
|
||
# @pytest.mark.integration | ||
# def test_coding_multiple_conditions(): | ||
# """Test coding sequence request with multiple query conditions""" | ||
# try: | ||
# request = ENAAPIRequest( | ||
# result=ENAPortalResultType.CODING, | ||
# query=( | ||
# CodingQuery(moltype="mRNA") & | ||
# CodingQuery(coding_length="500-1000") | ||
# ), | ||
# fields=[ | ||
# CodingFields.ACCESSION, | ||
# CodingFields.DESCRIPTION, | ||
# CodingFields.CODING_LENGTH, | ||
# CodingFields.MOLTYPE, | ||
# ], | ||
# limit=5 | ||
# ) | ||
# response = request.get() | ||
# assert response.status_code == 200 | ||
# data = response.json() | ||
# assert isinstance(data, list) | ||
# if len(data) > 0: | ||
# assert "accession" in data[0] | ||
# assert "moltype" in data[0] | ||
# assert data[0]["moltype"] == "mRNA" | ||
# length = int(data[0]["coding_length"]) | ||
# assert 500 <= length <= 1000 |
Oops, something went wrong.