-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_endpoints.py
More file actions
129 lines (107 loc) · 4.08 KB
/
test_endpoints.py
File metadata and controls
129 lines (107 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import pytest
def test_endpoints_test_search_simple():
from igvf_client import IgvfApi
from igvf_client.models.software import Software
api = IgvfApi()
r = api.search(query='abc')
assert r.total > 2
r = api.search(query='abc', limit=1)
assert len(r.graph) == 1
r = api.search(query='abc', type=['Software'], limit=1)
assert len(r.graph) == 1
item = r.graph[0].actual_instance
assert isinstance(item, Software)
assert item.type == ['Software', 'Item']
assert 'software' in item.id
assert 'lab' in item.lab
assert 'award' in item.award
assert item.status == 'released'
assert item.uuid is not None
assert item.title is not None
def test_endpoints_test_search_filters():
from igvf_client import IgvfApi
from igvf_client.models.software import Software
api = IgvfApi()
all_users = api.search(type=['User'], limit=0)
cherry_lab_users = api.search(
type=['User'],
limit=0,
field_filters={
'lab': '/labs/j-michael-cherry/'
}
)
assert cherry_lab_users.total > 10
assert all_users.total > cherry_lab_users.total
def test_endpoints_test_collections():
from igvf_client import IgvfApi
api = IgvfApi()
file_id = '/sequence-files/IGVFFI4531KBUU/'
files = api.measurement_sets(files_id=[file_id]).graph[0].files
assert len(files) >= 1
assert file_id in files
users = api.users(lab=['/labs/j-michael-cherry/'])
assert users.total > 10
assert users.graph[0].lab == '/labs/j-michael-cherry/'
def test_endpoints_test_schemas():
from igvf_client import IgvfApi
api = IgvfApi()
schemas = api.schemas()
assert len(schemas) > 50
assert 'AccessKey' in schemas
assert 'User' in schemas
user_schema = api.schema_for_item_type('User')
assert schemas['User'] == user_schema
def test_endpoints_test_user_collection():
from igvf_client import IgvfApi
api = IgvfApi()
users = api.users(title=['Indexing Service'])
assert users.total == 1
assert users.id == '/users/@@listing?title=Indexing%20Service&frame=object'
assert users.graph[0].id == '/users/1ac5c055-d3e8-4290-a4bb-d5e2f508e54a/'
assert users.graph[0].uuid == '1ac5c055-d3e8-4290-a4bb-d5e2f508e54a'
assert users.graph[0].lab == '/labs/j-michael-cherry/'
assert users.graph[0].title == 'Indexing Service'
assert users.graph[0].type == ['User', 'Item']
user = api.get_by_id(users.graph[0].uuid)
assert user.actual_instance == users.graph[0]
def test_endpoints_test_report():
from igvf_client import IgvfApi
api = IgvfApi()
r = api.report(type=['User'], field_filters={'lab': '/labs/j-michael-cherry/'})
assert 'Indexing Service' in r
assert 'J. Michael Cherry' in r
assert 'ID' in r
assert 'UUID' in r
assert 'Title' in r
assert 'Lab' in r
assert 'Status' in r
def test_endpoints_test_curated_set_collection():
from igvf_client import IgvfApi
api = IgvfApi()
curated_sets = api.curated_sets(files_file_format=['tsv'])
assert curated_sets.total > 10
def test_endpoints_test_download_tsv_file():
from igvf_client import IgvfApi
api = IgvfApi()
r = api.search(field_filters={'file_format': 'tsv'})
raw_tsv = api.download(r.graph[0].uuid)
assert isinstance(raw_tsv, bytes)
assert len(raw_tsv) > 1
def test_endpoints_test_search_facets():
from igvf_client import IgvfApi
api = IgvfApi()
actual_types = [x['key'] for x in api.search(field_filters={'files.file_format': 'tsv'}).facets[0].terms]
expected_types = ['FileSet', 'AuxiliarySet', 'CuratedSet']
for type_ in expected_types:
assert type_ in actual_types
def test_endpoints_test_search_field_filters():
from igvf_client import IgvfApi
api = IgvfApi()
r = api.search(type=['Item'], field_filters={'status': 'current'})
assert r.total > 100
r2 = api.search(type=['Item'], field_filters={'status': ['current', 'released']})
assert r2.total > r.total
def test_endpoints_test_sequence_file_int_coercion():
from igvf_client import IgvfApi
api = IgvfApi()
api.sequence_files()