def test_unique_together(self): v_01 = qa_utils.create_vendor() tp_01 = sl_utils.create_third_party(vendor=v_01) tp_01_first_name = tp_01.first_name tp_01_last_name = tp_01.last_name with self.assertRaises(IntegrityError): sl_models.ThirdParty.objects.create(vendor=v_01, first_name=tp_01_first_name, last_name=tp_01_last_name)
def create_third_party(vendor=None, first_name=None, last_name=None): if vendor is None: vendor = qa_utils.create_vendor() if first_name is None: first_name = 'first_name_%04d' % get_next_id( models.ThirdParty.objects.order_by('id').last()) if last_name is None: last_name = 'last_name_%04d' % get_next_id( models.ThirdParty.objects.order_by('id').last()) tp, _ = models.ThirdParty.objects.get_or_create(vendor=vendor, first_name=first_name, last_name=last_name) return tp
def test_admin_unit(self): if not utils.exists('units', 'UnitType', 'name', objects['UnitType']['name']): utils.create_unit_type(name=objects['UnitType']['name'], vendor=utils.create_vendor( objects['UnitType']['vendor'])) if not utils.exists('units', 'Modality', 'name', objects['Modality']['name']): utils.create_modality(name=objects['Modality']['name']) sl_utils.create_service_area() self.load_admin() self.click_by_link_text("Units") self.click_by_link_text("ADD UNIT") self.wait.until(e_c.presence_of_element_located((By.ID, 'id_name'))) self.driver.find_element_by_id('id_name').send_keys( objects['Unit']['name']) self.driver.find_element_by_id('id_number').send_keys( objects['Unit']['number']) self.driver.find_element_by_id('id_date_acceptance').send_keys( objects['Unit']['date_acceptance']) self.driver.find_element_by_css_selector( '#id_service_areas_add_all_link').click() self.select_by_index("id_type", 1) # self.driver.find_element_by_id('id_modalities_add_all_link').click() # self.driver.find_element_by_id('id_hours_monday').send_keys('800') # self.driver.find_element_by_id('id_hours_tuesday').send_keys('800') # self.driver.find_element_by_id('id_hours_wednesday').send_keys('800') # self.driver.find_element_by_id('id_hours_thursday').send_keys('800') # self.driver.find_element_by_id('id_hours_friday').send_keys('800') # self.driver.find_element_by_id('id_hours_saturday').send_keys('800') # self.driver.find_element_by_id('id_hours_sunday').send_keys('800') self.driver.find_element_by_name('_save').click() self.wait_for_success()
def test_nk(self): v = utils.create_vendor() assert v.natural_key() == (v.name, )
def test_get_by_nk(self): v = utils.create_vendor() assert models.Vendor.objects.get_by_natural_key(v.name).pk == v.pk