From 9fec7f69f514655ed2172e72300f779abae7b55f Mon Sep 17 00:00:00 2001 From: Jon Date: Sat, 7 Jun 2025 15:40:01 +0930 Subject: [PATCH] chore: add spt to class test cases for fields to be set as non-existant ref: #804 --- app/centurion/tests/unit_class.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/centurion/tests/unit_class.py b/app/centurion/tests/unit_class.py index 751d6484..c43275bf 100644 --- a/app/centurion/tests/unit_class.py +++ b/app/centurion/tests/unit_class.py @@ -1,5 +1,7 @@ import pytest +from django.db import models + @pytest.mark.unit @@ -23,6 +25,8 @@ class ClassTestCases: } ``` + **Note:** if the field does not exist, for the sub dict use `django.db.models.NOT_PROVIDED` + """ @@ -41,6 +45,10 @@ class ClassTestCases: Ensure that field `param_field_name` exists within the model """ + if param_type == models.NOT_PROVIDED: + + pytest.xfail( reason = 'Class does not have attribute') + assert hasattr(test_class, param_field_name) @@ -54,6 +62,11 @@ class ClassTestCases: Ensure that field `param_field_name` has a type of `param_type` """ + if param_type == models.NOT_PROVIDED: + + pytest.xfail( reason = 'Class does not have attribute') + + if type(getattr(test_class, param_field_name)) is property: assert type( getattr(test_class, param_field_name).fget(test_class) ) is param_type @@ -73,6 +86,10 @@ class ClassTestCases: Ensure that field `param_field_name`has a value of `param_value` """ + if param_value == models.NOT_PROVIDED: + + pytest.xfail( reason = 'Class does not have attribute') + if type(getattr(test_class, param_field_name)) is property: