Exemple #1
0
 def setUp(self):
     self.create_user()
     self.create_superuser()
     self.sprint = FakeSprintAutomatedFactory.create(
         created_by=self.user)
     self.sprint_training = FakeSprintAutomatedFactory.create(
         created_by=self.user,
         category=settings.PROJECT_CH_CATEGORY_TRAINING)
Exemple #2
0
    def test_coach_and_head_coach(self):
        # PREPARE DATA
        sprint = FakeSprintAutomatedFactory.create(
            category=settings.PROJECT_CH_CATEGORY_TRANSFORMATION,
            created_by=self.super_user)

        consultant_manager = FakeConsultantFactory.create(
            user__is_active=True, )
        consultant_coaches = FakeConsultantFactory.create_batch(
            size=3,
            user__is_active=True,
        )
        ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            consultant=consultant_manager,
            project=sprint.project_ptr,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_HEAD_COACH))
        for coach in consultant_coaches:
            ConsultantProjectRole.objects.get_or_create_consultant(
                user_from=self.super_user,
                consultant=coach,
                project=sprint.project_ptr,
                exo_role=ExORole.objects.get(
                    code=settings.EXO_ROLE_CODE_SPRINT_COACH))

        self.assertEqual(self.hub.users.count(), 0, 'No users yet')

        # DO ACTION
        add_coaches_and_head_coach_as_alumni()

        # ASSERTS
        self.assertEqual(self.hub.users.count(), 4,
                         'No coaches/head coach added yet')
 def prepare_data(self):
     self.sprint_automated = FakeSprintAutomatedFactory.create()
     self.team = FakeTeamFactory.create(
         project=self.sprint_automated.project_ptr)
     self.step = FakeStepFactory.create(project=self.team.project)
     user = FakeUserFactory.create(is_active=True)
     self.add_user_to_team(user, self.team)
Exemple #4
0
    def test_settings_room(self):
        """
            Test settings for this ZoomRoom
        """
        sprint = FakeSprintAutomatedFactory.create()

        coaches = FakeConsultantFactory.create_batch(
            size=3, user__is_active=True,
            status=settings.CONSULTANT_STATUS_CH_ACTIVE,
        )
        for coach in coaches:
            ConsultantProjectRole.objects.get_or_create_consultant(
                user_from=self.super_user,
                consultant=coach,
                project=sprint.project_ptr,
                exo_role=ExORole.objects.get(code=settings.EXO_ROLE_CODE_SPRINT_COACH),
            )

        meeting_id = faker.word()
        team = FakeTeamFactory(
            project=sprint.project_ptr,
            coach=Consultant.objects.last(),
            zoom_id=meeting_id,
        )

        self.assertEqual(team.room.meeting_object, team)
        self.assertEqual(team.room.meeting_id, meeting_id)
        self.assertEqual(
            team.room.zoom_settings,
            team.room._zoom_settings,
        )
Exemple #5
0
    def test_validation_teams(self):
        sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING,
        )
        team = FakeTeamFactory.create(
            project=sprint.project_ptr,
        )
        validator = TeamValidator(sprint.project_ptr)
        validator.validate()
        self.assertEqual(sprint.project_ptr.validations.count(), 1)
        self.assertEqual(
            sprint.project_ptr.validations
            .filter_by_status_pending().count(), 0,
        )
        self.assertEqual(
            sprint.project_ptr.validations
            .filter_by_status_fixed().count(), 1,
        )

        team.delete()
        validator.validate()
        self.assertEqual(
            sprint.project_ptr.validations
            .filter_by_status_pending().count(), 1,
        )
        self.assertEqual(
            sprint.project_ptr.validations
            .filter_by_status_fixed().count(), 0,
        )
