示例#1
0
    def test_filter_by_user_or_organization(self):
        # PREPARE DATA
        name = settings.BRAND_NAME
        users = FakeUserFactory.create_batch(size=2, is_active=True)
        customer = FakeCustomerFactory.create()
        organization = InternalOrganization.objects.get(name=name)
        for user in users:
            user.user_permissions.add(
                Permission.objects.get(
                    codename=settings.PROJECT_PERMS_ADD_PROJECT))
            user.user_permissions.add(
                Permission.objects.get(
                    codename=settings.SPRINT_AUTOMATED_ADD_SPRINT))
            organization.users_roles.get_or_create(user=user)

        FakeSprintAutomatedFactory.create_batch(
            size=3, created_by=users[0], internal_organization=organization)

        customer.create_sprint_automated(
            user_from=users[1],
            name=faker.name(),
            description=faker.text(),
            duration=settings.SPRINT_AUTOMATED_STEPS_COUNT,
        )
        # DO ACTION and ASSERTS
        for user in users:
            projects = Project.objects.filter_by_user_or_organization(
                user).count()
            self.assertEqual(projects, 4)

        self.assertEqual(
            Project.objects.filter_by_user_or_organization(
                FakeUserFactory.create(is_active=True)).count(), 0)
示例#2
0
    def test_filter_by_type(self):
        # PPEPARE DATA
        FakeSprintAutomatedFactory.create_batch(size=3)

        # ASSERTIONS
        queryset = Project.objects.filter_by_type(
            settings.PROJECT_CH_TYPE_SPRINT_AUTOMATED).count()
        self.assertEqual(queryset, 3)
示例#3
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)
示例#4
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')
示例#5
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_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),
        )
示例#7
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,
        )
示例#8
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,
        )
    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_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 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)
示例#12
0
    def test_project_real_type(self):

        self.assertEqual(self.project, self.project.real_type)

        sprint = FakeSprintAutomatedFactory()
        self.assertEqual(sprint, sprint.real_type)
        self.assertEqual(sprint, sprint.project_ptr.real_type)
示例#13
0
    def test_project_is_type_property(self):

        project = self.create_project()
        self.assertFalse(project.is_sprint)

        sprint = FakeSprintAutomatedFactory()
        self.assertTrue(sprint.is_sprintautomated)
    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'))
示例#15
0
 def setUp(self):
     super().setUp()
     self.create_superuser()
     self.consultant = FakeConsultantFactory(status=settings.CONSULTANT_STATUS_CH_ACTIVE)
     self.sprint = FakeSprintAutomatedFactory(status=settings.PROJECT_CH_PROJECT_STATUS_STARTED)
     # Sprint Teams
     self.team_s_a = FakeTeamFactory.create(project=self.sprint.project_ptr)
     self.team_s_b = FakeTeamFactory.create(project=self.sprint.project_ptr)
示例#16
0
    def test_project_type_project(self):

        self.assertEqual(self.project, self.project.real_type)

        sprint = FakeSprintAutomatedFactory()
        self.assertEqual(
            sprint.type_project.lower(),
            SprintAutomated._meta.model_name,
        )
 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,
     )
示例#18
0
    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_create_generic_typeform_feedback(self):
     sprint = FakeSprintAutomatedFactory()
     self.assertTrue(sprint.steps.exists())
     # There are typeform feedback for each step, except the first one
     for step in sprint.steps.filter(index__gt=1):
         for step_stream in step.streams.all():
             self.assertTrue(step_stream.typeform_feedback.exists())
     # the first step doesn't have feedback
     step = sprint.steps.first()
     for step_stream in step.streams.all():
         self.assertFalse(step_stream.typeform_feedback.exists())
示例#20
0
    def test_project_verbose_real_type(self):

        sprint = FakeSprintAutomatedFactory()
        self.assertEqual(
            sprint.project_ptr.type_verbose_name,
            sprint._meta.verbose_name,
        )

        fastrack = FakeFastrackFactory()
        self.assertEqual(
            fastrack.project_ptr.type_verbose_name,
            fastrack._meta.verbose_name,
        )
