|
1 | 1 | import pytest |
2 | 2 |
|
3 | | -from ..schemas import StudySchema, StudysetSchema, StudysetSnapshot |
| 3 | +from ..schemas import StudySchema, StudysetSchema, StudysetSnapshot, PointSchema |
4 | 4 | from ..models import Study, Studyset |
5 | 5 | from neurostore.schemas.pipeline import ( |
6 | 6 | PipelineSchema, |
@@ -109,3 +109,28 @@ def test_PipelineStudyResultSchema(): |
109 | 109 | assert result["result_data"] == {"result": "success"} |
110 | 110 | assert result["file_inputs"] == {"input1": "file1"} |
111 | 111 | assert result["status"] == "UNKNOWN" |
| 112 | + |
| 113 | + |
| 114 | +def test_PointSchema_deactivation_field(): |
| 115 | + """Test deactivation field behavior in PointSchema""" |
| 116 | + schema = PointSchema() |
| 117 | + |
| 118 | + # Test 1: When deactivation is explicitly set to None, it should convert to False |
| 119 | + data_with_none = {"x": 1.0, "y": 2.0, "z": 3.0, "deactivation": None} |
| 120 | + result = schema.load(data_with_none) |
| 121 | + assert result["deactivation"] is False |
| 122 | + |
| 123 | + # Test 2: When deactivation is not included in the input data, it should default to False |
| 124 | + data_without_deactivation = {"x": 1.0, "y": 2.0, "z": 3.0} |
| 125 | + result = schema.load(data_without_deactivation) |
| 126 | + assert result["deactivation"] is False |
| 127 | + |
| 128 | + # Test 3: When deactivation is explicitly set to True, it should remain True |
| 129 | + data_with_true = {"x": 1.0, "y": 2.0, "z": 3.0, "deactivation": True} |
| 130 | + result = schema.load(data_with_true) |
| 131 | + assert result["deactivation"] is True |
| 132 | + |
| 133 | + # Test 4: When deactivation is explicitly set to False, it should remain False |
| 134 | + data_with_false = {"x": 1.0, "y": 2.0, "z": 3.0, "deactivation": False} |
| 135 | + result = schema.load(data_with_false) |
| 136 | + assert result["deactivation"] is False |
0 commit comments