# Path: alerts/events/factories.py
# def randomSHA256():
#     def abi(self):
#     def alert(self):
# class UserFactory(factory.DjangoModelFactory):
#     class Meta:
# class DAppFactory(factory.DjangoModelFactory):
#     class Meta:
# class AlertFactory(factory.DjangoModelFactory):
#     class Meta:
# class EventFactory(factory.DjangoModelFactory):
#     class Meta:
# class EventValueFactory(factory.DjangoModelFactory):
#     class Meta:


from django.test import TestCase
from alerts.events import factories
from events import serializers
class TestSerializers(TestCase):

    def test_user_serializer(self):
        dapp = factories.DAppFactory()
        serialized_user = serializers.UserSerializer(dapp.user)
        serialized_dapp = serializers.DAppSerializer(dapp)
        self.assertIsNotNone(serialized_user)
        self.assertEquals(serialized_user.data.get('email'), dapp.user.email)
        self.assertEquals(serialized_dapp.data.get('authentication_code'), dapp.authentication_code)

        user_dict = {'email': None}
        dapp_dict = {'name': None, 'authentication_code': dapp.authentication_code, 'user': user_dict}

        serialized_dapp_fail = serializers.DAppSerializer(data=dapp_dict)
        serialized_user_fail = serializers.UserSerializer(data=user_dict)
        self.assertFalse(serialized_dapp_fail.is_valid())
        self.assertFalse(serialized_user_fail.is_valid())

        dapp_dict['name'] = 'testname'
        dapp_dict['authentication_code'] = 'testcode'
        user_dict['email'] = 'anotheremail@test.com'
        dapp_dict['user'] = user_dict

        serialized_dapp_success = serializers.DAppSerializer(data=dapp_dict)
        serialized_user_success = serializers.UserSerializer(data=user_dict)

        self.assertTrue(serialized_dapp_success.is_valid())
        self.assertTrue(serialized_user_success.is_valid())

    def test_event_serializer(self):

# Path: alerts/events/factories.py
# def randomSHA256():
#     def abi(self):
#     def alert(self):
# class UserFactory(factory.DjangoModelFactory):
#     class Meta:
# class DAppFactory(factory.DjangoModelFactory):
#     class Meta:
# class AlertFactory(factory.DjangoModelFactory):
#     class Meta:
# class EventFactory(factory.DjangoModelFactory):
#     class Meta:
# class EventValueFactory(factory.DjangoModelFactory):
#     class Meta:


# Path: alerts/events/tests/test_serializers.py
from django.test import TestCase
from alerts.events import factories
from events import serializers

class TestSerializers(TestCase):

    def test_user_serializer(self):
        dapp = factories.DAppFactory()
        serialized_user = serializers.UserSerializer(dapp.user)
        serialized_dapp = serializers.DAppSerializer(dapp)
        self.assertIsNotNone(serialized_user)
        self.assertEquals(serialized_user.data.get('email'), dapp.user.email)
        self.assertEquals(serialized_dapp.data.get('authentication_code'), dapp.authentication_code)

        user_dict = {'email': None}
        dapp_dict = {'name': None, 'authentication_code': dapp.authentication_code, 'user': user_dict}

        serialized_dapp_fail = serializers.DAppSerializer(data=dapp_dict)
        serialized_user_fail = serializers.UserSerializer(data=user_dict)
        self.assertFalse(serialized_dapp_fail.is_valid())
        self.assertFalse(serialized_user_fail.is_valid())

        dapp_dict['name'] = 'testname'
        dapp_dict['authentication_code'] = 'testcode'
        user_dict['email'] = 'anotheremail@test.com'
        dapp_dict['user'] = user_dict

        serialized_dapp_success = serializers.DAppSerializer(data=dapp_dict)
        serialized_user_success = serializers.UserSerializer(data=user_dict)

        self.assertTrue(serialized_dapp_success.is_valid())
        self.assertTrue(serialized_user_success.is_valid())

    def test_event_serializer(self):

        event_value = factories.EventValueFactory()