def test_perform_and_review(self):
        """Ensure that we can go through a full perform->review cycle"""

        utils.create_status(name="reviewed",
                            slug="reviewed",
                            is_default=False,
                            requires_review=False)
        self.fill_testlist()
        self.click("submit-qa")
        self.wait.until(
            e_c.presence_of_element_located((By.CLASS_NAME, 'alert-success')))

        self.open("/qc/session/unreviewed/")
        time.sleep(0.2)

        self.click_by_link_text("Review")
        self.select_by_text("bot-status-select", "reviewed")

        self.send_keys("id_comment", "testlistcomment")
        self.click("post-comment")
        time.sleep(0.2)
        assert models.Comment.objects.count() == 1

        assert models.TestListInstance.objects.unreviewed().count() == 1
        self.click("submit-review")
        self.wait.until(
            e_c.presence_of_element_located((By.CLASS_NAME, 'alert-success')))
        assert models.TestListInstance.objects.unreviewed().count() == 0
Beispiel #2
0
    def test_qa_urls(self):

        sl_utils.create_service_event_status(is_default=True)
        qa_utils.create_status(is_default=True)
        se = sl_utils.create_service_event()
        u = qa_utils.create_unit()
        utc = qa_utils.create_unit_test_collection(unit=u)
        tli = qa_utils.create_test_list_instance(unit_test_collection=utc)

        url_names_200 = (
            ('sl_dash', {}, ''),
            ('sl_new', {}, ''),
            ('sl_edit', {
                'pk': se.id
            }, ''),
            ('sl_details', {
                'pk': se.id
            }, ''),
            ('sl_list_all', {}, ''),
            ('rtsqa_list_for_event', {
                'se_pk': se.id
            }, ''),
            ('se_searcher', {}, '?q=%d&unit_id=%d' % (se.id, u.id)),
            ('tli_select', {
                'pk': utc.id,
                'form': 'a_form'
            }, ''),
            ('tli_statuses', {}, '?tli_id=%d' % tli.id),
            ('unit_sa_utc', {}, '?unit_id=%d' % u.id),
            ('err', {}, ''),
            ('sl_unit_new', {}, ''),
            ('sl_unit_view_se', {}, ''),
            ('se_down_time', {}, ''),
            ('handle_unit_down_time', {}, ''),
        )

        url_names_404 = (
            # Test urls that expect kwargs when not given any
            # (reverse should render url for use in templates, but return 404)
            ('sl_details', {}, ''),
            ('tli_select', {}, ''),
            ('se_searcher', {}, ''),
            ('tli_statuses', {}, ''),
            ('unit_sa_utc', {}, ''),
        )

        for url, kwargs, q in url_names_200:
            self.assertTrue(self.returns_code(reverse(url, kwargs=kwargs) + q))

        for url, kwargs, q in url_names_404:
            self.assertTrue(
                self.returns_code(reverse(url, kwargs=kwargs) + q, code=404))
    def setUp(self):

        super().setUp()

        self.unreviewed = utils.create_status(name="Unreviewed",
                                              slug="unreviewed")
        self.reviewed = utils.create_status(name="Approved",
                                            slug="approved",
                                            is_default=False,
                                            requires_review=False)
        utils.create_test_instance()

        self.url = "/qc/session/unreviewed/"
Beispiel #4
0
    def setUp(self):

        self.tests = []

        self.ref = models.Reference(type=models.NUMERICAL, value=100.)
        self.tol = models.Tolerance(type=models.PERCENT, act_low=-3, tol_low=-2, tol_high=2, act_high=3)
        self.values = [None, None, 96, 97, 100, 100]

        self.statuses = [utils.create_status(name="status%d" % x, slug="status%d" % x) for x in range(len(self.values))]

        self.test_list = utils.create_test_list()
        for i in range(6):
            test = utils.create_test(name="name%d" % i)
            self.tests.append(test)
            utils.create_test_list_membership(self.test_list, test)

        self.unit_test_collection = utils.create_unit_test_collection(test_collection=self.test_list)

        self.test_list_instance = self.create_test_list_instance()

        self.group = models.Group.objects.get(pk=1)
        user = models.User.objects.get(pk=1)
        user.groups.add(self.group)
        user.email = "*****@*****.**"
        user.save()
