Example #1
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'), [])
Example #2
0
 def setUp(self):
     super(AccountsInlineAdminTestCase, self).setUp()
     self.log_in_master_admin()
     self.client = ClientFactory(name='NS Global')
     self.client2 = ClientFactory(name='NS Vietnam')
     self.role = RoleFactory(name='Physician')
     self.user1 = UserFactory(email='*****@*****.**')
     self.user2 = UserFactory(email='*****@*****.**')
     self.specialty_1, self.specialty_2 = SpecialtyFactory.create_batch(2)
Example #3
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)]}
        })
Example #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)