示例#1
0
def test_household_to_dict_to_object():
    chris = model.Person(
        last_name='Barker',
        first_name='Chris',
        middle_name='H',
        cell_phone='(123) 555-7890',
        email='*****@*****.**',
    )
    fred = model.Person(
        last_name='Jones',
        first_name='Fred',
        middle_name='B',
        cell_phone='(123) 555-7890',
        email='*****@*****.**',
    )
    home = model.Household(
        name="The Barkers",
        people=(chris, ),
        address=model.Address(
            line_1='123 Some St',
            line_2='Apt 1234',
            city='Seattle',
            state='WA',
            zip_code='98000',
        ),
        phone='123-456-8762',
    )

    home2 = model.Household.from_dict(home.to_dict())

    assert home2.name == home.name
    assert home2.phone == home.phone
    assert home2.address.line_1 == home.address.line_1
    assert home2.address.line_2 == home.address.line_2
    assert home2.people == home.people
示例#2
0
def test_household_to_dict():
    chris = model.Person(
        last_name='Barker',
        first_name='Chris',
        middle_name='H',
        cell_phone='(123) 555-7890',
        email='*****@*****.**',
    )
    home = model.Household(
        name="The Barkers",
        people=(chris, ),
        address=model.Address(
            line_1='123 Some St',
            line_2='Apt 1234',
            city='Seattle',
            state='WA',
            zip_code='98000',
        ),
        phone='123-456-8762',
    )

    home_dct = home.to_dict()

    assert home_dct['name'] == "The Barkers"
    assert home_dct['address']['city'] == 'Seattle'
示例#3
0
def fred():
    fred = model.Person(last_name='Jones',
                        first_name='Fred',
                        middle_name='B',
                        cell_phone='(123) 555-7890',
                        email='*****@*****.**',
                        )
    return fred
示例#4
0
def chris():
    chris = model.Person(last_name='Barker',
                         first_name='Chris',
                         middle_name='H',
                         cell_phone='(123) 555-7890',
                         email='*****@*****.**',
                         )
    return chris
示例#5
0
def test_person_to_dict():
    chris = model.Person(
        last_name='Barker',
        first_name='Chris',
        middle_name='H',
        cell_phone='(123) 555-7890',
        email='*****@*****.**',
    )

    dct = chris.to_dict()

    assert dct['last_name'] == "Barker"
    assert dct['email'] == '*****@*****.**'
示例#6
0
def test_person_to_from_dict():
    chris = model.Person(
        last_name='Barker',
        first_name='Chris',
        middle_name='H',
        cell_phone='(123) 555-7890',
        email='*****@*****.**',
    )

    dct = chris.to_dict()
    chris2 = model.Person.from_dict(dct)

    print(chris2)

    assert chris2.last_name == 'Barker'
    assert chris2.first_name == 'Chris'
    assert chris2.middle_name == 'H'
    assert chris2.cell_phone == '(123) 555-7890'
    assert chris2.email == '*****@*****.**'