Skip to content

Commit

Permalink
✅ Add tests for TypeSerializer class
Browse files Browse the repository at this point in the history
  • Loading branch information
yezz123 committed Mar 1, 2024
1 parent e0f4ff5 commit 26fda8b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest

from fastango.serializer import TypeSerializer


class TestTypeSerializer:
@pytest.fixture
def type_serializer(self):
return TypeSerializer()

def test_serialize_valid(self, type_serializer):
obj = {"key": "value"}
serialized_data = type_serializer.serialize(obj)
assert isinstance(serialized_data, bytes)

def test_serialize_auto_detection(self, type_serializer):
# Define a sample object where auto-detection should be used
obj = [{"key1": "value1"}, {"key2": "value2"}] # List of dictionaries

# Call the serialize method with from_attributes="auto"
serialized_data = type_serializer.serialize(obj, from_attributes="auto")

# Assert that serialized_data is of type bytes
assert isinstance(serialized_data, bytes)

0 comments on commit 26fda8b

Please sign in to comment.