Example #1
0
    def test_coach_project_several_teams(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_STARTED, start=None)

        FakeTeamFactory.create(project=project)
        team = FakeTeamFactory.create(project=project)
        relation, _ = ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            project=project,
            consultant=team.coach,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_COACH),
        )

        # ASSERTS
        url, _ = next_project_url(project, relation.consultant.user)
        expected_url = settings.FRONTEND_PROJECT_STEP_PAGE.format(
            **{
                'project_id': project.id,
                'team_id': team.pk,
                'step_id': project.steps.first().pk,
                'section': 'learn'
            })

        self.assertEqual(url, expected_url)
    def test_create_delivery_manager(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        project_settings = project.settings
        project_settings.launch['fix_password'] = '******'
        project_settings.save()

        # DO ACTION
        member = project.add_user_project_delivery_manager(
            self.super_user,
            faker.name(),
            faker.email(),
        )

        # ASSERTS
        self.assertTrue(member.has_perm(
            settings.PROJECT_PERMS_VIEW_PROJECT,
            project,
        ))
        self.assertTrue(member.has_perm(
            settings.PROJECT_PERMS_DELIVERY_MANAGER,
            project,
        ))
        self.assertTrue(member.has_perm(
            settings.PROJECT_PERMS_PROJECT_MANAGER,
            project,
        ))
 def setUpTestData(cls):
     cls.create_super_user(cls)
     request_mock_account.reset()
     request_mock_account.add_mock(
         cls.super_user, is_consultant=False, is_superuser=True)
     cls.project = FakeProjectFactory.create(created_by=cls.super_user)
     cls.team = cls.project.teams.first()
Example #4
0
 def create_consultant_project_role(self, exo_role):
     project = FakeProjectFactory.create(
         status=settings.PROJECT_CH_PROJECT_STATUS_STARTED)
     return FakeConsultantProjectRoleFactory.create(
         consultant=self.consultant,
         project=project,
         exo_role=exo_role,
         visible=True,
         status=settings.RELATION_ROLE_CH_ACTIVE)
 def setUpTestData(cls):
     cls.create_super_user(cls)
     cls.project = FakeProjectFactory.create(created_by=cls.super_user)
     for team in cls.project.teams.all():
         UserProjectRole.objects.create(
             project_role=cls.project.project_roles.get(code=settings.EXO_ROLE_CODE_SPRINT_COACH),
             teams=[team],
             user=cls.get_user(cls))
         for _ in range(3):
             UserProjectRole.objects.create_participant(
                 project=cls.project,
                 teams=[team],
                 name=faker.name(),
                 email=faker.email())
    def test_create_supervisor_no_customer(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING,
            customer=None)
        project_settings = project.settings
        project_settings.launch['fix_password'] = '******'
        project_settings.save()

        # DO ACTION
        member = project.add_user_project_supervisor(
            self.super_user, faker.name(), faker.email())

        # ASSERTS
        self.assertIsNotNone(member)
    def test_create_supervisor_previous_launch(self):
        # PREPARE DATA
        project = FakeProjectFactory.create()
        project_settings = project.settings
        project_settings.launch['fix_password'] = '******'
        project_settings.save()

        # DO ACTION
        member = project.add_user_project_supervisor(self.super_user, faker.name(), faker.email())

        # ASSERTS
        self.assertTrue(member.has_usable_password())
        project.launch(self.super_user)
        member.refresh_from_db()
        self.assertTrue(member.check_password('123456'))
    def test_actives_filter(self):

        project = FakeProjectFactory()
        consultant_1 = FakeConsultantFactory(user__is_active=True)
        consultant_2 = FakeConsultantFactory(user__is_active=True)

        self.assertTrue(consultant_1.user.is_active)
        self.assertTrue(consultant_2.user.is_active)

        # Create another project to check filter
        relation_p_1 = FakeConsultantProjectRoleFactory(
            consultant=consultant_1,
            project=project,
            status=settings.RELATION_ROLE_CH_ACTIVE,
        )
        self.assertIsNotNone(relation_p_1)
        relation_p_2 = FakeConsultantProjectRoleFactory(
            consultant=consultant_2,
            project=project,
            status=settings.RELATION_ROLE_CH_INACTIVE,
        )
        self.assertIsNotNone(relation_p_2)

        # ##
        # Work with self.project
        # ##
        relation_1 = FakeConsultantProjectRoleFactory(
            consultant=consultant_1,
            project=self.project,
            status=settings.RELATION_ROLE_CH_ACTIVE,
        )
        self.assertIsNotNone(relation_1)

        relation_2 = FakeConsultantProjectRoleFactory(
            consultant=consultant_2,
            project=self.project,
            status=settings.RELATION_ROLE_CH_INACTIVE,
        )
        self.assertIsNotNone(relation_2)

        self.assertEqual(self.project.consultants_roles.actives().count(), 1)
        self.assertEqual(ConsultantProjectRole.objects.actives().count(), 2)

        relation_2.activate(consultant_2.user)
        self.assertEqual(self.project.consultants_roles.count(), 2)
        self.assertEqual(self.project.consultants_roles.actives().count(), 2)
        self.assertEqual(ConsultantProjectRole.objects.actives().count(), 3)
        self.assertEqual(ConsultantProjectRole.objects.count(), 4)
Example #9
0
    def test_superuser(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_STARTED)
        FakeTeamFactory.create(project=project)

        # ASSERTS
        url, _ = next_project_url(project, self.super_user)

        expected_url = project.get_absolute_url()

        self.assertEqual(
            url,
            expected_url,
            'Superuser',
        )
    def test_create_supervisor(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        project_settings = project.settings
        project_settings.launch['fix_password'] = '******'
        project_settings.save()

        # DO ACTION
        member = project.add_user_project_supervisor(self.super_user, faker.name(), faker.email())

        # ASSERTS
        self.assertTrue(member.check_password('123456'))
        self.assertTrue(member.has_perm(settings.PROJECT_PERMS_VIEW_PROJECT, project))
        self.assertTrue(member.has_perm(settings.PROJECT_PERMS_ONLY_VIEW_PROJECT, project))
        FakeTeamFactory.create_batch(size=3, project=project, user_from=self.super_user)
        teams = Team.objects.filter_by_project(project).filter_by_user(project, member)
        self.assertEqual(teams.count(), 3)
Example #11
0
    def test_staff_user(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_STARTED)
        FakeTeamFactory.create(project=project)
        exo_staff_user = FakeUserFactory.create(is_superuser=False,
                                                is_active=True,
                                                is_staff=True)
        project.add_user_project_staff(self.super_user,
                                       exo_staff_user.short_name,
                                       exo_staff_user.email)

        # ASSERTS
        url, _ = next_project_url(project, exo_staff_user)
        expected_url = ''
        self.assertEqual(
            url,
            expected_url,
            'Staff',
        )
    def test_create_reporter(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)

        FakeTeamFactory.create_batch(size=3, project=project)

        # DO ACTION
        relation, _ = ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            project=project,
            status=settings.RELATION_ROLE_CH_ACTIVE,
            consultant=FakeConsultantFactory.create(user__is_active=True),
            exo_role=ExORole.objects.get(code=settings.EXO_ROLE_CODE_SPRINT_REPORTER)
        )

        # ASSERTS
        member = relation.consultant.user
        self.assertTrue(member.has_perm(settings.PROJECT_PERMS_VIEW_PROJECT, project))
        self.assertTrue(member.has_perm(settings.PROJECT_PERMS_ONLY_VIEW_PROJECT, project))

        teams = Team.objects.filter_by_project(project).filter_by_user(project, member)
        self.assertEqual(teams.count(), 3)
    def test_create_exo_staff(self):
        # PREPARE DATA
        project = FakeProjectFactory.create(status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        project_settings = project.settings
        project_settings.launch['fix_password'] = '******'
        project_settings.save()
        delivery_manager_user = FakeUserFactory.create(
            is_superuser=True,
            is_active=True,
            is_staff=True,
            password='******')
        exo_staff_user = FakeUserFactory.create(
            is_superuser=True,
            is_active=True,
            is_staff=True,
            password='******')

        project.add_user_project_delivery_manager(
            self.super_user,
            delivery_manager_user.short_name,
            delivery_manager_user.email)

        # DO ACTION
        member = project.add_user_project_staff(
            self.super_user,
            exo_staff_user.short_name,
            exo_staff_user.email)

        # ASSERTS
        self.assertTrue(member.has_perm(settings.PROJECT_PERMS_VIEW_PROJECT,
                                        project))
        self.assertTrue(
            member.has_perm(
                settings.PROJECT_PERMS_DELIVERY_MANAGER,
                project))
        delivery_managers = project.delivery_managers
        self.assertEqual(len(delivery_managers), 1)
Example #14
0
    def test_jobs_for_projects_with_training_customer(self):
        # PREPARE DATA
        customer = FakeCustomerFactory.create(
            customer_type=settings.CUSTOMER_CH_TRAINING)
        project = FakeProjectFactory.create(
            customer=customer,
            status=settings.PROJECT_CH_PROJECT_STATUS_STARTED)

        for code in ExORole.objects.all().filter_by_category_code(
                settings.EXO_ROLE_CATEGORY_EXO_SPRINT).values_list('code',
                                                                   flat=True):
            exo_role = ExORole.objects.get(code=code)

            # DO ACTION
            c_project_role = FakeConsultantProjectRoleFactory.create(
                consultant=self.consultant,
                project=project,
                exo_role=exo_role,
                visible=True,
                status=settings.RELATION_ROLE_CH_ACTIVE)

            # ASSERTS
            self.assertTrue(CoreJob.objects.all().filter_by_instance(
                c_project_role).exists())
 def setUpTestData(cls):
     cls.create_super_user(cls)
     cls.project = FakeProjectFactory.create(created_by=cls.super_user)
Example #16
0
 def setUpTestData(cls):
     cls.create_super_user(cls)
     cls.project = FakeProjectFactory.create(created_by=cls.super_user)
     cls.team = cls.project.teams.first()
     cls.initialize(cls)
 def setUp(self):
     super().setUp()
     self.create_superuser()
     self.project = FakeProjectFactory(
         status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
    def test_update_coach_invitations(self):

        team = FakeTeamFactory(
            project__status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        project = FakeProjectFactory(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        team_coach = team.coach

        new_coach = FakeConsultantFactory()
        with self.assertRaises(ValidationError):
            team.update_coach(
                self.super_user,
                new_coach,
            )

        self.assertEqual(team_coach, team.coach)

        new_project_coach = FakeConsultantFactory(user__is_active=True)
        speaker = FakeConsultantFactory(user__is_active=True)

        ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            consultant=new_project_coach,
            project=project,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_COACH),
        )

        ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            consultant=speaker,
            project=project,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_AWAKE_SPEAKER),
        )

        with self.assertRaises(ValidationError):
            team.update_coach(
                self.super_user,
                new_coach,
            )

        with self.assertRaises(ValidationError):
            team.update_coach(
                self.super_user,
                speaker,
            )

        with self.assertRaises(ValidationError):
            team.update_coach(
                self.super_user,
                self.super_user,
            )

        ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            consultant=new_project_coach,
            project=team.project,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_COACH),
        )

        team.update_coach(
            self.super_user,
            new_project_coach,
        )

        self.assertNotEqual(team_coach, team.coach)
        self.assertEqual(Invitation.objects.count(), 6)
 def setUp(self):
     self.create_superuser()
     self.consultant = FakeConsultantFactory(
         status=settings.CONSULTANT_STATUS_CH_ACTIVE, )
     self.project = FakeProjectFactory(
         status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
Example #20
0
 def setUp(self):
     super().setUp()
     self.create_user()
     self.project = FakeProjectFactory.create(created_by=self.user)