-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor common fixtures into 'conftest.py' (#353)
* Refactor common fixtures into 'conftest.py' * run pre-commit * Fix function sigs
- Loading branch information
Showing
12 changed files
with
208 additions
and
267 deletions.
There are no files selected for viewing
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,93 @@ | ||
from unittest.mock import MagicMock | ||
|
||
import pandas as pd | ||
import polars as pl | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def df_personer() -> pl.DataFrame: | ||
JSON_FILE = "tests/data/personer.json" | ||
return pl.read_json( | ||
JSON_FILE, | ||
schema={ | ||
"fnr": pl.String, | ||
"fornavn": pl.String, | ||
"etternavn": pl.String, | ||
"kjonn": pl.String, | ||
"fodselsdato": pl.String, | ||
}, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def df_personer_pandas() -> pd.DataFrame: | ||
JSON_FILE = "tests/data/personer.json" | ||
return pd.read_json( | ||
JSON_FILE, | ||
dtype={ | ||
"fnr": str, | ||
"fornavn": str, | ||
"etternavn": str, | ||
"kjonn": str, | ||
"fodselsdato": str, | ||
}, | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def personer_hierarch_file_path() -> str: | ||
return "tests/data/personer_hierarchical.json" | ||
|
||
|
||
@pytest.fixture() | ||
def personer_pseudonymized_hierarch_file_path() -> str: | ||
return "tests/data/personer_hierarchical_pseudonymized.json" | ||
|
||
|
||
@pytest.fixture | ||
def personer_file_path() -> str: | ||
return "tests/data/personer.json" | ||
|
||
|
||
@pytest.fixture() | ||
def personer_pseudonymized_file_path() -> str: | ||
return "tests/data/personer_pseudonymized_default_encryption.json" | ||
|
||
|
||
@pytest.fixture | ||
def df_personer_fnr_daead_encrypted() -> pl.DataFrame: | ||
JSON_FILE = "tests/data/personer_pseudonymized_default_encryption.json" | ||
return pl.read_json( | ||
JSON_FILE, | ||
schema={ | ||
"fnr": pl.String, | ||
"fornavn": pl.String, | ||
"etternavn": pl.String, | ||
"kjonn": pl.String, | ||
"fodselsdato": pl.String, | ||
}, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def df_pandas_personer_fnr_daead_encrypted() -> pd.DataFrame: | ||
JSON_FILE = "tests/data/personer_pseudonymized_default_encryption.json" | ||
return pd.read_json( | ||
JSON_FILE, | ||
dtype={ | ||
"fnr": str, | ||
"fornavn": str, | ||
"etternavn": str, | ||
"kjonn": str, | ||
"fodselsdato": str, | ||
}, | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def single_field_response() -> MagicMock: | ||
mock_response = MagicMock() | ||
mock_response.status_code = 200 | ||
mock_response.content = b'{"data": ["Donald","Mikke","Anton"], "datadoc_metadata": {"pseudo_variables": []}, "metrics": [], "logs": []}' | ||
return mock_response |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
fnr,fornavn,etternavn,kjonn,fodselsdato | ||
AQ24fCDk0CgMxRkmKt4ok4S/Ora4E06co27zSpHVog==,Donald,Duck,M,020995 | ||
AQ24fCDk02LuH0Bob3QmvjG0LG9UXv54mcGjjzrf+g==,Mikke,Mus,M,060970 | ||
AQ24fCDZGzjjbKI2B9s0FOsEXSP33OrssHQXonYVcr8=,Anton,Duck,M,180999 | ||
AWIRfKLSNfR0ID+wBzogEcUT7JQPayk7Gosij6SXr8s=,Donald,Duck,M,020995 | ||
AWIRfKKLagk0LqYCKpiC4xfPkHqIWGVfc3wg5gUwRNE=,Mikke,Mus,M,060970 | ||
AWIRfKIzL1T9iZqt+pLjNbHMsLa0aKSszsRrLiLSAAg=,Anton,Duck,M,180999 |
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 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 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.