diff --git a/servicenow_api/servicenow_models.py b/servicenow_api/servicenow_models.py index 3762168..6c72f07 100644 --- a/servicenow_api/servicenow_models.py +++ b/servicenow_api/servicenow_models.py @@ -32,7 +32,7 @@ class ApplicationServiceModel(BaseModel): - ValueError: If 'application_id' is provided and not a string. """ - application_id: str = None + application_id: Optional[str] = None @field_validator("application_id") def validate_string_parameters(cls, v): @@ -67,7 +67,7 @@ class CMDBModel(BaseModel): - ValueError: If 'cmdb_id' is provided and not a string. """ - cmdb_id: str = None + cmdb_id: Optional[str] = None @field_validator("cmdb_id") def validate_string_parameters(cls, v): @@ -179,7 +179,7 @@ def validate_string_parameters(cls, v): return v @field_validator("sys_ids") - def validate_string_parameters(cls, v): + def validate_sys_ids_parameters(cls, v): """ Validate specific string parameters to ensure they are a List @@ -497,7 +497,7 @@ class ImportSetModel(BaseModel): - data (Dict): Dictionary containing additional data. """ - table: str = None + table: Optional[str] = None import_set_sys_id: Optional[str] = None data: Optional[Dict] = None @@ -644,7 +644,7 @@ class TableModel(BaseModel): The class includes field_validator functions for specific attribute validations. """ - table: str = None + table: Optional[str] = None table_record_sys_id: Optional[str] = None name_value_pairs: Optional[Dict] = None sysparm_display_value: Optional[str] = None diff --git a/test/test_servicenow_models.py b/test/test_servicenow_models.py index d732aaa..4834eb6 100644 --- a/test/test_servicenow_models.py +++ b/test/test_servicenow_models.py @@ -25,7 +25,6 @@ else: skip = False - reason = "do not run on MacOS or windows OR dependency is not installed OR " + reason @@ -33,12 +32,88 @@ sys.platform in ["darwin"] or skip, reason=reason, ) -def test_servicenow_models(): - # test Project model group_id +def test_servicenow_article(): article_sys_id = "asdofaisudfa098098as0df9a8s" article = KnowledgeManagementModel(article_sys_id=article_sys_id) assert article_sys_id == article.article_sys_id +@pytest.mark.skipif( + sys.platform in ["darwin"] or skip, + reason=reason, +) +def test_servicenow_change(): + change_request_sys_id = "asdofaisudfa098098as0df9a8s" + change = ChangeManagementModel(change_request_sys_id=change_request_sys_id) + assert change_request_sys_id == change.change_request_sys_id + + +@pytest.mark.skipif( + sys.platform in ["darwin"] or skip, + reason=reason, +) +def test_servicenow_incident(): + incident_id = "asdofaisudfa098098as0df9a8s" + incident = IncidentModel(incident_id=incident_id) + assert incident_id == incident.incident_id + + +@pytest.mark.skipif( + sys.platform in ["darwin"] or skip, + reason=reason, +) +def test_servicenow_cicd(): + result_id = "asdofaisudfa098098as0df9a8s" + cicd = CICDModel(result_id=result_id) + assert result_id == cicd.result_id + + +@pytest.mark.skipif( + sys.platform in ["darwin"] or skip, + reason=reason, +) +def test_servicenow_application(): + application_id = "asdofaisudfa098098as0df9a8s" + application = ApplicationServiceModel(application_id=application_id) + assert application_id == application.application_id + + +@pytest.mark.skipif( + sys.platform in ["darwin"] or skip, + reason=reason, +) +def test_servicenow_table(): + table_name = "users" + table = TableModel(table=table_name) + assert table_name == table.table + + +@pytest.mark.skipif( + sys.platform in ["darwin"] or skip, + reason=reason, +) +def test_servicenow_import_set(): + import_set_sys_id = "asdofaisudfa098098as0df9a8s" + import_set = ImportSetModel(import_set_sys_id=import_set_sys_id) + assert import_set_sys_id == import_set.import_set_sys_id + + +@pytest.mark.skipif( + sys.platform in ["darwin"] or skip, + reason=reason, + ) +def test_servicenow_cmdb(): + cmdb_id = "asdofaisudfa098098as0df9a8s" + cmdb = CMDBModel(cmdb_id=cmdb_id) + assert cmdb_id == cmdb.cmdb_id + + if __name__ == "__main__": - test_servicenow_models() + test_servicenow_article() + test_servicenow_change() + test_servicenow_incident() + test_servicenow_cicd() + test_servicenow_application() + test_servicenow_table() + test_servicenow_import_set() + test_servicenow_cmdb()