Exemplo n.º 1
0
    def get_valid_data():
        obj = CommitteeFactory.build()
        branch = BranchFactory()
        division = DivisionFactory()
        user = UserFactory()

        return {
            'name': obj.name,
            'branch': branch.pk,
            'division': division.pk,
            'is_dfo_chair': obj.is_dfo_chair,
            'meeting_frequency': obj.meeting_frequency,
            'main_actions': obj.main_actions,
            'last_modified': obj.last_modified,
            'last_modified_by': user.pk,
            'dfo_liaison': [
                user.pk,
            ],
            'other_dfo_branch': [
                branch.pk,
            ]
        }
Exemplo n.º 2
0
    def create_test_data(self):
        self.reg = RegionFactory()
        self.bra = BranchFactory(region=self.reg)
        self.div_1 = DivisionFactory(name="Div 1", branch=self.bra)
        self.div_2 = DivisionFactory(name="Div 2", branch=self.bra)
        self.sec_1 = SectionFactory(division=self.div_1)
        self.sec_2 = SectionFactory(division=self.div_2)

        self.fy_current = shared_models.FiscalYear.objects.get(pk=2020)
        self.fy_previous = shared_models.FiscalYear.objects.get(pk=2018)

        self.prj_1 = FactoryFloor.ProjectFactory(project_title="Test Project",
                                                 year=self.fy_current,
                                                 section=self.sec_1)
        self.prj_2 = FactoryFloor.ProjectFactory(
            project_title="Test Project 2",
            year=self.fy_previous,
            section=self.sec_2)
        self.om_1 = FactoryFloor.OMCostTravelFactory(project=self.prj_1)
        self.om_2 = FactoryFloor.OMCostEquipmentFactory(project=self.prj_2)
        # create two DFO and one non-DFO staff for columns 5 and 6
        FactoryFloor.IndeterminateStaffFactory(project=self.prj_1, lead=True)
        FactoryFloor.IndeterminateStaffFactory(project=self.prj_1)
        FactoryFloor.StudentStaffFactory(project=self.prj_1)
Exemplo n.º 3
0
 def test_m2m_branches(self):
     # a `default_reviewer` that is attached to a given `branch` should be accessible by the m2m field name `branches`
     branch = BranchFactory()
     self.instance.branches.add(branch)
     self.assertEqual(self.instance.branches.count(), 1)
     self.assertIn(branch, self.instance.branches.all())
Exemplo n.º 4
0
 def get_valid_data():
     return {
         'user': UserFactory().id,
         'sections': SectionFactory().id,
         'branches': BranchFactory().id,
     }
Exemplo n.º 5
0
    def test_get_requests_with_managerial_access(self):
        section1 = SectionFactory(head=UserFactory(), admin=UserFactory())
        division = section1.division
        division.head = UserFactory()
        division.admin = UserFactory()
        division.save()
        branch = division.branch
        branch.admin = UserFactory()
        branch.head = UserFactory()
        branch.save()
        sector = branch.sector
        sector.admin = UserFactory()
        sector.head = UserFactory()
        sector.save()
        region = sector.region
        region.head = UserFactory()
        region.admin = UserFactory()
        region.save()
        # another section within division
        section2 = SectionFactory(head=UserFactory(), admin=UserFactory(), division=division)
        # another section within branch
        d = DivisionFactory(head=UserFactory(), admin=UserFactory(), branch=branch)
        section3 = SectionFactory(head=UserFactory(), admin=UserFactory(), division=d)
        # another section within region
        b = BranchFactory(head=UserFactory(), admin=UserFactory(), sector=sector)
        d = DivisionFactory(head=UserFactory(), admin=UserFactory(), branch=b)
        section4 = SectionFactory(head=UserFactory(), admin=UserFactory(), division=d)

        # create 4 trip requests, one under each section
        r1 = FactoryFloor.TripRequestFactory(section=section1)
        r2 = FactoryFloor.TripRequestFactory(section=section2)
        r3 = FactoryFloor.TripRequestFactory(section=section3)
        r4 = FactoryFloor.TripRequestFactory(section=section4)

        # start high: region head should see all four requests
        self.assertEqual(utils.get_requests_with_managerial_access(region.head).count(), 4)
        self.assertEqual(utils.get_requests_with_managerial_access(region.admin).count(), 4)
        for r in [r1, r2, r3, r4]:
            self.assertIn(r, utils.get_requests_with_managerial_access(region.head))
            self.assertIn(r, utils.get_requests_with_managerial_access(region.admin))

        # branch head should see all 3 requests
        self.assertEqual(utils.get_requests_with_managerial_access(branch.head).count(), 3)
        self.assertEqual(utils.get_requests_with_managerial_access(branch.admin).count(), 3)
        for r in [r1, r2, r3]:
            self.assertIn(r, utils.get_requests_with_managerial_access(branch.head))
            self.assertIn(r, utils.get_requests_with_managerial_access(branch.admin))

        # division head should see all 2 requests
        self.assertEqual(utils.get_requests_with_managerial_access(division.head).count(), 2)
        self.assertEqual(utils.get_requests_with_managerial_access(division.admin).count(), 2)
        for r in [r1, r2]:
            self.assertIn(r, utils.get_requests_with_managerial_access(division.head))
            self.assertIn(r, utils.get_requests_with_managerial_access(division.admin))

        # section head should see all 1 requests
        self.assertEqual(utils.get_requests_with_managerial_access(section1.head).count(), 1)
        self.assertEqual(utils.get_requests_with_managerial_access(section1.admin).count(), 1)
        for r in [r1]:
            self.assertIn(r, utils.get_requests_with_managerial_access(section1.head))
            self.assertIn(r, utils.get_requests_with_managerial_access(section1.admin))
Exemplo n.º 6
0
 def other_dfo_branch(self, create, extracted, **kwargs):
     if create:
         branch = BranchFactory()
         self.other_dfo_branch.set((branch, ))