Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Add affects_rhel() check
Browse files Browse the repository at this point in the history
  • Loading branch information
major committed Oct 21, 2024
1 parent 40ed03c commit 40543fb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from langchain_core.documents import Document

from textprep.errata import (
affects_rhel,
clean_bugzillas,
clean_description,
clean_solution,
Expand Down Expand Up @@ -170,3 +171,30 @@ def test_parse_functional(errata_doc_path):
- BZ 2044863 found at https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2044863"""
assert result == expected


def test_affects_rhel(tmp_path):
content = """+++
portal_product_names=["Red Hat Enterprise Linux Server - Extended Life Cycle Support","Red Hat Enterprise Linux for x86_64 - Update Services for SAP Solutions","Red Hat Enterprise Linux for x86_64 - Extended Update Support","Red Hat Enterprise Linux Desktop","Red Hat Enterprise Linux Server - AUS","Red Hat Enterprise Linux EUS Compute Node","Red Hat Enterprise Linux Server - TUS","Red Hat Enterprise Linux Server","Red Hat Enterprise Linux Workstation","Red Hat Enterprise Linux Server from RHUI","Red Hat Enterprise Linux for Scientific Computing"]
+++
# Heading
Content.
"""
d = tmp_path / "sub"
d.mkdir()
p = d / "errata.md"
p.write_text(content, encoding="utf-8")
assert affects_rhel(p)

content = """+++
portal_product_names=["Red Hat OpenShift Enterprise Infrastructure","Red Hat OpenShift Enterprise Application Node","Red Hat OpenShift Enterprise JBoss EAP add-on","Red Hat OpenShift Enterprise Client Tools"]
+++
# Heading
Content.
"""
p.write_text(content, encoding="utf-8")
assert not affects_rhel(p)
7 changes: 7 additions & 0 deletions textprep/errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ def get_affected_products(product_keys: list, product_detail: list) -> str:
return "This errata affects the following products:\n\n" + product_text


def affects_rhel(path: str) -> bool:
"""Check if the errata affects RHEL."""
errata_doc = load_errata(path)
affected_products = errata_doc["frontmatter"]["portal_product_names"]
return any("Red Hat Enterprise Linux" in x for x in affected_products)


def parse(path: str) -> str:
"""Parse an errata document into a clean format."""
errata_doc = load_errata(path)
Expand Down

0 comments on commit 40543fb

Please sign in to comment.