Skip to content

Commit

Permalink
test: speed up e2e validate data tests (DEV-4484) (#1350)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Dec 18, 2024
1 parent f17c5f2 commit b38144f
Showing 1 changed file with 40 additions and 85 deletions.
125 changes: 40 additions & 85 deletions test/e2e_validate_data/test_validate_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from functools import lru_cache
from pathlib import Path
from typing import Iterator

Expand Down Expand Up @@ -36,177 +35,133 @@
DONT_SAVE_GRAPHS = False


@lru_cache(maxsize=None)
@pytest.fixture
def _create_project_generic() -> Iterator[None]:
@pytest.fixture(scope="module")
def _create_projects() -> Iterator[None]:
with get_containers():
success = create_project(Path("testdata/validate-data/generic/project.json"), CREDS)
assert success
assert create_project(Path("testdata/validate-data/generic/project.json"), CREDS)
assert create_project(Path("testdata/validate-data/special_characters/project_special_characters.json"), CREDS)
assert create_project(Path("testdata/validate-data/inheritance/project_inheritance.json"), CREDS)
yield


@lru_cache(maxsize=None)
@pytest.fixture
@pytest.fixture(scope="module")
def api_con() -> ApiConnection:
return ApiConnection(LOCAL_API)


@lru_cache(maxsize=None)
@pytest.fixture
def cardinality_correct(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def cardinality_correct(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/cardinality_correct.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def unknown_classes_graphs(_create_project_generic: Iterator[None], api_con: ApiConnection) -> RDFGraphs:
@pytest.fixture(scope="module")
def unknown_classes_graphs(_create_projects: Iterator[None], api_con: ApiConnection) -> RDFGraphs:
file = Path("testdata/validate-data/generic/unknown_classes.xml")
return _get_parsed_graphs(api_con, file)


@lru_cache(maxsize=None)
@pytest.fixture
def cardinality_violation(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def cardinality_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/cardinality_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def content_correct(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def content_correct(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/content_correct.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def content_violation(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def content_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/content_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def every_combination_once(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def every_combination_once(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/every_combination_once.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def minimal_correct(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def minimal_correct(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/minimal_correct.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def value_type_violation(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def value_type_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/value_type_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def unique_value_violation(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def unique_value_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/unique_value_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def file_value_correct(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def file_value_correct(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/file_value_correct.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def file_value_violation(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def file_value_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/file_value_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def dsp_inbuilt_correct(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def dsp_inbuilt_correct(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/dsp_inbuilt_correct.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def dsp_inbuilt_violation(_create_project_generic: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def dsp_inbuilt_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/generic/dsp_inbuilt_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def _create_project_special() -> Iterator[None]:
with get_containers():
success = create_project(
Path("testdata/validate-data/special_characters/project_special_characters.json"), CREDS
)
assert success
yield


@lru_cache(maxsize=None)
@pytest.fixture
def special_characters_correct(
_create_project_special: Iterator[None], api_con: ApiConnection
) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def special_characters_correct(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/special_characters/special_characters_correct.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def special_characters_violation(
_create_project_special: Iterator[None], api_con: ApiConnection
) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def special_characters_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/special_characters/special_characters_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def _create_project_inheritance() -> Iterator[None]:
with get_containers():
success = create_project(Path("testdata/validate-data/inheritance/project_inheritance.json"), CREDS)
assert success
yield


@lru_cache(maxsize=None)
@pytest.fixture
def inheritance_correct(_create_project_inheritance: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def inheritance_correct(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/inheritance/inheritance_correct.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)


@lru_cache(maxsize=None)
@pytest.fixture
def inheritance_violation(
_create_project_inheritance: Iterator[None], api_con: ApiConnection
) -> ValidationReportGraphs:
@pytest.fixture(scope="module")
def inheritance_violation(_create_projects: Iterator[None], api_con: ApiConnection) -> ValidationReportGraphs:
file = Path("testdata/validate-data/inheritance/inheritance_violation.xml")
graphs = _get_parsed_graphs(api_con, file)
return _get_validation_result(graphs, api_con, file, DONT_SAVE_GRAPHS)
Expand Down

0 comments on commit b38144f

Please sign in to comment.