Exemple #6
0
    def prepare_data(self):
        self.sprint_automated = FakeSprintAutomatedFactory.create()
        self.team = FakeTeamFactory.create(
            project=self.sprint_automated.project_ptr)
        self.step = FakeStepFactory.create(project=self.team.project)
        self.populate_assignments_version_2(
            self.sprint_automated,
            settings.PROJECT_CH_TEMPLATE_ASSIGNMENTS_SPRINT_BOOK)
        consultant_manager_user = FakeUserFactory.create()
        consultant_for_manager_role = FakeConsultantFactory.create(
            user=consultant_manager_user,
            status=settings.CONSULTANT_STATUS_CH_ACTIVE,
        )

        team_member = FakeUserFactory.create()
        self.team.team_members.add(self.user)
        self.team.team_members.add(team_member)

        self.manager_role, _ = ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            project=self.sprint_automated.project_ptr,
            consultant=consultant_for_manager_role,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_HEAD_COACH),
        )

        self.sprint_automated.launch(self.super_user)
 def setUp(self):
     self.create_superuser()
     self.create_user()
     self.sprint = FakeSprintAutomatedFactory.create(
         status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
     self.team = FakeTeamFactory.create(
         coach=FakeConsultantFactory.create(
             user=self.user,
             status=settings.CONSULTANT_STATUS_CH_ACTIVE,
         ),
         project=self.sprint.project_ptr,
     )
     for k in range(3):
         self.team.add_member(self.super_user,
                              email=faker.email(),
                              name=faker.name())
     self.project = self.sprint.project_ptr
     self.head_role = FakeConsultantProjectRoleFactory.create(
         project=self.project,
         consultant=FakeConsultantFactory(user__is_active=True),
         exo_role=ExORole.objects.get(
             code=settings.EXO_ROLE_CODE_SPRINT_HEAD_COACH),
         status=settings.RELATION_ROLE_CH_ACTIVE,
     )
     self.coach_role = self.project.consultants_roles.get(
         consultant=self.team.coach)
    def test_update_answer_team_project(self, answer_emails_task_mock):
        # PREPARE DATA
        sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        new_team = FakeTeamFactory.create(project=sprint.project_ptr)
        new_team.add_member(
            user_from=self.super_user,
            email=self.user.email,
            name=self.user.short_name,
        )
        post = Post.objects.create_project_team_post(
            user_from=self.super_user,
            team=new_team,
            title=' '.join(faker.words()),
            description=faker.text(),
        )
        answer = post.reply(self.user, faker.text())
        url = reverse('api:forum:answer-detail', kwargs={'pk': answer.pk})
        self.client.login(username=self.user.username, password='******')

        # DO ACTION
        data = {'comment': faker.text()}
        response = self.client.put(url, data=data)

        # ASSERTS
        self.assertTrue(status.is_success(response.status_code))
        answer.refresh_from_db()
        self.assertEqual(answer.comment, data['comment'])
        self.assertTrue(answer_emails_task_mock.called)
        self.assertEqual(answer_emails_task_mock.call_count, 1)
        self.assertIsNotNone(
            self.get_mock_kwarg(answer_emails_task_mock, 'eta'))
    def test_zoom_settings(self):
        """
        Check that ZoomSettings for ZoomRoom and the related object settings
        are the same
        """
        sprint = FakeSprintAutomatedFactory.create()

        coaches = FakeConsultantFactory.create_batch(
            size=3,
            user__is_active=True,
            status=settings.CONSULTANT_STATUS_CH_ACTIVE,
        )
        for coach in coaches:
            ConsultantProjectRole.objects.get_or_create_consultant(
                user_from=self.super_user,
                consultant=coach,
                project=sprint.project_ptr,
                exo_role=ExORole.objects.get(
                    code=settings.EXO_ROLE_CODE_SPRINT_COACH),
            )

        team = FakeTeamFactory(
            project=sprint.project_ptr,
            coach=Consultant.objects.last(),
        )

        self.assertEqual(team.settings, team.project.zoom_settings)
    def setUp(self):
        self.create_user()
        self.create_superuser()
        sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        new_team = FakeTeamFactory.create(project=sprint.project_ptr)
        new_team.add_member(
            user_from=self.super_user,
            email=self.user.email,
            name=self.user.short_name,
        )
        consultant_manager_user = FakeUserFactory.create()
        consultant_for_manager_role = FakeConsultantFactory.create(
            user=consultant_manager_user,
            status=settings.CONSULTANT_STATUS_CH_ACTIVE,
        )

        self.manager_role = ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            project=sprint.project_ptr,
            consultant=consultant_for_manager_role,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_HEAD_COACH),
        )
        self.team = new_team
        self.sprint = sprint
        self.step = sprint.project_ptr.steps.first()
        ConsultantProjectRole.objects.get_or_create_consultant(
            user_from=self.super_user,
            project=self.sprint.project_ptr,
            consultant=FakeConsultantFactory.create(
                status=settings.CONSULTANT_STATUS_CH_ACTIVE),
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_HEAD_COACH),
        )
 def create_consultant_project_roles(self, consultant):
     sprint = FakeSprintAutomatedFactory.create()
     sprint.set_started(sprint.created_by, timezone.now())
     self.consultant_role = FakeConsultantProjectRoleFactory.create(
         project=sprint.project_ptr,
         consultant=consultant,
         exo_role=ExORole.objects.get(code=settings.EXO_ROLE_CODE_ADVISOR),
         status=settings.RELATION_ROLE_CH_ACTIVE,
         visible=True,
     )
    def setUp(self):
        self.create_user()
        self.create_superuser()

        FakeConsultantFactory.create(
            user=self.user,
        )
        self.sprint_automated = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_DRAFT,
            start=decrease_date(days=1),
            created_by=self.user)
    def test_ask_the_ecosystem(self, post_emails_task_mock):
        # PREPARE DATA
        sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        new_team = FakeTeamFactory.create(project=sprint.project_ptr)
        new_team.add_member(
            user_from=self.super_user,
            email=self.user.email,
            name=self.user.short_name,
        )
        keyword = FakeKeywordFactory.create()
        num_files = 3
        data = {
            'title':
            ' '.join(faker.words()),
            'description':
            faker.text(),
            'tags': [
                {
                    'pk': keyword.pk,
                    'name': keyword.name,
                },
                {
                    'name': faker.word() + faker.numerify(),
                },
            ],
            'uploaded_files':
            self.get_files_example(num_files),
        }

        url_params = {
            'team_pk': new_team.id,
            'project_pk': sprint.id,
        }
        url = reverse('api:forum:questions-team-list', kwargs=url_params)
        self.client.login(username=self.user.username, password='******')

        # DO ACTION
        response = self.client.post(url, data=data)

        # ASSERTS
        self.assertTrue(status.is_success(response.status_code))
        self.assertIsNotNone(response.data['pk'])
        post = Post.objects.get(pk=response.data['pk'])
        self.assertEqual(post.tags.count(), 2)
        self.assertTrue(post.is_project)
        self.assertTrue(post_emails_task_mock.called)
        self.assertEqual(post_emails_task_mock.call_count, 1)
        self.assertIsNotNone(self.get_mock_kwarg(post_emails_task_mock, 'eta'))
        self.assertEqual(len(post.uploaded_files), num_files)
        self.assertEqual(len(response.data.get('uploaded_files')), num_files)
    def create_sprint(self):
        self.secondary_user = FakeUserFactory.create()
        self.sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        self.team_A = FakeTeamFactory.create(project=self.sprint.project_ptr)
        self.team_B = FakeTeamFactory.create(project=self.sprint.project_ptr)

        self.team_A.add_member(user_from=self.super_user,
                               email=self.user.email,
                               name=self.user.short_name)

        self.team_B.add_member(user_from=self.super_user,
                               email=self.secondary_user.email,
                               name=self.secondary_user.short_name)
    def test_sprint_automated_steps(self):
        # PREPARE DATA
        sprint = FakeSprintAutomatedFactory.create(start=None)
        project = sprint.project_ptr
        project.update_assignments_template(
            settings.PROJECT_CH_TEMPLATE_ASSIGNMENTS_SPRINT_BOOK)
        start = timezone.now()
        project.set_started(
            user=self.super_user,
            start_date=start,
        )
        dates = [
            ('2018-11-07 07:00:17+00:00', '2018-11-05 09:00:04+00:00', 1),
            ('2018-11-05 09:00:04+00:00', '2018-11-05 11:00:04+00:00', 2),
            ('2018-11-05 11:00:34+00:00', '2018-11-06 18:00:34+00:00', 3),
            ('2018-11-07 09:00:39+00:00', '2018-11-16 18:00:39+00:00', 4),
            ('2018-11-18 09:00:27+00:00', None, 5),
            ('2018-12-03 09:00:57+00:00', None, 6),
            ('2018-11-26 09:00:10+00:00', None, 7),
            ('2018-12-03 09:00:43+00:00', None, 8),
            ('2018-12-10 09:00:35+00:00', None, 9),
            ('2018-12-17 09:00:22+00:00', None, 10),
            ('2018-12-24 09:00:46+00:00', None, 11),
            ('2018-12-31 09:00:00+00:00', None, 12),
            ('2019-01-07 09:00:12+00:00', None, 13),
        ]
        for index, k in enumerate(project.steps.all().order_by('index')):
            k.start = parser.parse(dates[index][0])
            end = dates[index][1]
            if end is not None:
                k.end = parser.parse(end)
            k.save()

        inputs = [
            '2018-11-06 09:00:10+00:00',
            '2018-11-25 09:00:10+00:00',
            '2018-12-16 09:00:10+00:00',
        ]

        output_excepted = [3, 5, 9]

        # ASSERTS
        for index, date in enumerate(inputs):
            project_step = project.current_step(parser.parse(date))
            self.assertEqual(project_step.index, output_excepted[index])
