Exemple #1
0
    def test_rental_get_all(self):
        rental = RentalModel(rental_schema.load(self.rental1))
        rental.save()
        rental = RentalModel(rental_schema.load(self.rental1))
        rental.save()
        res = RentalService.get_all()

        json_data = json.loads(res.data)
        self.assertEqual(res.status_code, 200)
        self.assertEqual(json_data.__len__(), 2)
Exemple #2
0
    def test_rental_create(self):
        # fail first
        res = RentalService.create(rental_schema.load({}, partial=True))
        self.assertEqual(res.status_code, 400)

        res = RentalService.create(
            rental_schema.load({'movie_id': 1}, partial=True))
        self.assertEqual(res.status_code, 201)

        res = RentalService.get_all()
        json_data = json.loads(res.data)
        self.assertEqual(res.status_code, 200)
        self.assertEqual(json_data.__len__(), 1)
 def get(self):
     """Get all Rentals"""
     return RentalService.get_all()