Skip to content

Commit

Permalink
add tests for exceptions raised
Browse files Browse the repository at this point in the history
  • Loading branch information
GiaJordan committed Aug 21, 2024
1 parent eb66a37 commit e0d6b8b
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import math
import os
import shutil
from contextlib import contextmanager
from time import sleep
from typing import Any, Generator
from unittest.mock import AsyncMock, patch
Expand All @@ -19,7 +20,7 @@
from synapseclient.entity import File
from synapseclient.models import Annotations

from schematic.configuration.configuration import Configuration
from schematic.configuration.configuration import CONFIG, Configuration
from schematic.schemas.data_model_graph import DataModelGraph, DataModelGraphExplorer
from schematic.schemas.data_model_parser import DataModelParser
from schematic.store.base import BaseStorage
Expand All @@ -31,6 +32,11 @@
logger = logging.getLogger(__name__)


@contextmanager
def does_not_raise():
yield


@pytest.fixture
def test_download_manifest_id():
yield "syn51203973"
Expand Down Expand Up @@ -214,6 +220,34 @@ def test_view_query(
# tests that the query was valid and successful, that a view subset has actually been retrived
assert synapse_store_special_scope.storageFileviewTable.empty is False

@pytest.mark.parametrize(
"asset_view,columns,expectation",
[
("syn62339865", ["path"], pytest.raises(ValueError)),
("syn62340177", ["id"], pytest.raises(ValueError)),
("syn23643253", ["id", "path"], does_not_raise()),
],
)
def test_view_query_exception(
self,
synapse_store_special_scope: SynapseStorage,
asset_view: str,
columns: list,
expectation: str,
) -> None:
project_scope = ["syn23643250"]

# set to use appropriate test view and set scope
CONFIG.synapse_master_fileview_id = asset_view
synapse_store_special_scope.project_scope = project_scope

# ensure approriate exception is raised
with expectation:
synapse_store_special_scope.query_fileview(columns)

# reset config to default fileview
CONFIG.synapse_master_fileview_id = "syn23643253"

def test_getFileAnnotations(self, synapse_store: SynapseStorage) -> None:
expected_dict = {
"author": "bruno, milen, sujay",
Expand Down

0 comments on commit e0d6b8b

Please sign in to comment.