Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4baf128
commit a35859a
Showing
3 changed files
with
31 additions
and
165 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from NIPTool.build.document import build_batch, build_sample | ||
from NIPTool.models.constants import BATCH_KEYS, SAMPLE_KEYS | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("sample_key", SAMPLE_KEYS) | ||
@pytest.mark.parametrize("value", [124, 2.08, "randomstring"]) | ||
def test_build_sample(sample_key, value): | ||
# GIVEN a sample_data dict with requiered key 'SampleID' and a sample_key with some value and a non sample_key | ||
|
||
sample_data = {"SampleID": "someid", sample_key: value, "other_key": 8983} | ||
|
||
# WHEN building a mongo sample | ||
mongo_sample = build_sample(sample_data=sample_data) | ||
|
||
# THEN the SampleID will be _id and the non sample key will be removed | ||
assert mongo_sample == {"_id": "someid", sample_key: value} | ||
|
||
|
||
@pytest.mark.parametrize("batch_key", BATCH_KEYS) | ||
@pytest.mark.parametrize("value", [124, 2.08, "randomstring"]) | ||
def test_build_batch(batch_key, value): | ||
# GIVEN a batch_data dict a batch_key with some value and a non batch_key | ||
|
||
batch_data = {batch_key: value, "other_key": 8983} | ||
|
||
# WHEN building a mongo batch | ||
mongo_batch = build_batch(batch_data=batch_data) | ||
|
||
# THEN the non batch_key will be removed | ||
assert mongo_batch == {batch_key: value} |
This file was deleted.
Oops, something went wrong.