Skip to content

Commit

Permalink
V2.0.1 Make category OnlyList as per spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvcc committed Sep 26, 2024
1 parent a75867b commit 5d03c8c
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 4 deletions.
167 changes: 165 additions & 2 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pre-commit = "^2.12.0"
ruff = "*"
rich = "*"
pytest = "^7.4.0"
requests = "^2.32.3"

[tool.pytest.ini_options]
addopts = "--color=yes"
Expand Down
2 changes: 1 addition & 1 deletion rss_parser/models/rss/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class OptionalChannelElementsMixin(XMLBaseModel):
last_build_date: Optional[Tag[DateTimeOrStr]] = None # Sat, 07 Sep 2002 09:42:31 GMT
"The last time the content of the channel changed."

category: Optional[Tag[str]] = None # Newspapers
categories: Optional[OnlyList[Tag[str]]] = pydantic.Field(alias="category", default=[])
"Specify one or more categories that the channel belongs to. Follows the same rules as the <item.py>-level " "category element." # noqa

generator: Optional[Tag[str]] = None # MightyInHouse Content System v2.3
Expand Down
2 changes: 1 addition & 1 deletion rss_parser/models/rss/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OptionalItemElementsMixin(XMLBaseModel):
author: Optional[Tag[str]] = None
"Email address of the author of the item."

category: Optional[Tag[str]] = None
categories: Optional[OnlyList[Tag[str]]] = pydantic.Field(alias="category", default=[])
"Includes the item in one or more categories."

comments: Optional[Tag[str]] = None
Expand Down
Binary file modified tests/samples/apology_line/result.pkl
Binary file not shown.
Binary file modified tests/samples/github-49/result.pkl
Binary file not shown.
Binary file modified tests/samples/rss_2/result.pkl
Binary file not shown.
Binary file modified tests/samples/rss_2_no_category_attr/result.pkl
Binary file not shown.
Binary file modified tests/samples/rss_2_with_1_item/result.pkl
Binary file not shown.
1 change: 1 addition & 0 deletions tests/test_parsing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import pickle
from typing import Type

import pytest
Expand Down

0 comments on commit 5d03c8c

Please sign in to comment.