Exemple #16
0
    def test_assignment_step_teams_creation_after_assignments_content_is_populatated(
            self):
        # PREPARE DATA
        sprint_automated = FakeSprintAutomatedFactory.create()
        self.populate_assignments_version_2(
            sprint_automated,
            settings.PROJECT_CH_TEMPLATE_ASSIGNMENTS_SPRINT_BOOK)

        # DO ACTION
        team = FakeTeamFactory.create(project=sprint_automated.project_ptr)

        # ASSERTS
        assignments = AssignmentStep.objects.filter_by_project(
            sprint_automated.project_ptr).filter_by_stream(team.stream)

        for asignment in assignments:
            self.assertTrue(
                AssignmentStepTeam.objects.filter(assignment_step=asignment,
                                                  team=team).exists())
Exemple #17
0
 def test_validation_default_password(self):
     sprint = FakeSprintAutomatedFactory.create(
         status=settings.PROJECT_CH_PROJECT_STATUS_WAITING,
     )
     validator = ParticipantPasswordValidator(sprint.project_ptr)
     validator.validate()
     self.assertEqual(sprint.project_ptr.validations.count(), 1)
     self.assertEqual(
         sprint.project_ptr.validations
         .filter_by_status_pending().count(), 1,
     )
     project_settings = sprint.project_ptr.settings
     project_settings.launch['fix_password'] = faker.word()
     project_settings.save()
     validator.validate()
     self.assertEqual(sprint.project_ptr.validations.count(), 1)
     self.assertEqual(
         sprint.project_ptr.validations
         .filter_by_status_pending().count(), 0,
     )
    def test_participant_complete_onboarding(self):
        # PREPARE DATA
        sprint = FakeSprintAutomatedFactory.create(
            category=settings.PROJECT_CH_CATEGORY_TRANSFORMATION,
            created_by=self.super_user)

        exo_role = ExORole.objects.get(
            code=settings.EXO_ROLE_CODE_SPRINT_PARTICIPANT)
        sprint.project_ptr.users_roles.get_or_create(user=self.user,
                                                     exo_role=exo_role)
        consultant = FakeConsultantFactory.create(user=self.user)

        self.assertEqual(self.hub.users.count(), 0, 'No users added yet')

        # DO ACTION
        consultant_post_activated.send(sender=consultant.__class__,
                                       consultant=consultant)

        # ASSERTS
        self.assertEqual(self.hub.users.count(), 1,
                         'No user in project added yet')
    def test_api_step_detail_fail(self):
        # PREPARE DATA
        sprint2 = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        team_ids = [self.team.id + 1, 200]
        step_ids = [sprint2.project_ptr.steps.all()[0].pk, 200]
        self.client.login(username=self.user.username, password='******')

        # DO ACTION
        for team_id in team_ids:
            for step_id in step_ids:
                url = reverse('api:project:step:step-detail',
                              kwargs={
                                  'project_id': self.sprint.project_ptr.pk,
                                  'team_id': team_id,
                                  'pk': step_id,
                              })
                response = self.client.get(url)
                # ASSERTS
                self.assertTrue(response.status_code in [403, 404])
                self.assertTrue(status.is_client_error(response.status_code))
