|
14 | 14 | import pytest
|
15 | 15 | from aioresponses.core import aioresponses
|
16 | 16 | from servicelib.client_session import get_client_session
|
17 |
| -from simcore_service_webserver.scicrunch.service_client import SciCrunch |
| 17 | +from simcore_service_webserver.scicrunch.service_client import ( |
| 18 | + ResearchResource, |
| 19 | + SciCrunch, |
| 20 | +) |
18 | 21 | from simcore_service_webserver.scicrunch.submodule_setup import (
|
19 | 22 | setup_scicrunch_submodule,
|
20 | 23 | )
|
@@ -122,43 +125,33 @@ async def fake_app(mock_env_devel_environment, loop):
|
122 | 125 | await client.close()
|
123 | 126 |
|
124 | 127 |
|
| 128 | +## TESTS ------------------------------------------------------- |
| 129 | + |
| 130 | + |
125 | 131 | def test_setup_scicrunch_submodule(fake_app):
|
126 | 132 | # scicruch should be init
|
127 | 133 | scicrunch = SciCrunch.get_instance(fake_app)
|
128 | 134 | assert scicrunch
|
129 | 135 | assert scicrunch.client == get_client_session(fake_app)
|
130 | 136 |
|
131 | 137 |
|
132 |
| -## TESTS ------------------------------------------------------- |
133 |
| - |
134 |
| - |
135 |
| -async def test_unauntheticated_request_to_scicrunch(fake_app): |
| 138 | +async def test_get_research_resource(fake_app, mock_scicrunch_service_api): |
136 | 139 | scicrunch = SciCrunch.get_instance(fake_app)
|
137 |
| - resource = await scicrunch.get_resource_fields(rrid) |
138 |
| - |
139 |
| - |
140 |
| -@pytest.mark.parametrize( |
141 |
| - "name,rrid", |
142 |
| - [ |
143 |
| - (None, "SCR_INVALID_XXXXX"), |
144 |
| - (None, "ANOTHER_INVALID_RRID"), |
145 |
| - ] |
146 |
| - + VALID_RRID_SAMPLES, |
147 |
| -) |
148 |
| -async def test_scicrunch_service_rrid_validation(name, rrid, scicrunch): |
| 140 | + resource: ResearchResource = await scicrunch.get_resource_fields(rrid="SCR_018997") |
149 | 141 |
|
150 |
| - validation_result = await scicrunch.validate_rrid(rrid) |
| 142 | + assert resource.rrid == "RRID:SCR_018997" |
| 143 | + assert resource.name == "o²S²PARC" |
151 | 144 |
|
152 |
| - assert validation_result == ( |
153 |
| - ValidationResult.VALID if name else ValidationResult.INVALID |
154 |
| - ), f"{name} with rrid={rrid} is undefined" |
155 | 145 |
|
| 146 | +@pytest.mark.skip(reason="UNDER DEV: test_group_handlers") |
| 147 | +async def test_unauntheticated_request_to_scicrunch(client): |
| 148 | + # TODO: group handler calls |
| 149 | + from aiohttp import web_exceptions |
156 | 150 |
|
157 |
| -@pytest.mark.parametrize( |
158 |
| - "name,rrid", |
159 |
| - VALID_RRID_SAMPLES, |
160 |
| -) |
161 |
| -async def test_scicrunch_service_get_rrid_fields(name, rrid, scicrunch): |
162 |
| - assert name is not None |
163 |
| - resource = await scicrunch.get_resource_fields(rrid) |
164 |
| - assert resource.scicrunch_id == rrid |
| 151 | + with aioresponses() as mock: |
| 152 | + # TODO: mock scicrunch returns unauntheticated |
| 153 | + with pytest.raises(web_exceptions.HTTPBadRequest): |
| 154 | + resp = await client.post( |
| 155 | + "/groups/sparc/classifiers/scicrunch-resources/SCR_018997", |
| 156 | + raise_for_status=True, |
| 157 | + ) |
0 commit comments