-
Notifications
You must be signed in to change notification settings - Fork 3
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
d3e9470
commit b798fbb
Showing
1 changed file
with
27 additions
and
0 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,27 @@ | ||
|
||
from NIPTool.server import create_app | ||
from NIPTool.server.utils import get_last_batches | ||
from NIPTool.adapter.plugin import NiptAdapter | ||
from datetime import datetime | ||
|
||
|
||
app = create_app(test= True) | ||
|
||
|
||
def test_get_last_batches(database): | ||
app.db = database | ||
app.adapter = NiptAdapter(database.client, db_name = database.name) | ||
|
||
# GIVEN a database with four batch documents: | ||
batch1 = {"_id":"201860", "SequencingDate":"2022-03-10"} | ||
batch2 = {"_id":"201862", "SequencingDate":"2022-02-10"} | ||
batch3 = {"_id":"201830", "SequencingDate":"2022-02-09"} | ||
batch4 = {"_id":"101830", "SequencingDate":"2021-03-10"} | ||
|
||
database.batch.insert_many([batch4, batch1, batch3, batch2]) | ||
|
||
# WHEN running get_last_batches with nr=2 | ||
results = get_last_batches(adapter=app.adapter, nr=2) | ||
|
||
# THEN the results should contain the two batches with the latest SequencingDate | ||
assert results == [batch1, batch2] |