def test_group_linkers(self): se = sl_models.ServiceEvent.objects.first() g_01 = create_group() g_02 = create_group() gl_01 = sl_utils.create_group_linker(group=g_01) gl_01_name = gl_01.name with self.assertRaises(IntegrityError): sl_models.GroupLinker.objects.create(name=gl_01_name, group=g_01) gl_02 = sl_utils.create_group_linker(group=g_02) sl_utils.create_group_linker_instance(group_linker=gl_01, service_event=se) with self.assertRaises(IntegrityError): sl_models.GroupLinkerInstance.objects.create(group_linker=gl_01, service_event=se) sl_utils.create_group_linker_instance(group_linker=gl_02, service_event=se) self.assertEqual(2, len(se.grouplinkerinstance_set.all())) self.assertTrue(gl_01_name in str(gl_01))
def setUp(self): self.tests = [] self.unit = qa_utils.create_unit() self.unit_group = UnitGroup.objects.create(name="test group") self.unit_group.units.add(self.unit) self.group = create_group() user = create_user() user.groups.add(self.group) user.email = "*****@*****.**" user.save() self.recipients = RecipientGroup.objects.create(name="test group") self.recipients.groups.add(self.group) self.inactive_user = models.User.objects.create_user( 'inactive', '*****@*****.**', 'password') self.inactive_user.groups.add(self.group) self.inactive_user.is_active = False self.inactive_user.save() # delete defaults schedules to make counting easier Schedule.objects.all().delete()
def setUp(self): self.user = create_user(is_superuser=True, uname='user', pwd='pwd') self.client.login(username='******', password='******') self.u_1 = qa_utils.create_unit() self.u_2 = qa_utils.create_unit() self.f_1 = qa_utils.create_frequency() self.f_2 = qa_utils.create_frequency() self.tl_1 = qa_utils.create_test_list() self.tl_2 = qa_utils.create_test_list() self.t_1 = qa_utils.create_test() self.t_2 = qa_utils.create_test() qa_utils.create_test_list_membership(test_list=self.tl_1, test=self.t_1) qa_utils.create_test_list_membership(test_list=self.tl_1, test=self.t_2) self.g_1 = create_group() self.g_2 = create_group() self.tl_ct = ContentType.objects.get(model='testlist') self.tlc_ct = ContentType.objects.get(model='testlistcycle') self.utc_1 = qa_utils.create_unit_test_collection( unit=self.u_1, test_collection=self.tl_1, assigned_to=self.g_1, frequency=self.f_1 ) self.utc_2 = qa_utils.create_unit_test_collection( unit=self.u_2, active=False, assigned_to=self.g_2, frequency=self.f_2 ) self.url_list = reverse( 'admin:%s_%s_changelist' % ( qa_models.UnitTestCollection._meta.app_label, qa_models.UnitTestCollection._meta.model_name ) ) self.url_add = reverse( 'admin:%s_%s_add' % ( qa_models.UnitTestCollection._meta.app_label, qa_models.UnitTestCollection._meta.model_name ) ) self.url_change = reverse( 'admin:%s_%s_change' % ( qa_models.UnitTestCollection._meta.app_label, qa_models.UnitTestCollection._meta.model_name ), args=[self.utc_1.id] )
def create_group_linker(group=None, name=None): if group is None: group = create_group() if name is None: name = 'group_linker_%04d' % get_next_id( models.GroupLinker.objects.order_by('id').last()) gl, _ = models.GroupLinker.objects.get_or_create(group=group, name=name) return gl
def test_admin_unittestcollection(self): if not utils.exists('auth', 'Group', 'name', objects['Group']['name']): create_group(name=objects['Group']['name']) if not utils.exists('units', 'Unit', 'name', objects['Modality']['name']): utils.create_unit(name=objects['Modality']['name'], number=objects['Unit']['number']) if not utils.exists('qa', 'Frequency', 'name', objects['Frequency']['name']): utils.create_frequency(name=objects['Frequency']['name']) if not utils.exists('qa', 'TestList', 'name', objects['TestList']['name']): utils.create_test_list(name=objects['TestList']['name']) self.load_admin() self.click_by_link_text("Assign Test Lists to Units") self.click_by_link_text('ADD UNIT TEST COLLECTION') self.wait.until(e_c.presence_of_element_located((By.ID, 'id_unit'))) self.select_by_index("id_unit", 1) self.select_by_index("id_frequency", 1) self.select_by_index("id_assigned_to", 0) self.select_by_index("id_content_type", 1) self.driver.find_element_by_css_selector( '#id_visible_to_from > option:nth-child(1)').click() self.driver.find_element_by_css_selector( '#id_visible_to_add_link').click() time.sleep(2) self.driver.find_element_by_id( 'select2-generic_object_id-container').click() self.driver.find_element_by_id( 'select2-generic_object_id-container').click() self.driver.find_element_by_name('_save').click() self.wait_for_success()
def create_unit_test_info(unit=None, test=None, assigned_to=None, ref=None, tol=None, active=True): if unit is None: unit = create_unit() if test is None: test = create_test() if assigned_to is None: assigned_to = create_group() uti = models.UnitTestInfo( unit=unit, test=test, reference=ref, tolerance=tol, assigned_to=assigned_to, active=active ) uti.save() return uti
def setUp(self): self.factory = RequestFactory() self.view = views.UpdateServiceEvent.as_view() self.default_ses = sl_utils.create_service_event_status( is_default=True) self.approved_ses = sl_utils.create_service_event_status( is_review_required=False, rts_qa_must_be_reviewed=True) sl_utils.create_service_event_status() qa_utils.create_status(is_default=True) now = timezone.now() self.u_1 = qa_utils.create_unit(name='u_1') self.sa_1 = sl_utils.create_service_area(name='sa_1') self.usa_1 = sl_utils.create_unit_service_area(unit=self.u_1, service_area=self.sa_1) self.tl_1 = qa_utils.create_test_list(name='tl_1') self.tli_1_1 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_1, test_collection=self.tl_1), test_list=self.tl_1, work_completed=now - timezone.timedelta(hours=1)) self.tli_1_2 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_1, test_collection=self.tl_1), test_list=self.tl_1, work_completed=now) self.se_1 = sl_utils.create_service_event(unit_service_area=self.usa_1) self.u_2 = qa_utils.create_unit(name='u_2') self.sa_2 = sl_utils.create_service_area(name='sa_2') self.usa_2 = sl_utils.create_unit_service_area(unit=self.u_2, service_area=self.sa_2) self.tl_2 = qa_utils.create_test_list(name='tl_2') self.tli_2_1 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_2, test_collection=self.tl_2), test_list=self.tl_2, work_completed=now - timezone.timedelta(hours=1)) self.tli_2_2 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_2, test_collection=self.tl_2), test_list=self.tl_2, work_completed=now) self.se_2 = sl_utils.create_service_event(unit_service_area=self.usa_2) self.url = reverse('sl_new') self.user = create_user(is_superuser=True) self.client.login(username='******', password='******') perm = Permission.objects.get(codename='can_have_hours') user_can_hours = User.objects.get(username='******') user_can_hours.user_permissions.add(perm) user_group_has_hours = create_user(uname='in_group_with_hours') group_has_hours = create_group(name='can_have_hours') group_has_hours.permissions.add(perm) user_group_has_hours.groups.add(group_has_hours) sl_utils.create_third_party() group_linked = create_group(name='linked') user_group_linked = create_user(uname='user_in_group_linked') user_group_linked.groups.add(group_linked) self.gl_1 = sl_utils.create_group_linker(group=group_linked) self.part = sl_utils.create_part(add_storage=True) self.st = sl_utils.create_service_type() self.se = sl_utils.create_service_event( unit_service_area=self.usa_1, service_status=self.default_ses, service_type=self.st) self.url = reverse('sl_edit', kwargs={"pk": self.se.pk}) self.data = { 'datetime_service': format_datetime(timezone.now()), 'service_status': self.default_ses.id, 'service_type': self.st.id, 'is_review_required': 0, 'safety_precautions': 'safety_precautions', 'problem_description': 'problem_description', 'service_area_field': self.se.unit_service_area.service_area.id, 'unit_field': self.se.unit_service_area.unit.id, 'unit_field_fake': self.se.unit_service_area.unit.id, 'qafollowup_notes': 'qafollowup_notes', 'test_list_instance_initiated_by': self.tli_1_1.id, 'duration_lost_time': '0100', 'duration_service_time': '0100', 'hours-INITIAL_FORMS': 0, 'hours-MAX_NUM_FORMS': 1000, 'hours-TOTAL_FORMS': 0, 'hours-MIN_NUM_FORMS': 0, 'parts-INITIAL_FORMS': 0, 'parts-MAX_NUM_FORMS': 1000, 'parts-TOTAL_FORMS': 0, 'parts-MIN_NUM_FORMS': 0, 'rtsqa-INITIAL_FORMS': 0, 'rtsqa-MAX_NUM_FORMS': 1000, 'rtsqa-TOTAL_FORMS': 0, 'rtsqa-MIN_NUM_FORMS': 0, }
def setUp(self): u = create_user(is_superuser=True, uname='user', pwd='pwd') g = create_group() u.groups.add(g) u.save() self.client.login(username='******', password='******')
def setUp(self): self.factory = RequestFactory() self.view = views.CreateServiceEvent.as_view() self.default_ses = sl_utils.create_service_event_status( is_default=True) sl_utils.create_service_event_status() qa_utils.create_status(is_default=True) now = timezone.now() self.u_1 = qa_utils.create_unit(name='u_1') self.sa_1 = sl_utils.create_service_area(name='sa_1') self.usa_1 = sl_utils.create_unit_service_area(unit=self.u_1, service_area=self.sa_1) self.tl_1 = qa_utils.create_test_list(name='tl_1') self.tli_1_1 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_1, test_collection=self.tl_1), test_list=self.tl_1, work_completed=now - timezone.timedelta(hours=1)) self.tli_1_2 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_1, test_collection=self.tl_1), test_list=self.tl_1, work_completed=now) self.se_1 = sl_utils.create_service_event(unit_service_area=self.usa_1) self.u_2 = qa_utils.create_unit(name='u_2') self.sa_2 = sl_utils.create_service_area(name='sa_2') self.usa_2 = sl_utils.create_unit_service_area(unit=self.u_2, service_area=self.sa_2) self.tl_2 = qa_utils.create_test_list(name='tl_2') self.tli_2_1 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_2, test_collection=self.tl_2), test_list=self.tl_2, work_completed=now - timezone.timedelta(hours=1)) self.tli_2_2 = qa_utils.create_test_list_instance( unit_test_collection=qa_utils.create_unit_test_collection( unit=self.u_2, test_collection=self.tl_2), test_list=self.tl_2, work_completed=now) self.se_2 = sl_utils.create_service_event(unit_service_area=self.usa_2) self.url = reverse('sl_new') self.url_delete = reverse('se_delete') self.user = create_user(is_superuser=True) self.client.login(username='******', password='******') perm = Permission.objects.get(codename='can_have_hours') user_can_hours = User.objects.get(username='******') user_can_hours.user_permissions.add(perm) user_group_has_hours = create_user(uname='in_group_with_hours') group_has_hours = create_group(name='can_have_hours') group_has_hours.permissions.add(perm) user_group_has_hours.groups.add(group_has_hours) sl_utils.create_third_party() group_linked = create_group(name='linked') user_group_linked = create_user(uname='user_in_group_linked') user_group_linked.groups.add(group_linked) self.gl_1 = sl_utils.create_group_linker(group=group_linked) self.part = sl_utils.create_part(add_storage=True) self.st = sl_utils.create_service_type() self.sto = sl_utils.create_storage(quantity=2)