-
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.
fix: Adds get_jobs_replaced() to decoder
- Loading branch information
Alan Christie
committed
Mar 17, 2023
1 parent
ffcceb2
commit 1e0731f
Showing
2 changed files
with
61 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
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,40 @@ | ||
# Tests for the decoder's get_jobs_replaced() function. | ||
from typing import Dict | ||
|
||
import pytest | ||
|
||
pytestmark = pytest.mark.unit | ||
|
||
from decoder import decoder | ||
|
||
|
||
def test_get_jobs_replaced_when_none(): | ||
# Arrange | ||
job_definition: Dict = {} | ||
|
||
# Act | ||
replaced = decoder.get_jobs_replaced(job_definition) | ||
|
||
# Assert | ||
assert replaced is None | ||
|
||
|
||
def test_get_jobs_replaced(): | ||
# Arrange | ||
collection: str = "collection-x" | ||
job: str = "job-x" | ||
job_definition: Dict = { | ||
"replaces": [ | ||
{"collection": "c-1", "job": "j-1"}, | ||
{"collection": "c-1", "job": "j-2"}, | ||
] | ||
} | ||
|
||
# Act | ||
replaced = decoder.get_jobs_replaced(job_definition) | ||
|
||
# Assert | ||
assert replaced | ||
assert len(replaced) == 2 | ||
assert "c-1|j-1" in replaced | ||
assert "c-1|j-2" in replaced |