-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use local import to solve circular import - tests in progress
- Loading branch information
Showing
11 changed files
with
544 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/frontend/callbacks/test_callbacks_validation_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# def test_validation_utils() | ||
|
||
|
||
from unittest import mock | ||
|
||
import dash_bootstrap_components as dbc | ||
from dapla_metadata.datasets import Datadoc | ||
|
||
from datadoc import state | ||
from datadoc.frontend.callbacks.utils import save_metadata_and_generate_alerts | ||
from datadoc.frontend.components.builders import AlertTypes | ||
from datadoc.frontend.components.builders import build_ssb_alert | ||
|
||
|
||
# if none metadata missing: only save alert | ||
# if dataset missing -> | ||
# if variables missing -> | ||
# if another warning -> | ||
# if not n_clicks ? | ||
def test_save_and_validate(metadata: Datadoc, mocker): | ||
# if n_clicks and n_clicks > 0 ? | ||
|
||
success_alert = build_ssb_alert( | ||
AlertTypes.SUCCESS, | ||
"Lagret metadata", | ||
) | ||
state.metadata = metadata | ||
|
||
mocker.patch( | ||
"datadoc.frontend.callbacks.utils.save_metadata_and_generate_alerts", | ||
return_value=success_alert, | ||
) | ||
output = save_metadata_and_generate_alerts(metadata) | ||
assert isinstance(output, list) | ||
num_list_of_alerts = 3 | ||
assert len(output) == num_list_of_alerts | ||
assert output[1] is not None | ||
|
||
|
||
def test_with_mock_patch(metadata_3): | ||
state.metadata = metadata_3 | ||
result = save_metadata_and_generate_alerts(metadata_3) | ||
num_list_of_alerts = 3 | ||
assert len(result) == num_list_of_alerts | ||
assert result[1] is None | ||
assert result[2] is None | ||
|
||
|
||
def test_1(): | ||
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) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.