Skip to content

Commit a483ecd

Browse files
authored
Merge pull request #34 from microbiomedata/29-notebook_api_utilities-production-tests-failed
Update test_notebooks filter that uses 11.6 schema
2 parents 2dd6bb8 + 9fc5448 commit a483ecd

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

nmdc_api_utilities/test/test_biosample.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,34 @@
55
import logging
66

77
logging.basicConfig(level=logging.DEBUG)
8+
import os
9+
from dotenv import load_dotenv
10+
11+
load_dotenv()
12+
ENV = os.getenv("ENV")
813

914

1015
def test_find_biosample_by_id():
11-
biosample = BiosampleSearch()
16+
biosample = BiosampleSearch(env=ENV)
1217
results = biosample.get_record_by_id("nmdc:bsm-11-002vgm56")
1318
assert len(results) > 0
1419
assert results["id"] == "nmdc:bsm-11-002vgm56"
1520

1621

1722
def test_logger():
18-
biosample = BiosampleSearch()
23+
biosample = BiosampleSearch(env=ENV)
1924
logging.basicConfig(level=logging.DEBUG)
2025
results = biosample.get_record_by_id("nmdc:bsm-11-002vgm56")
2126

2227

2328
def test_biosample_by_filter():
24-
biosample = BiosampleSearch()
29+
biosample = BiosampleSearch(env=ENV)
2530
results = biosample.get_record_by_filter('{"id":"nmdc:bsm-11-006pnx90"}')
2631
assert len(results) > 0
2732

2833

2934
def test_biosample_by_attribute():
30-
biosample = BiosampleSearch()
35+
biosample = BiosampleSearch(env=ENV)
3136
results = biosample.get_record_by_attribute(
3237
"id", "nmdc:bsm-11-006pnx90", exact_match=False
3338
)
@@ -37,23 +42,23 @@ def test_biosample_by_attribute():
3742

3843
def test_biosample_by_latitude():
3944
# {"lat_lon.latitude": {"$gt": 45.0}, "lat_lon.longitude": {"$lt":45}}
40-
biosample = BiosampleSearch()
45+
biosample = BiosampleSearch(env=ENV)
4146
results = biosample.get_record_by_latitude("gt", 45.0)
4247
assert len(results) > 0
4348
assert results[0]["lat_lon"]["latitude"] == 63.875088
4449

4550

4651
def test_biosample_by_longitude():
4752
# {"lat_lon.latitude": {"$gt": 45.0}, "lat_lon.longitude": {"$lt":45}}
48-
biosample = BiosampleSearch()
53+
biosample = BiosampleSearch(env=ENV)
4954
results = biosample.get_record_by_longitude("lt", 45.0)
5055
assert len(results) > 0
5156
assert results[0]["lat_lon"]["longitude"] == -149.210438
5257

5358

5459
def test_biosample_by_lat_long():
5560
# {"lat_lon.latitude": {"$gt": 45.0}, "lat_lon.longitude": {"$lt":45}}
56-
biosample = BiosampleSearch()
61+
biosample = BiosampleSearch(env=ENV)
5762
results = biosample.get_record_by_lat_long("gt", "lt", 45.0, 45.0)
5863
assert len(results) > 0
5964
assert results[0]["lat_lon"]["latitude"] == 63.875088
@@ -62,7 +67,7 @@ def test_biosample_by_lat_long():
6267

6368
def test_biosample_build_filter_1():
6469
u = DataProcessing()
65-
b = BiosampleSearch()
70+
b = BiosampleSearch(env=ENV)
6671
filter = u.build_filter({"name": "G6R2_NF_20JUN2016"})
6772
results = b.get_record_by_filter(filter)
6873
print(results)
@@ -71,7 +76,7 @@ def test_biosample_build_filter_1():
7176

7277
def test_biosample_build_filter_2():
7378
u = DataProcessing()
74-
b = BiosampleSearch()
79+
b = BiosampleSearch(env=ENV)
7580
filter = u.build_filter({"name": "G6R2_NF_20JUN2016", "id": "nmdc:bsm-11-006pnx90"})
7681
logging.debug("Biosample test filter:", filter)
7782
results = b.get_record_by_filter(filter)

