Exemplo n.º 1
0
 def test_clean__different_depots(self):
     itemRental = ItemRental(rental=Rental(depot=self.depotA,
                                           user=self.user_member),
                             item=Item(quantity=42, depot=self.depotB),
                             quantity=12)
     with self.assertRaises(ValidationError):
         itemRental.clean()
Exemplo n.º 2
0
 def test_clean__greater_amount(self):
     itemRental = ItemRental(rental=Rental(depot=self.depotA,
                                           user=self.user_member),
                             item=Item(quantity=42),
                             quantity=56)
     with self.assertRaises(ValidationError):
         itemRental.clean()
Exemplo n.º 3
0
    def get_queryset(self, request):
        qs = super().get_queryset(request)

        if request.user.is_superuser:
            return qs

        return qs.filter(Item.filter_by_user(request.user)).distinct()
Exemplo n.º 4
0
 def test_clean__not_public_member(self):
     itemRental = ItemRental(rental=Rental(depot=self.depotA,
                                           user=self.user_member),
                             item=Item(visibility=Item.VISIBILITY_INTERNAL,
                                       quantity=42,
                                       depot=self.depotA),
                             quantity=12)
     itemRental.clean()
Exemplo n.º 5
0
 def test_clean__valid_data(self):
     itemRental = ItemRental(rental=Rental(depot=self.depotA,
                                           user=self.user_member),
                             item=Item(visibility=Item.VISIBILITY_PUBLIC,
                                       quantity=42,
                                       depot=self.depotA),
                             quantity=12)
     itemRental.clean()
Exemplo n.º 6
0
 def test_clean__not_public_not_member(self):
     itemRental = ItemRental(rental=Rental(depot=self.depotA,
                                           user=self.user_not_member),
                             item=Item(visibility=Item.VISIBILITY_INTERNAL,
                                       quantity=42,
                                       depot=self.depotA),
                             quantity=12)
     with self.assertRaises(ValidationError):
         itemRental.clean()
Exemplo n.º 7
0
 def test_str(self):
     item = Item(name='My item')
     self.assertEqual(item.__str__(), 'My item')