Update tests with new which enum

This commit is contained in:
Jason Paryani
2014-02-13 22:08:15 -08:00
parent 3d8dc6daa9
commit dceb437c44

View File

@@ -24,20 +24,23 @@ def test_which_builder(addressbook):
alice = people[0] alice = people[0]
alice.employment.school = "MIT" alice.employment.school = "MIT"
assert alice.employment.which() == "school" assert alice.employment.which == addressbook.Person.Employment.school
assert alice.employment.which == "school"
bob = people[1] bob = people[1]
assert bob.employment.which() == "unemployed" assert bob.employment.which == addressbook.Person.Employment.unemployed
assert bob.employment.which == "unemployed"
bob.employment.unemployed = None bob.employment.unemployed = None
assert bob.employment.which() == "unemployed" assert bob.employment.which == addressbook.Person.Employment.unemployed
assert bob.employment.which == "unemployed"
with pytest.raises(ValueError): with pytest.raises(ValueError):
addresses.which() addresses.which
with pytest.raises(ValueError): with pytest.raises(ValueError):
addresses.which() addresses.which
def test_which_reader(addressbook): def test_which_reader(addressbook):
@@ -63,15 +66,33 @@ def test_which_reader(addressbook):
people = addresses.people people = addresses.people
alice = people[0] alice = people[0]
assert alice.employment.which() == "school" assert alice.employment.which == "school"
bob = people[1] bob = people[1]
assert bob.employment.which() == "unemployed" assert bob.employment.which == "unemployed"
with pytest.raises(ValueError): with pytest.raises(ValueError):
addresses.which() addresses.which
with pytest.raises(ValueError): with pytest.raises(ValueError):
addresses.which() addresses.which
def test_enum(addressbook):
addresses = addressbook.AddressBook.new_message()
people = addresses.init('people', 2)
alice = people[0]
phones = alice.init('phones', 2)
assert phones[0].type == phones[1].type
phones[0].type = addressbook.Person.PhoneNumber.Type.home
assert phones[0].type != phones[1].type
phones[1].type = 'home'
assert phones[0].type == phones[1].type
def test_builder_set(addressbook): def test_builder_set(addressbook):