Exemple #20
0
    def test_assignments_populator_sprint_book(self):
        # PREPARE DATA
        sprint_automated = FakeSprintAutomatedFactory.create()
        team = FakeTeamFactory.create(project=sprint_automated.project_ptr)
        sprint_book_exo_data_path = settings.ASSIGNMENT_EXO_DATA_SPRINT_BOOK_PATH
        sprint_book_num_assignments = len(
            os.listdir(sprint_book_exo_data_path))

        # DO ACTION
        self.populate_assignments_version_2(
            sprint_automated.project_ptr,
            settings.PROJECT_CH_TEMPLATE_ASSIGNMENTS_SPRINT_BOOK)

        # ASSERTS
        self.assertEqual(
            AssignmentStep.objects.filter_by_project(
                sprint_automated.project_ptr).count(),
            sprint_book_num_assignments)

        for step in sprint_automated.steps.all():
            self.assertTrue(step.has_team_assignments(team))
    def test_update_question_by_user(self):
        # PREPARE DATA
        sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        new_team = FakeTeamFactory.create(project=sprint.project_ptr)
        new_team.add_member(
            user_from=self.super_user,
            email=self.user.email,
            name=self.user.short_name,
        )
        post = Post.objects.create_project_team_post(
            user_from=self.super_user,
            team=new_team,
            title=' '.join(faker.words()),
            description=faker.text(),
        )
        keyword = FakeKeywordFactory.create()

        # DO ACTION
        self.client.login(username=self.user.username, password='******')
        url = reverse('api:forum:post-detail', kwargs={'pk': post.pk})
        data = {
            'title':
            ' '.join(faker.words()),
            'description':
            faker.text(),
            'tags': [
                {
                    'pk': keyword.pk,
                    'name': keyword.name,
                },
                {
                    'name': faker.word(),
                },
            ]
        }
        response = self.client.put(url, data=data)

        # ASSERTS
        self.assertTrue(status.is_client_error(response.status_code))
