コード例 #1
0
    def setUp(self):
        super(ProductAdminTestCase, self).setUp()
        self.log_in_master_admin()
        self.specialty = SpecialtyFactory(name='Cardiac Rhythm Management')
        CategoryFactory.create_batch(2, specialty=self.specialty)

        self.product_1, self.product_2 = ProductFactory.create_batch(2, model_number='1456Q-86')
        ProductFactory.create_batch(3)
コード例 #2
0
ファイル: test_views.py プロジェクト: Happyandhappy/neptun
    def test_session_authorized_admin_user(self):
        response = self.authorized_admin_client.get(self.path)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data, [])

        product_1, product_2 = ProductFactory.create_batch(2, manufacturer=self.manufacturer)
        product_3 = ProductFactory(category=product_1.category, manufacturer=self.manufacturer)
        ProductFactory(category=CategoryFactory(specialty=product_2.category.specialty))
        response = self.authorized_admin_client.get(self.path)
        self.assertCountEqual(response.data, [
            {'id': product_1.id, 'name': product_1.name},
            {'id': product_2.id, 'name': product_2.name},
            {'id': product_3.id, 'name': product_3.name},
        ])

        path = reverse('api:staff:rebatable_items', args=(self.manufacturer.id, 'category'))
        self.assertEqual(path, f'/api/staff/manufacturers/{self.manufacturer.id}/category')
        response = self.authorized_admin_client.get(path)
        self.assertCountEqual(response.data, [
            {'id': product_1.category.id, 'name': product_1.category.name},
            {'id': product_2.category.id, 'name': product_2.category.name},
        ])

        path = reverse('api:staff:rebatable_items', args=(self.manufacturer.id, 'specialty'))
        self.assertEqual(path, f'/api/staff/manufacturers/{self.manufacturer.id}/specialty')
        response = self.authorized_admin_client.get(path)
        self.assertCountEqual(response.data, [
            {'id': product_1.category.specialty.id, 'name': product_1.category.specialty.name},
            {'id': product_2.category.specialty.id, 'name': product_2.category.specialty.name},
        ])

        path = f'/api/staff/manufacturers/{self.manufacturer.id}/manufacturer'
        response = self.authorized_admin_client.get(path)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
コード例 #3
0
    def setUp(self):
        super().setUp()
        self.category = CategoryFactory()
        self.client_1 = ClientFactory()
        AccountFactory.create(user=self.user, client=self.client_1)
        self.product_1, self.product_2 = ProductFactory.create_batch(2, category=self.category)
        self.feature_1 = FeatureFactory(name='Wireless', product=self.product_2,
                                        shared_image=SharedImageFactory(image=ImageField(filename='wireless.jpg')))
        self.feature_2, self.feature_3 = FeatureFactory.create_batch(2, product=self.product_2)
        price_1 = ClientPriceFactory(client=self.client_1, product=self.product_1, unit_cost=200, system_cost=300)
        price_2 = ClientPriceFactory(client=self.client_1, product=self.product_2, unit_cost=250, system_cost=300)
        ClientPriceFactory(client=self.client_1, unit_cost=250, system_cost=300,
                           product=ProductFactory(enabled=False),)
        self.discount_1 = DiscountFactory(
            client_price=price_1, discount_type=VALUE_DISCOUNT, value=50, name='CCO', order=1, percent=0,
            apply_type=ON_DOCTOR_ORDER, cost_type=UNIT_COST,
            shared_image=SharedImageFactory(image=ImageField(filename='CCO.png'))
        )
        self.discount_2 = DiscountFactory(
            client_price=price_2, discount_type=PERCENT_DISCOUNT, percent=10, cost_type=SYSTEM_COST, order=2,
            apply_type=ON_DOCTOR_ORDER, name='Repless',
            shared_image=SharedImageFactory(image=ImageField(filename='repless.png'))
        )
        self.discount_3 = DiscountFactory(
            client_price=price_1, discount_type=PERCENT_DISCOUNT, value=0, name='Bulk', order=2, percent=15,
            apply_type=PRE_DOCTOR_ORDER, cost_type=UNIT_COST, shared_image=None)
        device = self.client_1.device_set.get(product=self.product_1)
        ItemFactory(device=device, discounts=[self.discount_3], purchase_type=BULK_PURCHASE, is_used=False,
                    cost_type=UNIT_COST)

        self.path = reverse('api:hospital:device:products', args=(self.client_1.id, self.category.id,))
