28 lines
984 B
Python
28 lines
984 B
Python
from unittest import TestCase
|
|
from opssat_tmtc.camera_params import CameraParameters
|
|
|
|
|
|
TEST_CAM_PARAMS = CameraParameters(R=8, G=8, B=8, N=1, P=True, E=200, W=1000)
|
|
EXPECTED_JSON = '{"R":8,"G":8,"B":8,"N":1,"P":true,"E":200,"W":1000}'
|
|
|
|
|
|
class TestCamInterface(TestCase):
|
|
def test_serialization_to_dict(self):
|
|
model = TEST_CAM_PARAMS.model_dump()
|
|
self.assertEqual(model["R"], 8)
|
|
self.assertEqual(model["G"], 8)
|
|
self.assertEqual(model["B"], 8)
|
|
self.assertEqual(model["N"], 1)
|
|
self.assertEqual(model["P"], True)
|
|
self.assertEqual(model["E"], 200)
|
|
self.assertEqual(model["W"], 1000)
|
|
|
|
def test_serialization_to_json(self):
|
|
json = TEST_CAM_PARAMS.model_dump_json()
|
|
self.assertEqual(json, EXPECTED_JSON)
|
|
print(json)
|
|
|
|
def test_deserialization(self):
|
|
model_deserialized = CameraParameters.model_validate_json(EXPECTED_JSON)
|
|
self.assertEqual(TEST_CAM_PARAMS, model_deserialized)
|