-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Honestpuck/Honestpuck-documentation_Categ…
…ories Honestpuck documentation categories
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from typing import Optional | ||
|
||
from pydantic import Extra | ||
|
||
from .. import BaseModel | ||
from . import ClassicApiModel | ||
|
||
_XML_ARRAY_ITEM_NAMES = {} | ||
|
||
|
||
class ClassicCategoryItem(BaseModel, extra=Extra.allow): | ||
"""Represents a category record returned by the | ||
:meth:`~jamf_pro_sdk.clients.classic_api.ClassicApi.list_categories` operation. | ||
""" | ||
|
||
id: Optional[int] | ||
name: Optional[str] | ||
priority: Optional[int] | ||
|
||
|
||
class ClassicCategory(ClassicApiModel): | ||
"""Represents a category record returned by the | ||
:meth:`~jamf_pro_sdk.clients.classic_api.ClassicApi.get_category_by_id` operation. | ||
When exporting to XML for a ``POST``/``PUT`` operation, the SDK by default will only | ||
include ``name``, and ``priority. To bypass this | ||
behavior export the model using :meth:`~jamf_pro_sdk.models.classic.ClassicApiModel.xml` before | ||
pasting to the API operation. | ||
""" | ||
|
||
_xml_root_name = "category" | ||
_xml_array_item_names = _XML_ARRAY_ITEM_NAMES | ||
_xml_write_fields = {"name", "priority"} | ||
|
||
id: Optional[int] | ||
name: Optional[str] | ||
priority: Optional[int] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import json | ||
|
||
from deepdiff import DeepDiff | ||
from src.jamf_pro_sdk.models.classic.categories import ClassicCategory | ||
|
||
CATEGORY_JSON = {"category": {"id": 1, "name": "Test Category", "priority": 1}} | ||
|
||
|
||
def test_category_model_parsings(): | ||
"""Verify select attributes across the ComputerGroup model.""" | ||
category = ClassicCategory(**CATEGORY_JSON["category"]) | ||
|
||
assert category is not None # mypy | ||
assert category.name == "Test Category" | ||
assert category.priority == 1 | ||
assert category.id == 1 | ||
|
||
|
||
def test_category_model_json_output_matches_input(): | ||
category = ClassicCategory(**CATEGORY_JSON["category"]) | ||
serialized_output = json.loads(category.json(exclude_none=True)) | ||
|
||
diff = DeepDiff(CATEGORY_JSON["category"], serialized_output, ignore_order=True) | ||
|
||
assert not diff |