Exemple #22
0
 def initialize(self):
     sprint = FakeSprintAutomatedFactory.create(
         status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
     new_team = FakeTeamFactory.create(project=sprint.project_ptr)
     new_team.add_member(
         user_from=self.super_user,
         email=self.user.email,
         name=self.user.short_name,
     )
     consultants = [
         FakeConsultantProjectRoleFactory.create(
             project=sprint.project_ptr,
             consultant=FakeConsultantFactory(user__is_active=True),
             exo_role=ExORole.objects.get(
                 code=settings.EXO_ROLE_CODE_ADVISOR),
             exo_role_other_name='Swarm',
             status=settings.RELATION_ROLE_CH_ACTIVE,
         ) for i in range(5)
     ]
     self.team = new_team
     self.sprint = sprint
     self.advisors = consultants
Exemple #23
0
 def setUp(self):
     super().setUp()
     self.create_superuser()
     self.sprint = FakeSprintAutomatedFactory.create()
 def prepare_data(self):
     self.sprint_automated = FakeSprintAutomatedFactory.create()
     self.project = self.sprint_automated.project_ptr
 def create_project(self):
     self.sprint = FakeSprintAutomatedFactory.create(
         status=settings.PROJECT_CH_PROJECT_STATUS_WAITING,
         start=timezone.now())
     self.project = self.sprint.project_ptr
Exemple #26
0
    def initialize_swarms(self, superuser, user):
        self.secondary_user = FakeUserFactory.create()
        self.sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        self.team_A = FakeTeamFactory.create(project=self.sprint.project_ptr)
        self.team_B = FakeTeamFactory.create(project=self.sprint.project_ptr)

        self.team_A.add_member(user_from=superuser,
                               email=user.email,
                               name=user.short_name)

        self.team_B.add_member(user_from=superuser,
                               email=self.secondary_user.email,
                               name=self.secondary_user.short_name)

        self.advisors_first = [
            FakeConsultantProjectRoleFactory.create(
                project=self.sprint.project_ptr,
                consultant=FakeConsultantFactory(user__is_active=True),
                exo_role=ExORole.objects.get(
                    code=settings.EXO_ROLE_CODE_ADVISOR),
                exo_role_other_name='Swarm',
                status=settings.RELATION_ROLE_CH_ACTIVE,
            ) for i in range(4)
        ]
        self.advisors_second = [
            FakeConsultantProjectRoleFactory.create(
                project=self.sprint.project_ptr,
                consultant=FakeConsultantFactory(user__is_active=True),
                exo_role=ExORole.objects.get(
                    code=settings.EXO_ROLE_CODE_ADVISOR),
                exo_role_other_name='Swarm',
                status=settings.RELATION_ROLE_CH_ACTIVE,
            ) for i in range(3)
        ]

        self.qa_session_first = QASession.objects.create(
            project=self.sprint.project_ptr,
            start_at=string_to_datetime('2019, 04, 20, 11:00'),
            end_at=string_to_datetime('2019, 04, 20, 12:00'),
        )

        self.qa_session_second = QASession.objects.create(
            project=self.sprint.project_ptr,
            start_at=string_to_datetime('2019, 04, 26, 13:00'),
            end_at=string_to_datetime('2019, 04, 26, 14:00'),
        )

        for c_project_role in self.advisors_first:
            self.qa_session_first.qa_session_advisors.create(
                consultant_project_role=c_project_role)
            self.qa_session_second.qa_session_advisors.create(
                consultant_project_role=c_project_role)

        self.posts_first_A = [
            Post.objects.create_project_qa_session_post(
                user_from=user,
                title=' '.join(faker.words()),
                description=faker.text(),
                qa_session_team=self.qa_session_first.teams.get(
                    team=self.team_A)) for i in range(6)
        ]

        post = self.posts_first_A[0]
        post.reply(self.advisors_first[0].consultant.user, faker.text())
        post.reply(self.advisors_first[1].consultant.user, faker.text())
        post.reply(self.advisors_first[2].consultant.user, faker.text())

        self.post_first_B = [
            Post.objects.create_project_qa_session_post(
                user_from=self.secondary_user,
                title=' '.join(faker.words()),
                description=faker.text(),
                qa_session_team=self.qa_session_first.teams.get(
                    team=self.team_B)) for i in range(4)
        ]

        post = self.post_first_B[0]
        post.reply(self.advisors_first[0].consultant.user, faker.text())
        post.reply(self.advisors_first[1].consultant.user, faker.text())
        post.reply(self.advisors_first[0].consultant.user, faker.text())
Exemple #27
0
    def test_get_team_for_user(self):
        manager1 = FakeConsultantFactory.create(user__is_active=True)
        manager2 = FakeConsultantFactory.create(user__is_active=True)
        sprint = FakeSprintAutomatedFactory.create()
        sprint2 = FakeSprintAutomatedFactory.create()

        FakeConsultantProjectRoleFactory(
            consultant=manager1,
            project=sprint.project_ptr,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_COACH),
            status=settings.RELATION_ROLE_CH_ACTIVE,
        )
        FakeConsultantProjectRoleFactory(
            consultant=manager2,
            project=sprint2.project_ptr,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_COACH),
            status=settings.RELATION_ROLE_CH_ACTIVE,
        )

        coach1 = FakeConsultantFactory.create(user__is_active=True)
        teams_1 = FakeTeamFactory.create_batch(
            size=3,
            user_from=self.super_user,
            project=sprint.project_ptr,
        )
        teams_2 = FakeTeamFactory.create_batch(
            size=2,
            user_from=self.super_user,
            project=sprint2.project_ptr,
            coach=coach1,
        )
        sprint.project_ptr.launch(self.super_user)
        sprint2.project_ptr.launch(self.super_user)

        self.assertEqual(
            get_team_for_user(
                sprint.project_ptr,
                self.super_user,
            ).count(),
            3,
        )
        self.assertEqual(
            get_team_for_user(
                sprint2.project_ptr,
                self.super_user,
            ).count(),
            2,
        )
        self.assertEqual(
            get_team_for_user(
                sprint.project_ptr,
                manager2.user,
            ).count(),
            0,
        )
        self.assertEqual(
            get_team_for_user(
                sprint2.project_ptr,
                manager1.user,
            ).count(),
            0,
        )
        self.assertEqual(
            get_team_for_user(
                sprint.project_ptr,
                teams_1[0].coach.user,
            ).count(),
            1,
        )
        self.assertEqual(
            get_team_for_user(
                sprint.project_ptr,
                teams_1[0].coach.user,
            ).count(),
            1,
        )
        self.assertEqual(
            get_team_for_user(
                sprint2.project_ptr,
                coach1.user,
            ).count(),
            2,
        )

        member1 = teams_1[0].add_member(
            user_from=self.super_user,
            name=faker.first_name(),
            email=faker.email(),
        )
        member2 = teams_2[0].add_member(
            user_from=self.super_user,
            name=faker.first_name(),
            email=faker.email(),
        )
        self.assertEqual(
            get_team_for_user(
                sprint.project_ptr,
                member1,
            ).count(),
            1,
        )
        self.assertEqual(
            get_team_for_user(
                sprint2.project_ptr,
                member2,
            ).count(),
            1,
        )
