Skip to content

Commit

Permalink
Add TextContent Class
Browse files Browse the repository at this point in the history
  • Loading branch information
dahbar committed Dec 18, 2023
1 parent 2622e9c commit 30b161a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
1 change: 0 additions & 1 deletion polarion_rest_api_client/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from polarion_rest_api_client import data_models as dm

WorkItemType = t.TypeVar("WorkItemType", bound=dm.WorkItem)
DocumentType = t.TypeVar("DocumentType", bound=dm.Document)


class DefaultFields:
Expand Down
8 changes: 4 additions & 4 deletions polarion_rest_api_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,10 @@ def get_document(
module_name=unset_str_builder(attributes.module_name),
type=unset_str_builder(attributes.type),
status=unset_str_builder(attributes.status),
home_page_content={
"type": attributes.home_page_content.type,
"value": attributes.home_page_content.value,
}
home_page_content=dm.TextContent(
type=attributes.home_page_content.type,
value=attributes.home_page_content.value,
)
if not isinstance(
attributes.home_page_content, oa_types.Unset
)
Expand Down
17 changes: 15 additions & 2 deletions polarion_rest_api_client/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Document(BaseItem):

module_folder: str | None = None
module_name: str | None = None
home_page_content: dict | None = None
home_page_content: TextContent | None = None

def __init__(
self,
Expand All @@ -156,9 +156,22 @@ def __init__(
module_name: str | None = None,
type: str | None = None,
status: str | None = None,
home_page_content: dict | None = None,
home_page_content: TextContent | None = None,
):
super().__init__(id, type, status)
self.module_folder = module_folder
self.module_name = module_name
self.home_page_content = home_page_content


class TextContent:
type: str | None = None
value: str | None = None

def __init__(
self,
type: str | None = None,
value: str | None = None,
):
self.type = type
self.value = value
4 changes: 3 additions & 1 deletion tests/test_client_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ def test_get_document_with_all_fields(
"MyDocumentName",
"standardSpecification",
"open",
{"type": "text/html", "value": "<h1>My text value</h1>"},
polarion_api.data_models.TextContent(
type="text/html", value="<h1>My text value</h1>"
),
)

0 comments on commit 30b161a

Please sign in to comment.