mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2025-12-06 06:26:51 +00:00
CP-2063 - test examples
This commit is contained in:
parent
bca6dc2250
commit
0d0887e91a
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
Manage credentials for transaction tests using the Credentials API. The following permissions are required to access Credentials API endpoints: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. * `View sensitive data in web transaction scripts` to view the encrypted value property of credentials. * `Settings Tests Create Transaction (Tx) Tests` to create credentials. For more information about credentials, see [Working With Secure Credentials](https://docs.thousandeyes.com/product-documentation/browser-synthetics/transaction-tests/getting-started/working-with-secure-credentials).
|
Manage credentials for transaction tests using the Credentials API. The following permissions are required to access Credentials API endpoints: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. * `View sensitive data in web transaction scripts` to view the encrypted value property of credentials. * `Settings Tests Create Transaction (Tx) Tests` to create credentials. For more information about credentials, see [Working With Secure Credentials](https://docs.thousandeyes.com/product-documentation/browser-synthetics/transaction-tests/getting-started/working-with-secure-credentials).
|
||||||
|
|
||||||
The version of the OpenAPI document: 7.0.0
|
The version of the OpenAPI document: 7.0.4
|
||||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
@ -19,7 +19,7 @@ import json
|
|||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||||
from typing import Any, ClassVar, Dict, List, Optional
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
from credentials.models.self_links_links import SelfLinksLinks
|
from credentials.models.self_links import SelfLinks
|
||||||
from typing import Optional, Set
|
from typing import Optional, Set
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class Credential(BaseModel):
|
|||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
id: Optional[StrictStr] = Field(default=None, description="Unique ID of the credential.")
|
id: Optional[StrictStr] = Field(default=None, description="Unique ID of the credential.")
|
||||||
name: Optional[StrictStr] = Field(default=None, description="The name of the credential.")
|
name: Optional[StrictStr] = Field(default=None, description="The name of the credential.")
|
||||||
links: Optional[SelfLinksLinks] = Field(default=None, alias="_links")
|
links: Optional[SelfLinks] = Field(default=None, alias="_links")
|
||||||
value: Optional[StrictStr] = Field(default=None, description="The value of the credential that will be encrypted.")
|
value: Optional[StrictStr] = Field(default=None, description="The value of the credential that will be encrypted.")
|
||||||
__properties: ClassVar[List[str]] = ["id", "name", "_links", "value"]
|
__properties: ClassVar[List[str]] = ["id", "name", "_links", "value"]
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ class Credential(BaseModel):
|
|||||||
populate_by_name=True,
|
populate_by_name=True,
|
||||||
validate_assignment=True,
|
validate_assignment=True,
|
||||||
protected_namespaces=(),
|
protected_namespaces=(),
|
||||||
|
extra="allow",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ class Credential(BaseModel):
|
|||||||
def to_json(self) -> str:
|
def to_json(self) -> str:
|
||||||
"""Returns the JSON representation of the model using alias"""
|
"""Returns the JSON representation of the model using alias"""
|
||||||
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
return json.dumps(self.to_dict())
|
return self.model_dump_json(by_alias=True, exclude_unset=True, exclude_none=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||||
@ -89,7 +90,7 @@ class Credential(BaseModel):
|
|||||||
_obj = cls.model_validate({
|
_obj = cls.model_validate({
|
||||||
"id": obj.get("id"),
|
"id": obj.get("id"),
|
||||||
"name": obj.get("name"),
|
"name": obj.get("name"),
|
||||||
"_links": SelfLinksLinks.from_dict(obj["_links"]) if obj.get("_links") is not None else None,
|
"_links": SelfLinks.from_dict(obj["_links"]) if obj.get("_links") is not None else None,
|
||||||
"value": obj.get("value")
|
"value": obj.get("value")
|
||||||
})
|
})
|
||||||
return _obj
|
return _obj
|
||||||
|
|||||||
@ -16,8 +16,8 @@ import json
|
|||||||
import unittest
|
import unittest
|
||||||
import credentials.models
|
import credentials.models
|
||||||
|
|
||||||
|
from .test_utils import assert_constructed_model_matches_example_json
|
||||||
from credentials.api.credentials_api import CredentialsApi
|
from credentials.api.credentials_api import CredentialsApi
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
|
|
||||||
class TestCredentialsApi(unittest.TestCase):
|
class TestCredentialsApi(unittest.TestCase):
|
||||||
@ -38,20 +38,13 @@ class TestCredentialsApi(unittest.TestCase):
|
|||||||
}"""
|
}"""
|
||||||
|
|
||||||
request_loaded_json = json.loads(request_body_json)
|
request_loaded_json = json.loads(request_body_json)
|
||||||
request_from_constructor = credentials.models.CredentialRequest(**request_loaded_json)
|
|
||||||
self.recursive_assert_no_extra_fields(request_from_constructor)
|
|
||||||
|
|
||||||
request_from_json = credentials.models.CredentialRequest.from_json(request_body_json)
|
request_from_json = credentials.models.CredentialRequest.from_json(request_body_json)
|
||||||
self.assertIsNotNone(request_from_json)
|
assert_constructed_model_matches_example_json(request_from_json, request_loaded_json)
|
||||||
self.assertCountEqual(request_from_constructor.model_fields_set,
|
|
||||||
request_from_json.model_fields_set,
|
|
||||||
"Request model from constructor fields do not match model from json fields")
|
|
||||||
|
|
||||||
response_body_json = """
|
response_body_json = """
|
||||||
{
|
{
|
||||||
"_links" : {
|
"_links" : {
|
||||||
"self" : {
|
"self" : {
|
||||||
"extra" : "unexpected",
|
|
||||||
"hreflang" : "hreflang",
|
"hreflang" : "hreflang",
|
||||||
"templated" : true,
|
"templated" : true,
|
||||||
"profile" : "profile",
|
"profile" : "profile",
|
||||||
@ -67,14 +60,8 @@ class TestCredentialsApi(unittest.TestCase):
|
|||||||
}"""
|
}"""
|
||||||
|
|
||||||
response_loaded_json = json.loads(response_body_json)
|
response_loaded_json = json.loads(response_body_json)
|
||||||
response_from_constructor = credentials.models.CredentialWithoutValue(**response_loaded_json)
|
|
||||||
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
||||||
|
|
||||||
response_from_json = credentials.models.CredentialWithoutValue.from_json(response_body_json)
|
response_from_json = credentials.models.CredentialWithoutValue.from_json(response_body_json)
|
||||||
self.assertIsNotNone(response_from_json)
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
||||||
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
||||||
response_from_json.model_fields_set,
|
|
||||||
"Response model from constructor fields do not match model from json fields")
|
|
||||||
|
|
||||||
def test_delete_transaction_tests_credential_models_validation(self) -> None:
|
def test_delete_transaction_tests_credential_models_validation(self) -> None:
|
||||||
"""Test case for delete_transaction_tests_credential request a nd response models"""
|
"""Test case for delete_transaction_tests_credential request a nd response models"""
|
||||||
@ -103,14 +90,8 @@ class TestCredentialsApi(unittest.TestCase):
|
|||||||
}"""
|
}"""
|
||||||
|
|
||||||
response_loaded_json = json.loads(response_body_json)
|
response_loaded_json = json.loads(response_body_json)
|
||||||
response_from_constructor = credentials.models.Credential(**response_loaded_json)
|
|
||||||
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
||||||
|
|
||||||
response_from_json = credentials.models.Credential.from_json(response_body_json)
|
response_from_json = credentials.models.Credential.from_json(response_body_json)
|
||||||
self.assertIsNotNone(response_from_json)
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
||||||
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
||||||
response_from_json.model_fields_set,
|
|
||||||
"Response model from constructor fields do not match model from json fields")
|
|
||||||
|
|
||||||
def test_get_transaction_tests_credentials_list_models_validation(self) -> None:
|
def test_get_transaction_tests_credentials_list_models_validation(self) -> None:
|
||||||
"""Test case for get_transaction_tests_credentials_list request a nd response models"""
|
"""Test case for get_transaction_tests_credentials_list request a nd response models"""
|
||||||
@ -165,14 +146,8 @@ class TestCredentialsApi(unittest.TestCase):
|
|||||||
}"""
|
}"""
|
||||||
|
|
||||||
response_loaded_json = json.loads(response_body_json)
|
response_loaded_json = json.loads(response_body_json)
|
||||||
response_from_constructor = credentials.models.Credentials(**response_loaded_json)
|
|
||||||
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
||||||
|
|
||||||
response_from_json = credentials.models.Credentials.from_json(response_body_json)
|
response_from_json = credentials.models.Credentials.from_json(response_body_json)
|
||||||
self.assertIsNotNone(response_from_json)
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
||||||
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
||||||
response_from_json.model_fields_set,
|
|
||||||
"Response model from constructor fields do not match model from json fields")
|
|
||||||
|
|
||||||
def test_update_transaction_tests_credential_models_validation(self) -> None:
|
def test_update_transaction_tests_credential_models_validation(self) -> None:
|
||||||
"""Test case for update_transaction_tests_credential request a nd response models"""
|
"""Test case for update_transaction_tests_credential request a nd response models"""
|
||||||
@ -183,14 +158,8 @@ class TestCredentialsApi(unittest.TestCase):
|
|||||||
}"""
|
}"""
|
||||||
|
|
||||||
request_loaded_json = json.loads(request_body_json)
|
request_loaded_json = json.loads(request_body_json)
|
||||||
request_from_constructor = credentials.models.CredentialRequest(**request_loaded_json)
|
|
||||||
self.recursive_assert_no_extra_fields(request_from_constructor)
|
|
||||||
|
|
||||||
request_from_json = credentials.models.CredentialRequest.from_json(request_body_json)
|
request_from_json = credentials.models.CredentialRequest.from_json(request_body_json)
|
||||||
self.assertIsNotNone(request_from_json)
|
assert_constructed_model_matches_example_json(request_from_json, request_loaded_json)
|
||||||
self.assertCountEqual(request_from_constructor.model_fields_set,
|
|
||||||
request_from_json.model_fields_set,
|
|
||||||
"Request model from constructor fields do not match model from json fields")
|
|
||||||
|
|
||||||
response_body_json = """
|
response_body_json = """
|
||||||
{
|
{
|
||||||
@ -211,26 +180,8 @@ class TestCredentialsApi(unittest.TestCase):
|
|||||||
}"""
|
}"""
|
||||||
|
|
||||||
response_loaded_json = json.loads(response_body_json)
|
response_loaded_json = json.loads(response_body_json)
|
||||||
response_from_constructor = credentials.models.CredentialWithoutValue(**response_loaded_json)
|
|
||||||
self.recursive_assert_no_extra_fields(response_from_constructor)
|
|
||||||
|
|
||||||
response_from_json = credentials.models.CredentialWithoutValue.from_json(response_body_json)
|
response_from_json = credentials.models.CredentialWithoutValue.from_json(response_body_json)
|
||||||
self.assertIsNotNone(response_from_json)
|
assert_constructed_model_matches_example_json(response_from_json, response_loaded_json)
|
||||||
self.assertCountEqual(response_from_constructor.model_fields_set,
|
|
||||||
response_from_json.model_fields_set,
|
|
||||||
"Response model from constructor fields do not match model from json fields")
|
|
||||||
|
|
||||||
def recursive_assert_no_extra_fields(self, model: BaseModel):
|
|
||||||
self.assertIsNotNone(model)
|
|
||||||
self.assertGreater(model.model_fields_set.__len__(), 0)
|
|
||||||
self.assertEquals(model.model_extra.__len__(), 0,
|
|
||||||
'model {0}.{1} has unmapped extra fields {2}'
|
|
||||||
.format(model.__class__.__module__, model.__class__.__name__,
|
|
||||||
model.model_extra))
|
|
||||||
for f in model.model_fields_set:
|
|
||||||
field = model.__dict__.get(f)
|
|
||||||
if isinstance(field, BaseModel):
|
|
||||||
self.recursive_assert_no_extra_fields(field)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
16
credentials/test/test_utils.py
Normal file
16
credentials/test/test_utils.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
import json
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict):
|
||||||
|
test_case = unittest.TestCase()
|
||||||
|
test_case.maxDiff = None
|
||||||
|
test_case.assertIsNotNone(model)
|
||||||
|
constructed_json = json.loads(model.to_json())
|
||||||
|
sorted_loaded_json = json.dumps(loaded_json, sort_keys=True)
|
||||||
|
sorted_constructed_json = json.dumps(constructed_json, sort_keys=True)
|
||||||
|
test_case.assertEqual(sorted_loaded_json, sorted_constructed_json)
|
||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
Manage ThousandEyes Dashboards.
|
Manage ThousandEyes Dashboards.
|
||||||
|
|
||||||
The version of the OpenAPI document: 7.0.0
|
The version of the OpenAPI document: 7.0.4
|
||||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
@ -21,7 +21,7 @@ from datetime import datetime
|
|||||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
||||||
from typing import Any, ClassVar, Dict, List, Optional
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
from dashboards.models.api_widget import ApiWidget
|
from dashboards.models.api_widget import ApiWidget
|
||||||
from dashboards.models.dashboard_links_links import DashboardLinksLinks
|
from dashboards.models.dashboard_links import DashboardLinks
|
||||||
from dashboards.models.default_timespan import DefaultTimespan
|
from dashboards.models.default_timespan import DefaultTimespan
|
||||||
from typing import Optional, Set
|
from typing import Optional, Set
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
@ -38,7 +38,6 @@ class ApiDashboard(BaseModel):
|
|||||||
global_override: Optional[StrictBool] = Field(default=None, description="When set to `true`, the defaultTimespan is used and overrides the widget's timespan. If set to `false`, the the widget's timespan is used.", alias="globalOverride")
|
global_override: Optional[StrictBool] = Field(default=None, description="When set to `true`, the defaultTimespan is used and overrides the widget's timespan. If set to `false`, the the widget's timespan is used.", alias="globalOverride")
|
||||||
migrated_report: Optional[StrictBool] = Field(default=None, description="True if this dashboard was previously a report.", alias="migratedReport")
|
migrated_report: Optional[StrictBool] = Field(default=None, description="True if this dashboard was previously a report.", alias="migratedReport")
|
||||||
api_link: Optional[List[Dict[str, Any]]] = Field(default=None, description="A links array containing the self and the snapshots links.", alias="apiLink")
|
api_link: Optional[List[Dict[str, Any]]] = Field(default=None, description="A links array containing the self and the snapshots links.", alias="apiLink")
|
||||||
links: Optional[DashboardLinksLinks] = Field(default=None, alias="_links")
|
|
||||||
dashboard_id: Optional[StrictStr] = Field(default=None, description="Identifier of a dashboard.", alias="dashboardId")
|
dashboard_id: Optional[StrictStr] = Field(default=None, description="Identifier of a dashboard.", alias="dashboardId")
|
||||||
title: Optional[StrictStr] = Field(default=None, description="Title of a dashboard.")
|
title: Optional[StrictStr] = Field(default=None, description="Title of a dashboard.")
|
||||||
is_built_in: Optional[StrictBool] = Field(default=None, description="Indicates if a dashboard is built-in. True for built-in dashboards, false for user-created dashboards.", alias="isBuiltIn")
|
is_built_in: Optional[StrictBool] = Field(default=None, description="Indicates if a dashboard is built-in. True for built-in dashboards, false for user-created dashboards.", alias="isBuiltIn")
|
||||||
@ -54,12 +53,14 @@ class ApiDashboard(BaseModel):
|
|||||||
default_timespan: Optional[DefaultTimespan] = Field(default=None, alias="defaultTimespan")
|
default_timespan: Optional[DefaultTimespan] = Field(default=None, alias="defaultTimespan")
|
||||||
is_global_override: Optional[StrictBool] = Field(default=None, description="When set to `true`, the defaultTimespan is used and overrides the widget's timespan. If set to `false`, the the widget's timespan is used.", alias="isGlobalOverride")
|
is_global_override: Optional[StrictBool] = Field(default=None, description="When set to `true`, the defaultTimespan is used and overrides the widget's timespan. If set to `false`, the the widget's timespan is used.", alias="isGlobalOverride")
|
||||||
is_migrated_report: Optional[StrictBool] = Field(default=None, description="True if this dashboard was previously a report.", alias="isMigratedReport")
|
is_migrated_report: Optional[StrictBool] = Field(default=None, description="True if this dashboard was previously a report.", alias="isMigratedReport")
|
||||||
__properties: ClassVar[List[str]] = ["globalFilterId", "accountId", "createdBy", "modifiedBy", "modifiedDate", "globalOverride", "migratedReport", "apiLink", "_links", "dashboardId", "title", "isBuiltIn", "aid", "dashboardCreatedBy", "dashboardModifiedBy", "dashboardModifiedDate", "isPrivate", "isDefaultForUser", "isDefaultForAccount", "widgets", "description", "defaultTimespan", "isGlobalOverride", "isMigratedReport"]
|
links: Optional[DashboardLinks] = Field(default=None, alias="_links")
|
||||||
|
__properties: ClassVar[List[str]] = ["globalFilterId", "accountId", "createdBy", "modifiedBy", "modifiedDate", "globalOverride", "migratedReport", "apiLink", "dashboardId", "title", "isBuiltIn", "aid", "dashboardCreatedBy", "dashboardModifiedBy", "dashboardModifiedDate", "isPrivate", "isDefaultForUser", "isDefaultForAccount", "widgets", "description", "defaultTimespan", "isGlobalOverride", "isMigratedReport", "_links"]
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(
|
||||||
populate_by_name=True,
|
populate_by_name=True,
|
||||||
validate_assignment=True,
|
validate_assignment=True,
|
||||||
protected_namespaces=(),
|
protected_namespaces=(),
|
||||||
|
extra="allow",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ class ApiDashboard(BaseModel):
|
|||||||
def to_json(self) -> str:
|
def to_json(self) -> str:
|
||||||
"""Returns the JSON representation of the model using alias"""
|
"""Returns the JSON representation of the model using alias"""
|
||||||
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
return json.dumps(self.to_dict())
|
return self.model_dump_json(by_alias=True, exclude_unset=True, exclude_none=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||||
@ -123,9 +124,6 @@ class ApiDashboard(BaseModel):
|
|||||||
exclude=excluded_fields,
|
exclude=excluded_fields,
|
||||||
exclude_none=True,
|
exclude_none=True,
|
||||||
)
|
)
|
||||||
# override the default output from pydantic by calling `to_dict()` of links
|
|
||||||
if self.links:
|
|
||||||
_dict['_links'] = self.links.to_dict()
|
|
||||||
# override the default output from pydantic by calling `to_dict()` of each item in widgets (list)
|
# override the default output from pydantic by calling `to_dict()` of each item in widgets (list)
|
||||||
_items = []
|
_items = []
|
||||||
if self.widgets:
|
if self.widgets:
|
||||||
@ -136,6 +134,9 @@ class ApiDashboard(BaseModel):
|
|||||||
# override the default output from pydantic by calling `to_dict()` of default_timespan
|
# override the default output from pydantic by calling `to_dict()` of default_timespan
|
||||||
if self.default_timespan:
|
if self.default_timespan:
|
||||||
_dict['defaultTimespan'] = self.default_timespan.to_dict()
|
_dict['defaultTimespan'] = self.default_timespan.to_dict()
|
||||||
|
# override the default output from pydantic by calling `to_dict()` of links
|
||||||
|
if self.links:
|
||||||
|
_dict['_links'] = self.links.to_dict()
|
||||||
return _dict
|
return _dict
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -156,7 +157,6 @@ class ApiDashboard(BaseModel):
|
|||||||
"globalOverride": obj.get("globalOverride"),
|
"globalOverride": obj.get("globalOverride"),
|
||||||
"migratedReport": obj.get("migratedReport"),
|
"migratedReport": obj.get("migratedReport"),
|
||||||
"apiLink": obj.get("apiLink"),
|
"apiLink": obj.get("apiLink"),
|
||||||
"_links": DashboardLinksLinks.from_dict(obj["_links"]) if obj.get("_links") is not None else None,
|
|
||||||
"dashboardId": obj.get("dashboardId"),
|
"dashboardId": obj.get("dashboardId"),
|
||||||
"title": obj.get("title"),
|
"title": obj.get("title"),
|
||||||
"isBuiltIn": obj.get("isBuiltIn"),
|
"isBuiltIn": obj.get("isBuiltIn"),
|
||||||
@ -171,7 +171,8 @@ class ApiDashboard(BaseModel):
|
|||||||
"description": obj.get("description"),
|
"description": obj.get("description"),
|
||||||
"defaultTimespan": DefaultTimespan.from_dict(obj["defaultTimespan"]) if obj.get("defaultTimespan") is not None else None,
|
"defaultTimespan": DefaultTimespan.from_dict(obj["defaultTimespan"]) if obj.get("defaultTimespan") is not None else None,
|
||||||
"isGlobalOverride": obj.get("isGlobalOverride"),
|
"isGlobalOverride": obj.get("isGlobalOverride"),
|
||||||
"isMigratedReport": obj.get("isMigratedReport")
|
"isMigratedReport": obj.get("isMigratedReport"),
|
||||||
|
"_links": DashboardLinks.from_dict(obj["_links"]) if obj.get("_links") is not None else None
|
||||||
})
|
})
|
||||||
return _obj
|
return _obj
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
Manage ThousandEyes Dashboards.
|
Manage ThousandEyes Dashboards.
|
||||||
|
|
||||||
The version of the OpenAPI document: 7.0.0
|
The version of the OpenAPI document: 7.0.4
|
||||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
@ -31,7 +31,7 @@ from dashboards.models.api_stacked_barchart_widget import ApiStackedBarchartWidg
|
|||||||
from dashboards.models.api_table_widget import ApiTableWidget
|
from dashboards.models.api_table_widget import ApiTableWidget
|
||||||
from dashboards.models.api_test_table_widget import ApiTestTableWidget
|
from dashboards.models.api_test_table_widget import ApiTestTableWidget
|
||||||
from dashboards.models.api_timeseries_widget import ApiTimeseriesWidget
|
from dashboards.models.api_timeseries_widget import ApiTimeseriesWidget
|
||||||
from pydantic import StrictStr, Field
|
from pydantic import StrictStr, Field, model_serializer
|
||||||
from typing import Union, List, Set, Optional, Dict
|
from typing import Union, List, Set, Optional, Dict
|
||||||
from typing_extensions import Literal, Self
|
from typing_extensions import Literal, Self
|
||||||
|
|
||||||
@ -280,6 +280,10 @@ class ApiWidget(BaseModel):
|
|||||||
else:
|
else:
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
@model_serializer(when_used="json")
|
||||||
|
def serialize_model(self):
|
||||||
|
return json.loads(self.to_json())
|
||||||
|
|
||||||
def to_json(self) -> str:
|
def to_json(self) -> str:
|
||||||
"""Returns the JSON representation of the actual instance"""
|
"""Returns the JSON representation of the actual instance"""
|
||||||
if self.actual_instance is None:
|
if self.actual_instance is None:
|
||||||
|
|||||||
1345
dashboards/test/test_dashboards_api.py
Normal file
1345
dashboards/test/test_dashboards_api.py
Normal file
File diff suppressed because it is too large
Load Diff
16
dashboards/test/test_utils.py
Normal file
16
dashboards/test/test_utils.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
import json
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict):
|
||||||
|
test_case = unittest.TestCase()
|
||||||
|
test_case.maxDiff = None
|
||||||
|
test_case.assertIsNotNone(model)
|
||||||
|
constructed_json = json.loads(model.to_json())
|
||||||
|
sorted_loaded_json = json.dumps(loaded_json, sort_keys=True)
|
||||||
|
sorted_constructed_json = json.dumps(constructed_json, sort_keys=True)
|
||||||
|
test_case.assertEqual(sorted_loaded_json, sorted_constructed_json)
|
||||||
Loading…
Reference in New Issue
Block a user