From b38144fc4966fc999c7f9fd53623236e72d20927 Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum <39048939+jnussbaum@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:33:12 +0100 Subject: [PATCH] test: speed up e2e validate data tests (DEV-4484) (#1350) --- test/e2e_validate_data/test_validate_data.py | 125 ++++++------------- 1 file changed, 40 insertions(+), 85 deletions(-) diff --git a/test/e2e_validate_data/test_validate_data.py b/test/e2e_validate_data/test_validate_data.py index b0e21bbe0..a939e6ada 100644 --- a/test/e2e_validate_data/test_validate_data.py +++ b/test/e2e_validate_data/test_validate_data.py @@ -1,4 +1,3 @@ -from functools import lru_cache from pathlib import Path from typing import Iterator @@ -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)