Skip to content

Commit

Permalink
fixup! Refactor parse_modular, docstrings and small type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-psb committed Dec 4, 2023
1 parent 708a7cf commit 6cb4740
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions pulp_rpm/tests/unit/test_modulemd.py
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"

0 comments on commit 6cb4740

Please sign in to comment.