Beispiel #5
0
    def setUp(self):

        self.tests = []

        self.ref = models.Reference(type=models.NUMERICAL, value=100.)
        self.tol = models.Tolerance(type=models.PERCENT,
                                    act_low=-3,
                                    tol_low=-2,
                                    tol_high=2,
                                    act_high=3)
        self.values = [None, None, 96, 97, 100, 100]

        self.statuses = [
            utils.create_status(name="status%d" % x, slug="status%d" % x)
            for x in range(len(self.values))
        ]

        self.test_list = utils.create_test_list()
        for i in range(6):
            test = utils.create_test(name="name%d" % i)
            self.tests.append(test)
            utils.create_test_list_membership(self.test_list, test)

        self.unit_test_collection = utils.create_unit_test_collection(
            test_collection=self.test_list)

        self.test_list_instance = self.create_test_list_instance()

        self.group = models.Group.objects.get(pk=1)
        user = models.User.objects.get(pk=1)
        user.groups.add(self.group)
        user.email = "*****@*****.**"
        user.save()
Beispiel #6
0
    def setUp(self):

        self.tests = []

        self.ref = models.Reference(type=models.NUMERICAL, value=100.)
        self.tol = models.Tolerance(type=models.PERCENT,
                                    act_low=-3,
                                    tol_low=-2,
                                    tol_high=2,
                                    act_high=3)
        self.ref.created_by = utils.create_user()
        self.tol.created_by = utils.create_user()
        self.ref.modified_by = utils.create_user()
        self.tol.modified_by = utils.create_user()
        self.values = [None, None, 96, 97, 100, 100]

        self.statuses = [
            utils.create_status(name="status%d" % x, slug="status%d" % x)
            for x in range(len(self.values))
        ]

        self.test_list = utils.create_test_list()
        for i in range(6):
            test = utils.create_test(name="name%d" % i)
            self.tests.append(test)
            utils.create_test_list_membership(self.test_list, test)

        self.testlist_group = TestListGroup.objects.create(name="test group")
        self.testlist_group.test_lists.add(self.test_list)

        self.unit_test_collection = utils.create_unit_test_collection(
            test_collection=self.test_list)

        self.unit_group = UnitGroup.objects.create(name="test group")
        self.unit_group.units.add(self.unit_test_collection.unit)

        self.test_list_instance = self.create_test_list_instance()

        self.group = models.Group.objects.latest('pk')
        user = models.User.objects.latest('pk')
        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()
Beispiel #7
0
    def test_unreviewed_rtsqa(self):

        ses_approved = sl_utils.create_service_event_status(
            name='Approved',
            is_review_required=False,
            rts_qa_must_be_reviewed=True)

        test_status = qa_utils.create_status()
        tl = qa_utils.create_test_list()
        t = qa_utils.create_test()
        qa_utils.create_test_list_membership(tl, t)

        tli_unreviewed = qa_utils.create_test_list_instance(test_list=tl)
        qa_utils.create_test_instance(
            tli_unreviewed,
            unit_test_info=qa_utils.create_unit_test_info(unit=self.u_1),
            status=test_status)

        data = {
            'datetime_service': format_datetime(timezone.now()),
            'unit_field': self.u_1.id,
            'service_area_field': self.sa_1.id,
            'service_type': self.st.id,
            'problem_description': 'problem',
            'service_status': ses_approved.id,
            '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': 1,
            'rtsqa-MIN_NUM_FORMS': 0,
            'rtsqa-0-all_reviewed': tli_unreviewed.all_reviewed,
            'rtsqa-0-unit_test_collection':
            tli_unreviewed.unit_test_collection.id,
            'rtsqa-0-test_list_instance': tli_unreviewed.id,
            'rtsqa-0-id': '',
        }

        response = self.client.post(self.url, data=data)
        self.assertTrue(
            'service_status' in response.context_data['form'].errors)

        data['rtsqa-0-all_reviewed'] = ''
        data['rtsqa-0-test_list_instance'] = ''

        response = self.client.post(self.url, data=data)
        self.assertTrue(
            'service_status' in response.context_data['form'].errors)
Beispiel #8
0
    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,
        }
Beispiel #9
0
    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)