diff --git a/.secrets.baseline b/.secrets.baseline index c86c5b0..f5f9f7e 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -187,7 +187,7 @@ "filename": "tests/conftest.py", "hashed_secret": "0dd78d9147bb410f0cb0199c5037da36594f77d8", "is_verified": false, - "line_number": 224 + "line_number": 226 } ], "tests/migrations/test_migration_e1886270d9d2.py": [ @@ -209,5 +209,5 @@ } ] }, - "generated_at": "2024-12-16T16:26:23Z" + "generated_at": "2024-12-16T16:59:25Z" } diff --git a/tests/conftest.py b/tests/conftest.py index e5c17a1..188a6e9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,6 +15,8 @@ import pytest_asyncio from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine from starlette.config import environ +from threading import Thread +import uvicorn # Set up the config *before* loading the app, which loads the configuration CURRENT_DIR = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/test_ga4gh_tes.py b/tests/test_ga4gh_tes.py index 8a29fda..6652692 100644 --- a/tests/test_ga4gh_tes.py +++ b/tests/test_ga4gh_tes.py @@ -95,7 +95,7 @@ async def test_get_task(client, access_token_patcher, view): mock_arborist_request.assert_called_with( method="POST", path=f"/auth/request", - body=f'{{"requests": [{{"resource": "/users/{TEST_USER_ID}/gen3-workflow/tasks/123", "action": {{"service": "gen3-workflow", "method": "read"}}}}], "user": {{"token": "123"}}}}', + body=f'{{"requests":[{{"resource":"/users/{TEST_USER_ID}/gen3-workflow/tasks/123","action":{{"service":"gen3-workflow","method":"read"}}}}],"user":{{"token":"123"}}}}', authorized=client.authorized, ) @@ -129,7 +129,7 @@ async def test_create_task(client, access_token_patcher): method="POST", path="/tasks", query_params={}, - body=f'{{"name": "test-task", "tags": {{"AUTHZ": "/users/{TEST_USER_ID}/gen3-workflow/tasks/TASK_ID_PLACEHOLDER"}}}}', + body=f'{{"name":"test-task","tags":{{"AUTHZ":"/users/{TEST_USER_ID}/gen3-workflow/tasks/TASK_ID_PLACEHOLDER"}}}}', status_code=client.tes_resp_code, ) @@ -137,14 +137,14 @@ async def test_create_task(client, access_token_patcher): mock_arborist_request.assert_any_call( method="POST", path=f"/auth/request", - body=f'{{"requests": [{{"resource": "/services/workflow/gen3-workflow/tasks", "action": {{"service": "gen3-workflow", "method": "create"}}}}], "user": {{"token": "123"}}}}', + body=f'{{"requests":[{{"resource":"/services/workflow/gen3-workflow/tasks","action":{{"service":"gen3-workflow","method":"create"}}}}],"user":{{"token":"123"}}}}', authorized=client.authorized, ) if client.authorized and client.tes_resp_code != 500: mock_arborist_request.assert_any_call( method="POST", path=f"/auth/request", - body=f'{{"requests": [{{"resource": "/users/{TEST_USER_ID}/gen3-workflow/tasks", "action": {{"service": "gen3-workflow", "method": "read"}}}}], "user": {{"token": "123"}}}}', + body=f'{{"requests":[{{"resource":"/users/{TEST_USER_ID}/gen3-workflow/tasks","action":{{"service":"gen3-workflow","method":"read"}}}}],"user":{{"token":"123"}}}}', authorized=client.authorized, ) @@ -169,7 +169,7 @@ async def test_create_task_new_user(client, access_token_patcher): method="POST", path="/tasks", query_params={}, - body=f'{{"name": "test-task", "tags": {{"AUTHZ": "/users/{NEW_TEST_USER_ID}/gen3-workflow/tasks/TASK_ID_PLACEHOLDER"}}}}', + body=f'{{"name":"test-task","tags":{{"AUTHZ":"/users/{NEW_TEST_USER_ID}/gen3-workflow/tasks/TASK_ID_PLACEHOLDER"}}}}', status_code=200, ) @@ -177,31 +177,31 @@ async def test_create_task_new_user(client, access_token_patcher): mock_arborist_request.assert_any_call( method="POST", path=f"/resource/users/{NEW_TEST_USER_ID}/gen3-workflow", - body=f'{{"name": "tasks", "description": "Represents workflow tasks owned by user \'test-username-{NEW_TEST_USER_ID}\'"}}', + body=f'{{"name":"tasks","description":"Represents workflow tasks owned by user \'test-username-{NEW_TEST_USER_ID}\'"}}', authorized=True, ) mock_arborist_request.assert_any_call( method="POST", path="/role", - body='{"id": "gen3-workflow_task_owner", "permissions": [{"id": "gen3-workflow-reader", "action": {"service": "gen3-workflow", "method": "read"}}, {"id": "gen3-workflow-deleter", "action": {"service": "gen3-workflow", "method": "delete"}}]}', + body='{"id":"gen3-workflow_task_owner","permissions":[{"id":"gen3-workflow-reader","action":{"service":"gen3-workflow","method":"read"}},{"id":"gen3-workflow-deleter","action":{"service":"gen3-workflow","method":"delete"}}]}', authorized=True, ) mock_arborist_request.assert_any_call( method="POST", path="/policy", - body=f'{{"id": "gen3-workflow_task_owner_sub-{NEW_TEST_USER_ID}", "description": "policy created by gen3-workflow for user \'test-username-{NEW_TEST_USER_ID}\'", "role_ids": ["gen3-workflow_task_owner"], "resource_paths": ["/users/{NEW_TEST_USER_ID}/gen3-workflow/tasks"]}}', + body=f'{{"id":"gen3-workflow_task_owner_sub-{NEW_TEST_USER_ID}","description":"policy created by gen3-workflow for user \'test-username-{NEW_TEST_USER_ID}\'","role_ids":["gen3-workflow_task_owner"],"resource_paths":["/users/{NEW_TEST_USER_ID}/gen3-workflow/tasks"]}}', authorized=True, ) mock_arborist_request.assert_any_call( method="POST", path="/user", - body=f'{{"name": "test-username-{NEW_TEST_USER_ID}"}}', + body=f'{{"name":"test-username-{NEW_TEST_USER_ID}"}}', authorized=True, ) mock_arborist_request.assert_any_call( method="POST", path=f"/user/test-username-{NEW_TEST_USER_ID}/policy", - body=f'{{"policy": "gen3-workflow_task_owner_sub-{NEW_TEST_USER_ID}"}}', + body=f'{{"policy":"gen3-workflow_task_owner_sub-{NEW_TEST_USER_ID}"}}', authorized=True, ) @@ -357,7 +357,7 @@ async def test_create_task_with_whitelist_images( method="POST", path="/tasks", query_params={}, - body=json.dumps(result_body), + body=json.dumps(result_body, separators=(",", ":")), status_code=200, ) @@ -481,6 +481,6 @@ async def test_delete_task(client, access_token_patcher): mock_arborist_request.assert_called_with( method="POST", path=f"/auth/request", - body=f'{{"requests": [{{"resource": "/users/{TEST_USER_ID}/gen3-workflow/tasks/123", "action": {{"service": "gen3-workflow", "method": "delete"}}}}], "user": {{"token": "123"}}}}', + body=f'{{"requests":[{{"resource":"/users/{TEST_USER_ID}/gen3-workflow/tasks/123","action":{{"service":"gen3-workflow","method":"delete"}}}}],"user":{{"token":"123"}}}}', authorized=client.authorized, )