File size: 1,423 Bytes
550665c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
from unittest import TestCase
from gcsa.person import Person
from gcsa.serializers.person_serializer import PersonSerializer
class TestPerson(TestCase):
def test_repr_str(self):
person = Person(
email='[email protected]',
display_name='Guest',
_id='123123',
_is_self=False
)
self.assertEqual(person.__repr__(), "<Person '[email protected]' - 'Guest'>")
self.assertEqual(person.__str__(), "'[email protected]' - 'Guest'")
class TestPersonSerializer(TestCase):
def test_to_json(self):
person = Person(
email='[email protected]',
display_name='Organizer'
)
person_json = PersonSerializer(person).get_json()
self.assertEqual(person.email, person_json['email'])
self.assertEqual(person.display_name, person_json['displayName'])
def test_to_object(self):
person_json = {
'email': '[email protected]',
'displayName': 'Creator',
'id': '123123',
'self': False
}
person = PersonSerializer.to_object(person_json)
self.assertEqual(person_json['email'], person.email)
self.assertEqual(person_json['displayName'], person.display_name)
self.assertEqual(person_json['id'], person.id_)
self.assertEqual(person_json['self'], person.is_self)
|