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 6cb4740 commit d34ad7e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 324 deletions.
317 changes: 0 additions & 317 deletions pulp_rpm/tests/unit/modulemd.yaml

This file was deleted.

65 changes: 58 additions & 7 deletions pulp_rpm/tests/unit/test_modulemd.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,70 @@
from pathlib import Path
from pulp_rpm.app.modulemd import parse_modular
import os

from pulp_rpm.app.modulemd import parse_modular
sample_file_data = """
---
document: modulemd
version: 2
data:
name: kangaroo
stream: 1.10
version: 20180730223407
context: deadbeef
arch: noarch
summary: Kangaroo 0.3 module
description: >-
A module for the kangaroo 0.3 package
license:
module:
- MIT
content:
- MIT
profiles:
default:
rpms:
- kangaroo
artifacts:
rpms:
- kangaroo-0:0.3-1.noarch
...
---
document: modulemd
version: 2
data:
name: kangaroo
stream: "1.10"
version: 20180704111719
context: deadbeef
arch: noarch
summary: Kangaroo 0.2 module
description: >-
A module for the kangaroo 0.2 package
license:
module:
- MIT
content:
- MIT
profiles:
default:
rpms:
- kangaroo
artifacts:
rpms:
- kangaroo-0:0.2-1.noarch
...
"""


def test_parse_modular_preserves_literal_unquoted_values_3285(tmp_path):
"""Unquoted yaml numbers with trailing/leading zeros are preserved"""

# copy sample file to tmp_path, so it have proper test permissions
# write data to test_file
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())
file_name = "modulemd.yaml"
with open(file_name, "w") as file:
file.write(sample_file_data)

all, default, obsoletes = parse_modular(str(test_file.absolute()))
all, default, obsoletes = parse_modular(str(file_name))

# check the first two entries
kangoroo1 = all[0] # unquoted
Expand Down

0 comments on commit d34ad7e

Please sign in to comment.