Ejemplo n.º 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)
Ejemplo n.º 2
0
 def setUp(self):
     super().setUp()
     self.specialty = SpecialtyFactory()
     self.category_1, self.category_2 = CategoryFactory.create_batch(2, specialty=self.specialty)
     self.log_in_master_admin()
     self.visit_reverse('admin:device_category_add')
     self.wait_for_element_contains_text('.model-category.change-form #content h1', 'Add category')
Ejemplo n.º 3
0
    def test_rebatable_items(self):
        for model_name in ['product', 'category', 'specialty']:
            self.assertCountEqual(
                self.manufacturer.rebatable_items(model_name), [])

        specialty_1, specialty_2 = SpecialtyFactory.create_batch(2)
        category_1 = CategoryFactory(specialty=specialty_1)
        category_2, category_3 = CategoryFactory.create_batch(
            2, specialty=specialty_2)
        product_1 = ProductFactory(category=category_1,
                                   manufacturer=self.manufacturer)
        product_2 = ProductFactory(category=category_2,
                                   manufacturer=self.manufacturer)
        product_3 = ProductFactory(category=category_3,
                                   manufacturer=self.manufacturer)
        product_4 = ProductFactory(category=category_1,
                                   manufacturer=self.manufacturer)
        ProductFactory(category=category_3)

        self.assertCountEqual(self.manufacturer.rebatable_items('specialty'),
                              [specialty_1, specialty_2])
        self.assertCountEqual(self.manufacturer.rebatable_items('category'),
                              [category_1, category_2, category_3])
        self.assertCountEqual(self.manufacturer.rebatable_items('product'),
                              [product_1, product_2, product_3, product_4])
        self.assertCountEqual(
            self.manufacturer.rebatable_items('manufacturer'), [])
Ejemplo n.º 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)
Ejemplo n.º 5
0
    def test_devices_by_specialties(self):
        specialty1, specialty2 = SpecialtyFactory.create_batch(2)
        category1 = CategoryFactory(specialty=specialty1)
        category2, category3 = CategoryFactory.create_batch(2, specialty=specialty2)
        product1 = DeviceFactory(client=self.client, product=ProductFactory(name='Device1', category=category1)).product
        product2 = DeviceFactory(client=self.client, product=ProductFactory(name='Device2', category=category2)).product
        product3 = DeviceFactory(client=self.client, product=ProductFactory(name='Device3', category=category3)).product

        self.assertDictEqual(self.client.devices_by_specialties(), {
            specialty1.id: {'name': specialty1.name, 'products': [(product1.id, product1.name)]},
            specialty2.id: {'name': specialty2.name, 'products': [(product2.id, product2.name),
                                                                  (product3.id, product3.name)]}
        })
Ejemplo n.º 6
0
 def setUp(self):
     super().setUp()
     self.category_1, self.category_2 = CategoryFactory.create_batch(2)
     self.client_1, self.client_2 = ClientFactory.create_batch(2)
     self.user.default_client = self.client_1
     self.user.save()
     self.path = reverse('api:hospital:device:categories', args=(self.client_1.id,))
     self.account_1 = AccountFactory.create(user=self.user, client=self.client_1)
     self.account_2 = AccountFactory.create(user=self.user, client=self.client_2)
     ClientPriceFactory(client=self.client_1, product=ProductFactory(category=self.category_1))
     ClientPriceFactory(client=self.client_1, product=ProductFactory(category=self.category_2))
     ClientPriceFactory(client=self.client_2, product=ProductFactory(category=self.category_1))
     ClientPriceFactory.create_batch(3)
Ejemplo n.º 7
0
    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,
            [])
Ejemplo n.º 8
0
 def setUp(self):
     super().setUp()
     self.client_1 = ClientFactory()
     physician = AccountFactory(
         client=self.client_1,
         user=self.user,
         role=RoleFactory(priority=RolePriority.PHYSICIAN.value))
     self.category_1, self.category_2, self.category_3 = CategoryFactory.create_batch(
         3)
     device_1 = DeviceFactory(
         client=self.client_1,
         product=ProductFactory(category=self.category_1))
     device_2 = DeviceFactory(
         client=self.client_1,
         product=ProductFactory(category=self.category_2))
     device_3 = DeviceFactory(
         client=self.client_1,
         product=ProductFactory(category=self.category_3))
     rep_case = RepCaseFactory(client=self.client_1, physician=physician)
     ItemFactory(device=device_1, rep_case=rep_case, is_used=True)
     ItemFactory(device=device_2, rep_case=rep_case, is_used=True)
     ItemFactory(device=device_3, rep_case=RepCaseFactory(), is_used=True)
     self.path = reverse('api:hospital:tracker:app:categories',
                         args=(self.client_1.id, ))