Exemplo n.º 1
0
    def setUp(self):
        super(AuditTestCaseMixin, self).setUp()
        EmailTemplate.objects.get_or_create(name='audit/staff_member/invite')
        EmailTemplate.objects.get_or_create(
            name='audit/engagement/submit_to_auditor')
        EmailTemplate.objects.get_or_create(
            name='audit/engagement/reported_by_auditor')

        GroupWrapper.invalidate_instances()

        self.auditor_firm = AuditPartnerFactory()

        self.auditor = UserFactory(
            auditor=True,
            partner_firm=self.auditor_firm,
            profile__countries_available=[connection.tenant])
        self.unicef_user = UserFactory(
            first_name='UNICEF User',
            unicef_user=True,
            profile__countries_available=[connection.tenant])
        self.unicef_focal_point = UserFactory(
            first_name='UNICEF Audit Focal Point',
            audit_focal_point=True,
            profile__countries_available=[connection.tenant])
        self.usual_user = UserFactory(
            first_name='Unknown user',
            profile__countries_available=[connection.tenant])
Exemplo n.º 2
0
    def test_signal(self):
        self.firm = AuditPartnerFactory()
        user = BaseUserFactory()
        Auditor.invalidate_cache()

        staff_member = AuditorStaffMember.objects.create(
            auditor_firm=self.firm, user=user)

        self.assertIn(Auditor.name,
                      staff_member.user.groups.values_list('name', flat=True))
Exemplo n.º 3
0
    def test_signal(self):
        auditor_firm = AuditPartnerFactory()
        staff_member = auditor_firm.staff_members.first()
        staff_member.user.profile.countries_available = []
        engagement = EngagementFactory(staff_members=[],
                                       agreement__auditor_firm=auditor_firm)

        engagement.staff_members.add(staff_member)

        self.assertSequenceEqual(
            staff_member.user.profile.countries_available.all(),
            [Country.objects.get(schema_name=connection.schema_name)])
        self.assertEqual(len(mail.outbox), 1)
        mail.outbox = []

        engagement = EngagementFactory(staff_members=[],
                                       agreement__auditor_firm=auditor_firm)

        engagement.staff_members.add(staff_member)
        self.assertEqual(len(mail.outbox), 1)
        mail.outbox = []
Exemplo n.º 4
0
 def setUp(self):
     super(TestAuditorFirmViewSet, self).setUp()
     self.second_auditor_firm = AuditPartnerFactory()