import datetime
from django.utils import timezone
from factory import LazyAttribute, SubFactory
from factory.fuzzy import FuzzyText, FuzzyInteger, FuzzyDateTime, FuzzyDate, FuzzyDecimal, FuzzyChoice
from factory.django import DjangoModelFactory

from companies.models import Company

class CompanyFactory(DjangoModelFactory):

    cif = FuzzyText(prefix='CIF_', length=10)
    company_name = FuzzyText(prefix='COMPANY_NAME_', length=10)
    short_name = FuzzyText(prefix='SHORT_NAME_', length=10)
    web_link = FuzzyText(prefix='http://WEB-LINK-', suffix='.test', length=10)
    shop = FuzzyChoice(choices=(True, False))
    shop_link = FuzzyText(prefix='http://SHOP-LINK-', suffix='.test', length=10)
    platform = FuzzyChoice(choices=[x[1] for x in Company.PLATFORMS])
    email = FuzzyText(prefix='EMAIL_', suffix='@test.com', length=10)
    logo = None
    city = None
    address = FuzzyText(prefix='ADDRESS_', length=10)
    geo = None
    phone = '+34666555444'
    mobile = '+34666555333'
    other_phone = '+34666555222'
    description = FuzzyText(prefix='DESCRIPTION_', length=250)
    shop_rss_feed = FuzzyText(prefix='http://SHOP-RSS-FEED-', suffix='.test', length=10)
    sale_terms = FuzzyText(prefix='SALES_TERMS', length=250)
    shipping_cost = FuzzyDecimal(low=1.00)
    tags = ['cool', 'hip', 'tech/blockchain']
    sync = FuzzyChoice(choices=(True, False))

    class Meta:
        model = 'companies.Company'


class ValidatedCompanyFactory(DjangoModelFactory):

    cif = FuzzyText(prefix='CIF_', length=10)
    company_name = FuzzyText(prefix='COMPANY_NAME_', length=10)
    short_name = FuzzyText(prefix='SHORT_NAME_', length=10)
    web_link = FuzzyText(prefix='http://WEB-LINK-', suffix='.test', length=10)
    shop = FuzzyChoice(choices=(True, False))
    shop_link = FuzzyText(prefix='http://SHOP-LINK-', suffix='.test', length=10)
    platform = FuzzyChoice(choices=[x[1] for x in Company.PLATFORMS])
    email = FuzzyText(prefix='EMAIL_', suffix='@test.com', length=10)
    logo = None
    city = None
    address = FuzzyText(prefix='ADDRESS_', length=10)
    geo = None
    phone = '+34666555444'
    mobile = '+34666555333'
    other_phone = '+34666555222'
    description = FuzzyText(prefix='DESCRIPTION_', length=250)
    shop_rss_feed = FuzzyText(prefix='http://SHOP-RSS-FEED-', suffix='.test', length=10)
    sale_terms = FuzzyText(prefix='SALES_TERMS', length=250)
    shipping_cost = FuzzyDecimal(low=1.00)
    tags = ['cool', 'hip', 'tech/blockchain']
    sync = FuzzyChoice(choices=(True, False))
    is_validated = True

    class Meta:
        model = 'companies.Company'