コード例 #4
0
    def test_show_list_of_categories(self):
        self.log_in_master_admin()
        self.specialty, specialty = SpecialtyFactory.create_batch(2)
        self.category = CategoryFactory(name='Total Knee System', specialty=self.specialty)
        CategoryFactory.create_batch(2, specialty=specialty)
        ProductFactory.create_batch(3, category=self.category)

        self.visit_reverse('admin:device_specialty_changelist')
        self.wait_for_element_contains_text('#content h1', 'Select specialty to change')
        self.assert_elements_count('#result_list tbody tr', count=2)

        self.find_link(self.specialty.name).click()
        self.wait_for_element_contains_text('#content h1', 'Select category to change')
        self.assert_elements_count('#result_list tbody tr', count=1)
        self.wait_for_element_contains_text('#result_list tbody tr', 'Total Knee System')

        self.find_link(self.category.name).click()
        self.wait_for_element_contains_text('#content h1', 'Select product to change')
        self.assert_elements_count('#result_list tbody tr', count=3)
コード例 #5
0
    def test_sub_categories_listing(self):
        self.category_2.parent = self.category_1
        self.category_2.save()
        ProductFactory.create_batch(2, category=self.category_2)

        self.visit_reverse('admin:device_specialty_changelist')
        self.wait_for_element_contains_text('.model-specialty.change-list #content h1', 'Select specialty to change')
        self.assert_elements_count('#result_list tbody tr .field-specialty_name', count=1)

        self.find_link(self.specialty.name).click()
        self.wait_for_element_contains_text('.model-category.change-list #content h1', 'Select category to change')
        self.assert_elements_count('#result_list tbody tr .field-category_name', count=1)

        self.find_link(self.category_1.name).click()
        self.wait_for_element_contains_text('#result_list tbody tr .field-category_name', self.category_2.name)

        self.find_link(self.category_2.name).click()
        self.wait_for_element_contains_text('.model-product.change-list #content h1', 'Select product to change')
        self.assert_elements_count('#result_list tbody tr .field-name', count=2)
コード例 #6
0
ファイル: test_models.py プロジェクト: Happyandhappy/neptun
 def setUp(self):
     self.rebate = RebateFactory(name='Q3 bulk rebate',
                                 start_date=date(2018, 7, 1),
                                 end_date=date(2018, 9, 30))
     self.category = CategoryFactory()
     self.product_1, self.product_2 = ProductFactory.create_batch(
         2, category=self.category, manufacturer=self.rebate.manufacturer)
     self.rebate_item_1 = RebatableItemFactory(
         content_object=self.product_1,
         rebate=self.rebate,
         item_type=ELIGIBLE_ITEM)
     self.rebate_item_2 = RebatableItemFactory(content_object=self.category,
                                               rebate=self.rebate,
                                               item_type=REBATED_ITEM)
コード例 #7
0
ファイル: test_models.py プロジェクト: Happyandhappy/neptun
    def test_product_ids(self):
        specialty = SpecialtyFactory()
        category_1, category_2 = CategoryFactory.create_batch(
            2, specialty=specialty)
        product_1, product_2 = ProductFactory.create_batch(2,
                                                           category=category_1)
        product_3, product_4 = ProductFactory.create_batch(2,
                                                           category=category_2)

        self.assertCountEqual(
            RebatableItemFactory(content_object=product_1).product_ids,
            [product_1.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=category_1).product_ids,
            [product_1.id, product_2.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=category_2).product_ids,
            [product_3.id, product_4.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=specialty).product_ids,
            [product_1.id, product_2.id, product_3.id, product_4.id])
        self.assertCountEqual(
            RebatableItemFactory(content_object=ClientFactory()).product_ids,
            [])
コード例 #8
0
ファイル: test_views.py プロジェクト: Happyandhappy/neptun
 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}]
             }
         },
     ])
コード例 #9
0
 def setUp(self):
     self.product_1, self.product_2 = ProductFactory.create_batch(2)