# Path: tests/ex03_company/models.py
# class Company(object):
#     name = related.StringField()
#     uuid = related.UUIDField()
#     email = related.RegexField("[^@]+@[^@]+", required=False)
#     is_active = related.BooleanField(required=False)
#     url = related.URLField(required=False)
#     meta = related.ChildField(dict, required=False)
#     nicknames = related.SequenceField(str, required=False)
#     temperature = related.FloatField(required=False)
#     guess = related.SetField(int, required=False)
#     established = related.DateField('%m/%d/%Y', required=False)
#     closed = related.DateField(required=False)  # default formatter (%Y-%m-%d)


from datetime import date, datetime
from uuid import UUID
from future.moves.urllib.parse import ParseResult
from pytest import fixture, raises
from six import string_types
from related import (to_dict, to_yaml, from_yaml,
                     to_json, from_json)
from .models import Company
    return Company(
        name='Acme Inc.',
        url='http://www.acme-inc-website.net/',
        email='info@acme-inc.net',
        meta=dict(key1="value1", key2="value2"),
        nicknames=("Acme", u"Acme", 123),
        temperature=80.4,
        guess=[1, 4, 6, 8, 9, 14, 27, 45],
        established="1/2/1903",
        closed=datetime.strptime('1904-05-06', '%Y-%m-%d'),  # pass datetime
    )


def test_field_getters(company):
    assert company.name == 'Acme Inc.'
    assert isinstance(company.uuid, UUID)
    assert isinstance(company.url, ParseResult)
    assert company.url.geturl() == 'http://www.acme-inc-website.net/'
    assert company.url.netloc == 'www.acme-inc-website.net'
    assert company.url.scheme == 'http'
    assert company.nicknames == ["Acme", "Acme", "123"]
    assert company.guess == {1, 4, 6, 8, 9, 14, 27, 45}
    assert sorted(list(company.guess)) == [1, 4, 6, 8, 9, 14, 27, 45]
    assert company.temperature == 80.4
    assert company.established == date(1903, 1, 2)
    assert company.closed == date(1904, 5, 6)


def test_dictionary(company):
    company_dict = to_dict(company)

# Path: tests/ex03_company/models.py
# class Company(object):
#     name = related.StringField()
#     uuid = related.UUIDField()
#     email = related.RegexField("[^@]+@[^@]+", required=False)
#     is_active = related.BooleanField(required=False)
#     url = related.URLField(required=False)
#     meta = related.ChildField(dict, required=False)
#     nicknames = related.SequenceField(str, required=False)
#     temperature = related.FloatField(required=False)
#     guess = related.SetField(int, required=False)
#     established = related.DateField('%m/%d/%Y', required=False)
#     closed = related.DateField(required=False)  # default formatter (%Y-%m-%d)


# Path: tests/ex03_company/test_company.py
from datetime import date, datetime
from uuid import UUID
from future.moves.urllib.parse import ParseResult
from pytest import fixture, raises
from six import string_types
from related import (to_dict, to_yaml, from_yaml,
                     to_json, from_json)
from .models import Company

    return Company(
        name='Acme Inc.',
        url='http://www.acme-inc-website.net/',
        email='info@acme-inc.net',
        meta=dict(key1="value1", key2="value2"),
        nicknames=("Acme", u"Acme", 123),
        temperature=80.4,
        guess=[1, 4, 6, 8, 9, 14, 27, 45],
        established="1/2/1903",
        closed=datetime.strptime('1904-05-06', '%Y-%m-%d'),  # pass datetime
    )


def test_field_getters(company):
    assert company.name == 'Acme Inc.'
    assert isinstance(company.uuid, UUID)
    assert isinstance(company.url, ParseResult)
    assert company.url.geturl() == 'http://www.acme-inc-website.net/'
    assert company.url.netloc == 'www.acme-inc-website.net'
    assert company.url.scheme == 'http'
    assert company.nicknames == ["Acme", "Acme", "123"]
    assert company.guess == {1, 4, 6, 8, 9, 14, 27, 45}
    assert sorted(list(company.guess)) == [1, 4, 6, 8, 9, 14, 27, 45]
    assert company.temperature == 80.4
    assert company.established == date(1903, 1, 2)
    assert company.closed == date(1904, 5, 6)


def test_dictionary(company):
    company_dict = to_dict(company)

    assert company_dict['name'] == 'Acme Inc.'