nmdc_api_utilities/test/test_metdata.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
CLIENT_ID = os.getenv("CLIENT_ID")
99
CLIENT_SECRET = os.getenv("CLIENT_SECRET")
10+
ENV = os.getenv("ENV")
1011

1112

1213
def test_validate():
13-
metadata = Metadata()
14+
metadata = Metadata(env=ENV)
1415
results = metadata.validate_json("nmdc_api_utilities/test/test_data/test.json")
1516
assert results == None

nmdc_api_utilities/test/test_mint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from dotenv import load_dotenv
66

77
load_dotenv()
8-
8+
ENV = os.getenv("ENV")
99
CLIENT_ID = os.getenv("CLIENT_ID")
1010
CLIENT_SECRET = os.getenv("CLIENT_SECRET")
1111

1212

1313
def test_mint():
14-
mint = Minter()
14+
mint = Minter(env=ENV)
1515
results = mint.mint("nmdc:DataObject", CLIENT_ID, CLIENT_SECRET)
1616
assert results
1717
assert "nmdc:dobj" in results

nmdc_api_utilities/test/test_notebooks.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
from nmdc_api_utilities.data_processing import DataProcessing
33
from nmdc_api_utilities.data_object_search import DataObjectSearch
44
from nmdc_api_utilities.workflow_execution_search import WorkflowExecutionSearch
5+
from dotenv import load_dotenv
6+
import os
7+
8+
load_dotenv()
9+
ENV = os.getenv("ENV")
510

611

712
def test_nom_notebook():
8-
dos_client = DataObjectSearch()
13+
dos_client = DataObjectSearch(env=ENV)
914

1015
dp_client = DataProcessing()
1116
processed_nom = dos_client.get_record_by_attribute(
1217
attribute_name="data_object_type",
13-
attribute_value="FT ICR-MS Analysis Results",
18+
attribute_value="Direct Infusion FT-ICR MS Analysis Results",
1419
max_page_size=100,
1520
fields="id,md5_checksum,url",
1621
all_pages=True,

nmdc_api_utilities/test/test_study.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# -*- coding: utf-8 -*-
22
from nmdc_api_utilities.study_search import StudySearch
33
import logging
4+
import os
5+
from dotenv import load_dotenv
46

7+
load_dotenv()
8+
ENV = os.getenv("ENV")
59
logging.basicConfig(level=logging.DEBUG)
610

711

812
def test_find_study_by_attribute():
9-
st = StudySearch()
13+
st = StudySearch(env=ENV)
1014
stu = st.get_record_by_attribute(
1115
"name",
1216
"Lab enrichment of tropical soil microbial communities from Luquillo Experimental Forest, Puerto Rico",
@@ -20,14 +24,14 @@ def test_find_study_by_attribute():
2024

2125

2226
def test_find_study_by_id():
23-
st = StudySearch()
27+
st = StudySearch(env=ENV)
2428
stu = st.get_record_by_id("nmdc:sty-11-8fb6t785")
2529
assert len(stu) > 0
2630
assert stu["id"] == "nmdc:sty-11-8fb6t785"
2731

2832

2933
def test_find_study_by_filter():
30-
st = StudySearch()
34+
st = StudySearch(env=ENV)
3135
stu = st.get_record_by_filter(
3236
'{"name":"Lab enrichment of tropical soil microbial communities from Luquillo Experimental Forest, Puerto Rico"}'
3337
)
@@ -39,14 +43,14 @@ def test_find_study_by_filter():
3943

4044

4145
def test_get_studies_all_pages():
42-
st = StudySearch()
46+
st = StudySearch(env=ENV)
4347
studies = st.get_records(max_page_size=20, all_pages=True)
4448
print(studies)
4549
assert len(studies) > 32
4650

4751

4852
def test_get_studies():
49-
st = StudySearch()
53+
st = StudySearch(env=ENV)
5054
studies = st.get_records(max_page_size=100)
5155
print(studies)
5256
assert len(studies) > 32

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "nmdc_api_utilities"
77

8-
version = "0.3.8"
8+
version = "0.3.9"
99

1010
description = "A Python library for general research functions using NMDC APIs"
1111
authors = [

0 commit comments

Comments
 (0)