-
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.
sites with model, test, doco, and additions to classic_api.py
- Loading branch information
1 parent
447f2a2
commit ef02271
Showing
4 changed files
with
164 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
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,31 @@ | ||
from typing import Optional | ||
|
||
from pydantic import Extra | ||
|
||
from .. import BaseModel | ||
from . import ClassicApiModel | ||
|
||
_XML_ARRAY_ITEM_NAMES = {} | ||
|
||
|
||
class ClassicSiteItem(BaseModel, extra=Extra.allow): | ||
"""Represents a site record returned by the | ||
:meth:`~jamf_pro_sdk.clients.classic_api.ClassicApi.list_sites` operation. | ||
""" | ||
|
||
id: Optional[int] | ||
name: Optional[str] | ||
|
||
|
||
class ClassicSite(ClassicApiModel): | ||
"""Represents a site record returned by the | ||
:meth:`~jamf_pro_sdk.clients.classic_api.ClassicApi.get_site_by_id` operation. | ||
Note that due to the simplicity of the model this information is available in the list. | ||
""" | ||
|
||
_xml_root_name = "site" | ||
_xml_array_item_names = _XML_ARRAY_ITEM_NAMES | ||
_xml_write_fields = {"name"} | ||
|
||
id: Optional[int] | ||
name: Optional[str] |
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,24 @@ | ||
import json | ||
|
||
from deepdiff import DeepDiff | ||
from src.jamf_pro_sdk.models.classic.sites import ClassicSite | ||
|
||
SITE_JSON = {"site": {"id": 1, "name": "Test Site"}} | ||
|
||
|
||
def test_site_model_parsings(): | ||
"""Verify select attributes across the Site model.""" | ||
site = ClassicSite(**SITE_JSON["site"]) | ||
|
||
assert site is not None # mypy | ||
assert site.name == "Test Site" | ||
assert site.id == 1 | ||
|
||
|
||
def test_site_model_json_output_matches_input(): | ||
site = ClassicSite(**SITE_JSON["site"]) | ||
serialized_output = json.loads(site.json(exclude_none=True)) | ||
|
||
diff = DeepDiff(SITE_JSON["site"], serialized_output, ignore_order=True) | ||
|
||
assert not diff |