Exemple #1
0
 def test_property_discounts_as_table(self):
     discount_1, discount_2, discount_3 = DiscountFactory.create_batch(3)
     item = ItemFactory(discounts=[discount_1, discount_2])
     discounts_table = item.discounts_as_table
     self.assertTrue(discount_1.name in discounts_table)
     self.assertTrue(discount_2.name in discounts_table)
     self.assertFalse(discount_3.name in discounts_table)
Exemple #2
0
 def setUp(self):
     super().setUp()
     self.log_in_master_admin()
     self.client = ClientFactory()
     self.product = ProductFactory()
     ClientPriceFactory(client=self.client, product=self.product)
     device = self.client.device_set.get(product=self.product)
     self.discounts = DiscountFactory.create_batch(2)
     self.item = ItemFactory(device=device,
                             purchase_type=BULK_PURCHASE,
                             is_used=False,
                             discounts=self.discounts)
Exemple #3
0
 def test_session_authorized_staff_user(self):
     product_1, product_2 = ProductFactory.create_batch(2)
     discount_1, discount_3 = DiscountFactory.create_batch(2, cost_type=UNIT_COST)
     discount_2 = DiscountFactory(cost_type=SYSTEM_COST)
     ClientPriceFactory(client=self.hospital, product=product_1, discounts=[discount_1])
     ClientPriceFactory(client=self.hospital, product=product_2, discounts=[discount_2, discount_3])
     response = self.authorized_admin_client.get(self.path)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertCountEqual(response.data, [
         {
             'id': product_1.id,
             'discounts': {
                 UNIT_COST: [{'id': discount_1.id, 'name': discount_1.name}],
                 SYSTEM_COST: []
             }
         }, {
             'id': product_2.id,
             'discounts': {
                 UNIT_COST: [{'id': discount_3.id, 'name': discount_3.name}],
                 SYSTEM_COST: [{'id': discount_2.id, 'name': discount_2.name}]
             }
         },
     ])