diff --git a/test/test_base_model.py b/test/test_base_model.py new file mode 100644 index 00000000..bbaae8c5 --- /dev/null +++ b/test/test_base_model.py @@ -0,0 +1,63 @@ +import pprint +import unittest +from typing import Dict + +from fingerprint_pro_server_api_sdk import BaseModel + + +class ExampleModel(BaseModel): + """Example model that inherits from BaseModel for testing purposes.""" + swagger_types: Dict[str, str] = { + 'name': 'str', + 'details': 'dict' + } + + attribute_map: Dict[str, str] = { + 'name': 'name', + 'details': 'details' + } + + def __init__(self, name=None, details=None): + self.name = name + self.details = details + + +class MyTestCase(unittest.TestCase): + + def setUp(self): + """Set up test fixtures.""" + self.model = ExampleModel(name="Test Model", details={"key": "value"}) + + def test_to_dict(self): + """Test conversion to dictionary.""" + expected = { + 'name': "Test Model", + 'details': {"key": "value"} + } + self.assertEqual(self.model.to_dict(), expected) + + def test_to_str(self): + """Test conversion to string.""" + expected_str = pprint.pformat(self.model.to_dict()) + self.assertEqual(self.model.to_str(), expected_str) + + def test_repr(self): + """Test __repr__ method.""" + expected_repr = self.model.to_str() + self.assertEqual(repr(self.model), expected_repr) + + def test_eq(self): + """Test equality comparison.""" + model1 = ExampleModel(name="Test Model", details={"key": "value"}) + model2 = ExampleModel(name="Test Model", details={"key": "value"}) + self.assertTrue(model1 == model2) + + def test_ne(self): + """Test inequality comparison.""" + model1 = ExampleModel(name="Test Model", details={"key": "value"}) + model2 = ExampleModel(name="Test Model", details={"key": "different_value"}) + self.assertTrue(model1 != model2) + + +if __name__ == '__main__': + unittest.main()