コード例 #1
0
def setup():
    the_cattery = Cattery()
    """
      ID    First Name   Last Name   Amount Owed
      7        Ruth      George      $12.34
      23      Casey      van Dyke    $34.56
      4      Temepara   Williams    $12.56
      165     Irene     Aitkin      $56.12
    """
    # ADD CODE HERE TO CREATE THE OWNERS
    the_cattery.add_owner('7', 'Ruth', 'George', 12.34)
    the_cattery.add_owner('23', 'Casey', 'van Dyke', 34.56)
    the_cattery.add_owner('4', 'Temepara', 'Williams', 12.56)
    the_cattery.add_owner('165', 'Irene', 'Aitkin', 56.12)
    """
    Owner ID    Name      Breed          Gender    Secret Name
    
     7          Art      Abyssianian       N      The Underwear Thief
     23        Fluffy     Persian          M       Grey ghost
     23        Blackey   Common Domestic   N       Her Majesty
     23         Inky       Persian         F       The Talker
     4          Meta        Tabby          F    Mouse's worse nightmare
     165      Random       Siamese         F     The One-Eyed Horror
    """
    # ADD CODE HERE TO CREATE THE CATS

    return the_cattery
コード例 #2
0
 def test_g_add_cat_increases_cat_count(self):
     cattery = Cattery()
     owner = Owner('1', 'A', 'B', 2, cattery)
     owner.add_cat('name1', 'breed1', 'gender1', 'secret_name1')
     assert len(owner.all_my_cats) == 1
     owner.add_cat('name2', 'breed2', 'gender2', 'secret_name2')
     assert len(owner.all_my_cats) == 2
コード例 #3
0
 def test_a_owner_properties(self):
     cattery = Cattery()
     owner = Owner('1', 'A', 'B', 2, cattery)
     assert hasattr(owner, 'id')
     assert hasattr(owner, 'first_name')
     assert hasattr(owner, 'last_name')
     assert hasattr(owner, 'amount_owed')
     assert hasattr(owner, 'my_cattery')
     assert hasattr(owner, 'all_my_cats')
     assert type(owner.all_my_cats) == list
コード例 #4
0
 def test_f_owner_add_cat_exists(self):
     cattery = Cattery()
     owner = Owner('1', 'A', 'B', 2, cattery)
     assert hasattr(owner, 'add_cat')
     assert callable(getattr(owner, 'add_cat', None))
コード例 #5
0
 def test_e_cattery_get_those_with_many_cats_not_hard_coded(self):
     cattery = Cattery()
     returned = cattery.get_those_with_many_cats()
     assert len(returned) == 0
コード例 #6
0
 def test_d_cattery_get_those_with_many_cats_returns_string(self):
     cattery = Cattery()
     returned = cattery.get_those_with_many_cats()
     assert isinstance(returned, str)
コード例 #7
0
 def test_c_cattery_get_those_with_many_cats_exists(self):
     cattery = Cattery()
     assert hasattr(cattery, 'get_those_with_many_cats')
     assert callable(getattr(cattery, 'get_those_with_many_cats', None))
コード例 #8
0
 def test_a_cattery_collection(self):
     cattery = Cattery()
     assert hasattr(cattery, 'all_my_owners')
     assert type(cattery.all_my_owners) == list
コード例 #9
0
 def test_b_owner_methods(self):
     cattery = Cattery()
     owner = Owner('1', 'A', 'B', 2, cattery)
     assert hasattr(owner, 'sort_cats')
     assert callable(getattr(owner, 'sort_cats', None))
コード例 #10
0
 def test_d_cattery_sort_owners(self):
     cattery = Cattery()
     assert hasattr(cattery, 'sort_owners')
     assert callable(getattr(cattery, 'sort_owners', None))
コード例 #11
0
 def test_c_cattery_find_owner(self):
     cattery = Cattery()
     assert hasattr(cattery, 'find_owner')
     assert callable(getattr(cattery, 'find_owner', None))
コード例 #12
0
 def test_b_cattery_add_owner(self):
     cattery = Cattery()
     assert hasattr(cattery, 'add_owner')
     assert callable(getattr(cattery, 'add_owner', None))
コード例 #13
0
 def test_a_owner__str__exists(self):
     cattery = Cattery()
     owner = Owner('id', 'first_name', 'last_name', 'amount_owed', cattery)
     assert type(owner).__str__ is not object.__str__
コード例 #14
0
 def test_c_owner__str__works(self):
     cattery = Cattery()
     cattery = Cattery()
     owner = Owner('id', 'first_name', 'last_name', 'amount_owed', cattery)
     returned = str(owner)
     assert returned == 'first_name, last_name [id]'
コード例 #15
0
 def test_b_owner__str__returns_string(self):
     cattery = Cattery()
     owner = Owner('id', 'first_name', 'last_name', 'amount_owed', cattery)
     returned = str(owner)
     assert isinstance(returned, str)