示例#21
0
    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)
示例#23
0
 def test_filter_by_user(self):
     user1 = FakeUserFactory.create(is_active=True)
     projects = FakeSprintAutomatedFactory.create_batch(size=3)
     queryset = Project.objects.filter_by_type(
         settings.PROJECT_CH_TYPE_SPRINT_AUTOMATED, ).filter_by_user(
             user1, ).count()
     self.assertEqual(queryset, 0)
     queryset = Project.objects.filter_by_type(
         settings.PROJECT_CH_TYPE_SPRINT_AUTOMATED, ).filter_by_user(
             self.super_user, ).count()
     self.assertEqual(queryset, 3)
     assign_perm(settings.PROJECT_PERMS_VIEW_PROJECT, user1,
                 projects[0].project_ptr)
     queryset = Project.objects.filter_by_type(
         settings.PROJECT_CH_TYPE_SPRINT_AUTOMATED, ).filter_by_user(
             user1, ).count()
     self.assertEqual(queryset, 1)
示例#24
0
    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])
示例#25
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())
示例#26
0
    def _build_sprint(self, number_of_members=2):
        sprint = FakeSprintAutomatedFactory()
        team_members = [{
            'email': faker.email(),
            'short_name': faker.name(),
        } for _ in range(1, number_of_members + 1)]

        project = sprint.project_ptr
        consultant = FakeConsultantFactory()
        team = Team.objects.create(
            project=project,
            user_from=self.super_user,
            created_by=self.super_user,
            name=faker.name(),
            coach=consultant,
            stream=settings.PROJECT_STREAM_CH_STRATEGY,
            team_members=team_members,
        )
        return sprint, team, consultant
示例#27
0
    def test_edit_project_settings_form(self):
        # PREPARE DATA
        self.client.login(username=self.super_user.username, password='******')
        sprint = FakeSprintAutomatedFactory()
        url = reverse('project:project:settings', args=[sprint.pk])

        # DO ACTION
        response = self.client.get(url)

        # ASSERTS
        initial = response.context.get('form').initial
        self.assertFalse(initial['send_welcome_consultant'])
        self.assertFalse(initial['send_welcome_participant'])
        self.assertEqual(initial['fix_password'], '')
        self.assertFalse(initial['participant_step_feedback_enabled'])
        self.assertTrue(initial['directory_enabled'])

        # PREPARE DATA
        new_data = {
            'send_welcome_consultant': True,
            'send_welcome_participant': True,
            'fix_password': faker.name(),
            'participant_step_feedback_enabled': False,
            'version': settings.PROJECT_CH_VERSION_DEFAULT,
            'directory_enabled': False,
            'advisor_request_enabled': True,
            'num_tickets_per_team': 5,
            'tickets_price': 200,
            'tickets_currency': settings.OPPORTUNITIES_CH_CURRENCY_EXOS,
        }

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

        # ASSERTS
        sprint_settings = sprint.settings
        self.assertTrue(sprint_settings.launch['send_welcome_consultant'])
        self.assertTrue(sprint_settings.launch['send_welcome_participant'])
        self.assertEqual(sprint_settings.launch['fix_password'],
                         new_data.get('fix_password'))
        self.assertFalse(sprint_settings.participant_step_feedback_enabled)
        self.assertFalse(sprint_settings.directory)
示例#28
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,
     )
示例#29
0
    def test_edit_service_sprint_from_django_form(self, mock):
        # PREPARE DATA
        sprint = FakeSprintAutomatedFactory()
        new_date = '2013-01-01 10:00:00'
        sprint_form = SprintSimpleForm(instance=sprint)
        data = sprint_form.initial
        data['start'] = new_date
        data['agenda'] = ''
        data['location'] = faker.city()
        data['timezone'] = faker.timezone()
        data['place_id'] = faker.pyint()
        url = reverse('project:project:dashboard',
                      kwargs={'project_id': sprint.id})
        self.client.login(username=self.super_user.username, password='******')

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

        # ASSERTS
        self.assertTrue(status.is_success(response.status_code))
示例#30
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))