-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Refactor
parse_modular
, docstrings and small type annotations
- Loading branch information
Showing
1 changed file
with
25 additions
and
16 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 |
---|---|---|
@@ -1,23 +1,32 @@ | ||
from pathlib import Path | ||
import os | ||
|
||
from pulp_rpm.app.modulemd import parse_modular | ||
|
||
|
||
def test_parse_modular_preserves_literal_unquoted_values_3285(): | ||
def test_parse_modular_preserves_literal_unquoted_values_3285(tmp_path): | ||
"""Unquoted yaml numbers with trailing/leading zeros are preserved""" | ||
|
||
file_path = str(Path("pulp_rpm/tests/unit/modulemd.yaml").absolute()) | ||
all, default, obsoletes = parse_modular(file_path) | ||
|
||
# check the first two entries, a unquoted and a quoted one. | ||
assert all[0]["name"] == "kangaroo" | ||
assert all[0]["stream"] == "1.10" # unquoted in yaml, shoul not be 1.1 | ||
assert all[0]["version"] == "20180730223407" | ||
assert all[0]["context"] == "deadbeef" | ||
assert all[0]["arch"] == "noarch" | ||
|
||
assert all[1]["name"] == "kangaroo" | ||
assert all[1]["stream"] == "1.10" | ||
assert all[1]["version"] == "20180704111719" | ||
assert all[1]["context"] == "deadbeef" | ||
assert all[1]["arch"] == "noarch" | ||
# copy sample file to tmp_path, so it have proper test permissions | ||
os.chdir(tmp_path) | ||
sample = Path("/src/pulp_rpm/pulp_rpm/tests/unit/modulemd.yaml") | ||
test_file = Path("modulemd.yaml") | ||
test_file.write_bytes(sample.read_bytes()) | ||
|
||
all, default, obsoletes = parse_modular(str(test_file.absolute())) | ||
|
||
# check the first two entries | ||
kangoroo1 = all[0] # unquoted | ||
kangoroo2 = all[1] # quoted | ||
|
||
assert kangoroo1["name"] == "kangaroo" | ||
assert kangoroo1["stream"] == "1.10" # should not be 1.1 | ||
assert kangoroo1["version"] == "20180730223407" | ||
assert kangoroo1["context"] == "deadbeef" | ||
assert kangoroo1["arch"] == "noarch" | ||
|
||
assert kangoroo2["name"] == "kangaroo" | ||
assert kangoroo2["stream"] == "1.10" | ||
assert kangoroo2["version"] == "20180704111719" | ||
assert kangoroo2["context"] == "deadbeef" | ||
assert kangoroo2["arch"] == "noarch" |