Skip to content

Commit

Permalink
fix synapse test file when secrets file doesnt exists
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewelamb committed Dec 7, 2023
1 parent 2493241 commit 841de8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/schematic/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"test": {
"executor": "nx:run-commands",
"options": {
"command": "poetry run pytest -m unit",
"command": "poetry run pytest -m 'not secrets'",
"cwd": "apps/schematic/api"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for validation endpoint functions"""

from unittest.mock import patch
import pytest

from schematic_api.models.basic_error import BasicError
import schematic_api.controllers.manifest_validation_controller_impl
Expand Down Expand Up @@ -57,7 +56,6 @@ def test_500(self, correct_manifest_path: str, test_schema_url: str) -> None:
assert isinstance(result, BasicError)


@pytest.mark.unit
class TestSubmitManifestJson:
"""Tests submit_manifest_"""

Expand Down Expand Up @@ -100,7 +98,6 @@ def test_500(self, correct_manifest_path: str, test_schema_url: str) -> None:
assert isinstance(result, BasicError)


@pytest.mark.unit
class TestValidateManifestCsv:
"""Tests validate_manifest_csv"""

Expand Down Expand Up @@ -168,7 +165,6 @@ def test_500(self, correct_manifest_path: str, test_schema_url: str) -> None:
assert isinstance(result, BasicError)


@pytest.mark.unit
class TestValidateManifestJson:
"""Tests validate_manifest_json"""

Expand Down
24 changes: 16 additions & 8 deletions apps/schematic/api/schematic_api/test/test_synapse_endpoints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for endpoints that use Synapse without mocking the Synapse client"""

import json
import os

import pytest
import yaml
Expand All @@ -14,14 +15,21 @@
csv_to_json_str,
)

with open("schematic_api/test/data/synapse_config.yaml", "r", encoding="utf-8") as file:
secrets = yaml.safe_load(file)
SYNAPSE_TOKEN = secrets["synapse_token"]
TEST_DATASET = secrets["test_dataset"]
TEST_MANIFEST = secrets["test_manifest"]
TEST_ASSET_VIEW = secrets["test_asset_view"]
TEST_PROJECT = secrets["test_project"]

SECRETS_FILE = "schematic_api/test/data/synapse_config.yaml"
EXAMPLE_SECRETS_FILE = "schematic_api/test/data/synapse_config_example.yaml"

if os.path.exists(SECRETS_FILE):
with open(SECRETS_FILE, "r", encoding="utf-8") as file:
secrets = yaml.safe_load(file)
else:
with open(EXAMPLE_SECRETS_FILE, "r", encoding="utf-8") as file:
secrets = yaml.safe_load(file)

SYNAPSE_TOKEN = secrets["synapse_token"]
TEST_DATASET = secrets["test_dataset"]
TEST_MANIFEST = secrets["test_manifest"]
TEST_ASSET_VIEW = secrets["test_asset_view"]
TEST_PROJECT = secrets["test_project"]

HEADERS = {
"Accept": "application/json",
Expand Down

0 comments on commit 841de8c

Please sign in to comment.