Skip to content

Commit

Permalink
test: add tests for BaseModel
Browse files Browse the repository at this point in the history
  • Loading branch information
ilfa committed Jul 26, 2024
1 parent bfa2285 commit c6cf192
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions test/test_base_model.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit c6cf192

Please sign in to comment.