예제 #1
0
 def test_find_by_gender(self):
     """It should Find Pets by Gender"""
     pets = PetFactory.create_batch(10)
     for pet in pets:
         pet.create()
     gender = pets[0].gender
     count = len([pet for pet in pets if pet.gender == gender])
     found = Pet.find_by_gender(gender)
     self.assertEqual(found.count(), count)
     for pet in found:
         self.assertEqual(pet.gender, gender)
예제 #2
0
 def test_find_by_availability(self):
     """It should Find Pets by Availability"""
     pets = PetFactory.create_batch(10)
     for pet in pets:
         pet.create()
     available = pets[0].available
     count = len([pet for pet in pets if pet.available == available])
     found = Pet.find_by_availability(available)
     self.assertEqual(found.count(), count)
     for pet in found:
         self.assertEqual(pet.available, available)
예제 #3
0
 def test_find_by_category(self):
     """It should Find Pets by Category"""
     pets = PetFactory.create_batch(10)
     for pet in pets:
         pet.create()
     category = pets[0].category
     count = len([pet for pet in pets if pet.category == category])
     found = Pet.find_by_category(category)
     self.assertEqual(found.count(), count)
     for pet in found:
         self.assertEqual(pet.category, category)
예제 #4
0
    def test_find_or_404_found(self):
        """It should Find or return 404 not found"""
        pets = PetFactory.create_batch(3)
        for pet in pets:
            pet.create()

        pet = Pet.find_or_404(pets[1].id)
        self.assertIsNot(pet, None)
        self.assertEqual(pet.id, pets[1].id)
        self.assertEqual(pet.name, pets[1].name)
        self.assertEqual(pet.available, pets[1].available)
        self.assertEqual(pet.gender, pets[1].gender)
        self.assertEqual(pet.birthday, pets[1].birthday)
예제 #5
0
 def test_find_by_name(self):
     """It should Find a Pet by Name"""
     pets = PetFactory.create_batch(5)
     for pet in pets:
         pet.create()
     name = pets[0].name
     found = Pet.find_by_name(name)
     self.assertEqual(found.count(), 1)
     self.assertEqual(found[0].category, pets[0].category)
     self.assertEqual(found[0].name, pets[0].name)
     self.assertEqual(found[0].available, pets[0].available)
     self.assertEqual(found[0].gender, pets[0].gender)
     self.assertEqual(found[0].birthday, pets[0].birthday)
예제 #6
0
 def test_find_pet(self):
     """It should Find a Pet by ID"""
     pets = PetFactory.create_batch(5)
     for pet in pets:
         pet.create()
     logging.debug(pets)
     # make sure they got saved
     self.assertEqual(len(Pet.all()), 5)
     # find the 2nd pet in the list
     pet = Pet.find(pets[1].id)
     self.assertIsNot(pet, None)
     self.assertEqual(pet.id, pets[1].id)
     self.assertEqual(pet.name, pets[1].name)
     self.assertEqual(pet.available, pets[1].available)
     self.assertEqual(pet.gender, pets[1].gender)
     self.assertEqual(pet.birthday, pets[1].birthday)