# Path: tests/v1/python/accounts/test_models.py
# class UserFactory(factory.DjangoModelFactory):
#     first_name = 'John'
#     last_name = 'Doe'
#     is_active = True
#     facebook_uid = str(uuid.uuid4())
# 
#     class Meta:
#         model = User
#         django_get_or_create = ('email',)


from rest_framework import status
from rest_framework.test import APITestCase
from device.v1.serializers import OrderDeviceSerializer, GetOrderDeviceListSerializer
from lib.v1.testutils import CustomTestCase
from tests.v1.python.accounts.test_models import UserFactory

class OrderDeviceSerializerTest(CustomTestCase, APITestCase):
    INVALID_DATA_DICT = [
        {
            'data': {
                'user': 1,
                'address': 'Street John 221',
                'phone_number': '+35190123450232'
            },
            'error': ('phone_number', ['Phone number is not valid.']),
            'label': 'Invalid phone number format.',
            'method': 'POST',
            'status': status.HTTP_400_BAD_REQUEST
        }
    ]
    VALID_DATA_DICT = [
        {
            'user': '28cae40c-7caf-4e24-87d6-d9ec68853b7d',
            'address': 'Street John 221',
            'phone_number': '+23412345678'
        },
    ]

    def setUp(self):
        self.required_fields = ['user', 'address', 'phone_number']
        self.not_required_fields = ['id', 'payment']
        self.user = UserFactory(id='28cae40c-7caf-4e24-87d6-d9ec68853b7d', email='a@a.com')

    def test_fields(self):
        serializer = OrderDeviceSerializer()

# Path: tests/v1/python/accounts/test_models.py
# class UserFactory(factory.DjangoModelFactory):
#     first_name = 'John'
#     last_name = 'Doe'
#     is_active = True
#     facebook_uid = str(uuid.uuid4())
# 
#     class Meta:
#         model = User
#         django_get_or_create = ('email',)


# Path: tests/v1/python/device/test_serializers.py
from rest_framework import status
from rest_framework.test import APITestCase
from device.v1.serializers import OrderDeviceSerializer, GetOrderDeviceListSerializer
from lib.v1.testutils import CustomTestCase
from tests.v1.python.accounts.test_models import UserFactory


class OrderDeviceSerializerTest(CustomTestCase, APITestCase):
    INVALID_DATA_DICT = [
        {
            'data': {
                'user': 1,
                'address': 'Street John 221',
                'phone_number': '+35190123450232'
            },
            'error': ('phone_number', ['Phone number is not valid.']),
            'label': 'Invalid phone number format.',
            'method': 'POST',
            'status': status.HTTP_400_BAD_REQUEST
        }
    ]
    VALID_DATA_DICT = [
        {
            'user': '28cae40c-7caf-4e24-87d6-d9ec68853b7d',
            'address': 'Street John 221',
            'phone_number': '+23412345678'
        },
    ]

    def setUp(self):
        self.required_fields = ['user', 'address', 'phone_number']
        self.not_required_fields = ['id', 'payment']
        self.user = UserFactory(id='28cae40c-7caf-4e24-87d6-d9ec68853b7d', email='a@a.com')

    def test_fields(self):
        serializer = OrderDeviceSerializer()

        self.assert_fields_required(True, serializer, self.required_fields)