Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tilen1976 committed Aug 20, 2024
1 parent f95dc2b commit e97bb16
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 81 deletions.
17 changes: 0 additions & 17 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

from datadoc import state

from .utils import TEST_EKS_PARQUET
from .utils import TEST_EXISTING_METADATA_DIRECTORY
from .utils import TEST_EXISTING_METADATA_NAMING_STANDARD_FILEPATH_NO_MISSING
from .utils import TEST_PARQUET_FILE_NAME
from .utils import TEST_PARQUET_FILEPATH
from .utils import TEST_RESOURCES_DIRECTORY
Expand Down Expand Up @@ -91,21 +89,6 @@ def metadata(
)


@pytest.fixture()
def metadata_3(
_mock_timestamp: None,
_mock_user_info: None,
subject_mapping_fake_statistical_structure: StatisticSubjectMapping,
tmp_path: Path,
) -> Datadoc:
shutil.copy(TEST_PARQUET_FILEPATH, tmp_path / TEST_EKS_PARQUET)
return Datadoc(
None,
str(TEST_EXISTING_METADATA_NAMING_STANDARD_FILEPATH_NO_MISSING),
statistic_subject_mapping=subject_mapping_fake_statistical_structure,
)


@pytest.fixture()
def existing_metadata_path() -> Path:
return TEST_EXISTING_METADATA_DIRECTORY
Expand Down
29 changes: 29 additions & 0 deletions tests/frontend/callbacks/test_callbacks_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from unittest import mock

import dash_bootstrap_components as dbc
import pytest
from dapla_metadata.datasets import model
from dash import html

from datadoc import state
from datadoc.frontend.callbacks.utils import find_existing_language_string
from datadoc.frontend.callbacks.utils import render_tabs
from datadoc.frontend.callbacks.utils import save_metadata_and_generate_alerts
from datadoc.frontend.components.identifiers import ACCORDION_WRAPPER_ID
from datadoc.frontend.components.identifiers import SECTION_WRAPPER_ID

Expand Down Expand Up @@ -67,3 +72,27 @@ def test_render_tabs(tab: str, identifier: str):
result = render_tabs(tab)
assert isinstance(result, html.Article)
assert result.children[-1].id == identifier


# if none metadata missing: only save alert
# if dataset missing ->
# if variables missing ->
# if another warning ->
# if not n_clicks ?
# if n_clicks and n_clicks > 0 ?
def test_save_and_generate_alerts():
mock_metadata = mock.Mock()
mock_metadata.variables = [
"var1",
"var2",
]
state.metadata = mock_metadata

result = save_metadata_and_generate_alerts(
mock_metadata,
)

num_list_of_alerts = 3
assert len(result) == num_list_of_alerts
assert result[2] is None
assert isinstance(result[0], dbc.Alert)
64 changes: 0 additions & 64 deletions tests/frontend/callbacks/test_callbacks_validation_utils.py

This file was deleted.

0 comments on commit e97bb16

Please sign in to comment.