Exemple #28
0
 def setUp(self):
     self.create_user()
     self.create_superuser()
     self.consultant = FakeConsultantFactory.create(user=self.user)
     self.sprint = FakeSprintAutomatedFactory.create(created_by=self.user)
    def initialize_project(self):
        sprint = FakeSprintAutomatedFactory.create(
            status=settings.PROJECT_CH_PROJECT_STATUS_WAITING)
        project = sprint.project_ptr
        role = FakeConsultantProjectRoleFactory.create(
            project=project,
            exo_role=ExORole.objects.get(
                code=settings.EXO_ROLE_CODE_SPRINT_COACH),
            status=settings.RELATION_ROLE_CH_ACTIVE,
            consultant__user__is_active=True,
            consultant__user__password='******',
        )
        FakeUserProjectRoleFactory.create(
            status=settings.RELATION_ROLE_CH_ACTIVE,
            project=project,
            user=self.user)

        query = """query allProject($pk: String) {
            allProject(pk: $pk) {
            edges {
                node {
                    consultantsRoles {
                        edges {
                            node {
                            rating
                            exoRole {
                                code
                                name
                            }
                    consultant {
                        pk
                        user {
                            pk
                            fullName
                            shortName
                            slug
                            isOpenexoMember
                            profilePictures {
                                width
                                height
                                url
                            }
                        }
                    }
                }
              }
            }
            usersRoles {
              edges {
                node {
                  status
                  exoRole {
                    code
                    name

                  }
                  user {
                    pk
                    fullName
                    shortName
                    slug
                    profilePictures {
                      width
                      height
                      url
                    }
                  }
                }
              }
            }
            teams {
              edges {
                node {
                  pk
                  name
                  coach {
                    pk
                  }
                  teamMembers {
                    edges {
                      node {
                        pk
                      }
                    }
                  }
                }
              }
                }
              }
            }
          }
        }
        """
        return project, query, role.consultant
Exemple #30
0
 def setUp(self):
     super().setUp()
     self.sprint = FakeSprintAutomatedFactory.create()
     self.super_user.set_password('123456')
     self.super_user.save()