-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update conversion script and add test
Signed-off-by: Rodolfo Olivieri <[email protected]>
- Loading branch information
Showing
3 changed files
with
65 additions
and
4 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
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,56 @@ | ||
import json | ||
from mock import patch | ||
import pytest | ||
from scripts.conversion_script import parse_migration_results | ||
|
||
|
||
def test_no_migration_results(tmpdir): | ||
migration_result_file = tmpdir.join("migration_result") | ||
with patch( | ||
"scripts.conversion_script.C2R_MIGRATION_RESULTS_FILE", | ||
str(migration_result_file), | ||
): | ||
assert not parse_migration_results() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("content", "expected"), | ||
( | ||
( | ||
{"activities": [{"success": True}]}, | ||
True, | ||
), | ||
( | ||
{"activities": [{"success": False}]}, | ||
False, | ||
), | ||
( | ||
{"activities": [{"success": False}, {"success": True}]}, | ||
True, | ||
), | ||
( | ||
{"activities": [{"success": True}, {"success": False}]}, | ||
False, | ||
), | ||
( | ||
{"activities": [{}]}, | ||
False, | ||
), | ||
( | ||
{}, | ||
False, | ||
), | ||
( | ||
None, | ||
False, | ||
), | ||
), | ||
) | ||
def test_migration_results_content(content, expected, tmpdir): | ||
migration_result_file = tmpdir.join("migration_result") | ||
migration_result_file.write(json.dumps(content, indent=4)) | ||
with patch( | ||
"scripts.conversion_script.C2R_MIGRATION_RESULTS_FILE", | ||
str(migration_result_file), | ||
): | ||
assert parse_migration_results() == expected |