Esempio n. 1
0
    def setUp(self):

        self.unit1 = qa_utils.create_unit(name="unit1", number=1)
        self.unit2 = qa_utils.create_unit(name="unit2", number=2)
        self.usa1 = utils.create_unit_service_area(unit=self.unit1)
        self.usa2 = utils.create_unit_service_area(unit=self.unit2)

        self.se1 = utils.create_service_event(unit_service_area=self.usa1,
                                              is_review_required=True)
        self.se2 = utils.create_service_event(unit_service_area=self.usa2,
                                              is_review_required=False)

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

        self.group = qa_utils.create_group()
        user = models.User.objects.latest('pk')
        user.is_active = True
        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.unit1 = qa_utils.create_unit(name="unit1", number=1)
        self.unit2 = qa_utils.create_unit(name="unit2", number=2)

        self.fault1 = utils.create_fault(unit=self.unit1)
        self.fault2 = utils.create_fault(unit=self.unit2)

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

        self.group = qa_utils.create_group()
        self.user = models.User.objects.latest('pk')
        self.user.is_active = True
        self.user.groups.add(self.group)
        self.user.email = "*****@*****.**"
        self.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()
Esempio n. 3
0
    def setUp(self):

        super().setUp()

        self.unit = utils.create_unit()
        self.group = utils.create_group()
        for p in Permission.objects.all():
            self.group.permissions.add(p)
        self.user.groups.add(self.group)
        self.test_list = utils.create_test_list()

        self.tnum_1 = utils.create_test(name="test1")
        self.tnum_2 = utils.create_test(name="test2")
        self.tcomp = utils.create_test(name="testc",
                                       test_type=models.COMPOSITE)
        self.tcomp.calculation_procedure = "result = test1 + test2 + 2"
        self.tcomp.save()

        self.tdate = utils.create_test(name="testdate", test_type=models.DATE)
        self.tdatetime = utils.create_test(name="testdatetime",
                                           test_type=models.DATETIME)

        self.tmult = utils.create_test(name="testmult",
                                       choices="choicea,choiceb",
                                       test_type=models.MULTIPLE_CHOICE)
        self.tstring = utils.create_test(name="teststring",
                                         test_type=models.STRING)
        self.tstringcomp = utils.create_test(name="teststringcomp",
                                             test_type=models.STRING_COMPOSITE)
        self.tstringcomp.calculation_procedure = "teststringcomp = teststring + testmult"
        self.tstringcomp.save()

        all_tests = [
            self.tnum_1,
            self.tnum_2,
            self.tcomp,
            self.tdate,
            self.tdatetime,
            self.tmult,
            self.tstring,
            self.tstringcomp,
        ]

        for o, t in enumerate(all_tests):
            utils.create_test_list_membership(self.test_list, t, order=o)

        self.utc = utils.create_unit_test_collection(
            unit=self.unit, test_collection=self.test_list)

        self.utc.visible_to.add(self.group)
        self.url = reverse("perform_qa", kwargs={'pk': self.utc.pk})
        self.status = models.TestInstanceStatus.objects.create(
            name="foo",
            slug="foo",
            is_default=True,
        )

        sl_utils.create_service_event_status(is_default=True)
        sl_utils.create_unit_service_area(self.utc.unit)
        sl_utils.create_service_type()
Esempio n. 4
0
    def setUp(self):

        self.unit1 = qa_utils.create_unit(name="unit1", number=1)
        self.unit2 = qa_utils.create_unit(name="unit2", number=2)
        self.usa1 = utils.create_unit_service_area(unit=self.unit1)
        self.usa2 = utils.create_unit_service_area(unit=self.unit2)

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

        self.group = qa_utils.create_group()
        user = models.User.objects.latest('pk')
        user.groups.add(self.group)
        user.is_active = True
        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()

        self.notice = ServiceEventReviewNotice.objects.create(
            recipients=self.recipients,
            notification_type=ServiceEventReviewNotice.UNREVIEWED,
            time="0:00",
        )
        # delete defaults schedules to make counting easier
        Schedule.objects.all().delete()
Esempio n. 5
0
def create_fault_review_group(group=None, required=True):

    group = group or qa_utils.create_group()
    return models.FaultReviewGroup.objects.create(
        group=group,
        required=required,
    )
Esempio n. 6
0
    def test_review_bulk(self):
        group = qa_utils.create_group("group")
        self.user.groups.add(group)
        frg = FaultReviewGroup.objects.create(group=group)

        f1 = utils.create_fault()
        f2 = utils.create_fault()
        review_url = reverse("fault_bulk_review")
        data = {'faults': [f1.pk, f2.pk]}
        resp = self.client.post(review_url, data=data)
        assert resp.status_code == 200
        assert resp.json()['ok']
        f1.refresh_from_db()
        f2.refresh_from_db()
        assert f1.faultreviewinstance_set.count() > 0
        assert f1.faultreviewinstance_set.first().fault_review_group == frg
        assert f2.faultreviewinstance_set.count() > 0
    def test_email_not_sent_to_group_for_unit(self):
        """Main group is not included in notification, only the new group, so only one email
        should be sent to the new user"""

        group2 = qa_utils.create_group(name="group2")
        rg = RecipientGroup.objects.create(name='group2')
        rg.groups.add(group2)
        FaultNotice.objects.create(
            notification_type=FaultNotice.LOGGED,
            recipients=rg,
            units=self.unit_group,
        )
        user2 = create_user(uname="user2")
        user2.email = "*****@*****.**"
        user2.save()
        user2.groups.add(group2)
        utils.create_fault(unit=self.unit)
        assert len(mail.outbox) == 1
        assert mail.outbox[0].recipients() == ['*****@*****.**']
Esempio n. 8
0
    def test_email_not_sent_to_group_for_unit(self):
        """Main group is not included in notification, only the new group, so only one email
        should be sent to the new user"""

        group2 = utils.create_group(name="group2")
        rg = RecipientGroup.objects.create(name='group2')
        rg.groups.add(group2)
        QCCompletedNotice.objects.create(
            notification_type=QCCompletedNotice.TOLERANCE,
            recipients=rg,
            units=self.unit_group,
        )
        user2 = utils.create_user(uname="user2")
        user2.email = "*****@*****.**"
        user2.save()
        user2.groups.add(group2)
        signals.testlist_complete.send(sender=self,
                                       instance=self.test_list_instance,
                                       created=True)
        assert len(mail.outbox) == 1
        assert mail.outbox[0].recipients() == ['*****@*****.**']
Esempio n. 9
0
def create_service_event_schedule(service_event_template=None,
                                  unit_service_area=None,
                                  frequency=None,
                                  assigned_to=None):

    if service_event_template is None:
        service_event_template = create_service_event_template()

    if unit_service_area is None:
        unit_service_area = create_unit_service_area()

    if assigned_to is None:
        assigned_to = qa_utils.create_group()

    ses, _ = models.ServiceEventSchedule.objects.get_or_create(
        service_event_template=service_event_template,
        unit_service_area=unit_service_area,
        assigned_to=assigned_to,
        frequency=frequency,
    )

    return ses