Beispiel #1
0
def test__sanitize_issue():
    mock_group = 'Moof'
    mock_issue = retro.create_mock_issueV2(group=mock_group)

    actual_sanitized_issue = ServiceV2._sanitize_issue(mock_issue, RetroStepV2.ADDING_ISSUES, 'whatever-user-token')

    assert mock_group == actual_sanitized_issue['group']
Beispiel #2
0
def test_delete_group(mock_send_retro_update):
    mock_group1 = retro.create_mock_group(id='group1')
    mock_group2 = retro.create_mock_group(id='group2')
    mock_issue1 = retro.create_mock_issueV2(group=mock_group1.id)
    mock_issue2 = retro.create_mock_issueV2()
    mock_issue3 = retro.create_mock_issueV2(group=mock_group2.id)
    mock_issue4 = retro.create_mock_issueV2(group=mock_group1.id)
    mock_retro = retro.create_mock_retroV2(groups=[mock_group1, mock_group2], issues=[mock_issue1, mock_issue2, mock_issue3, mock_issue4])

    before_group_number = len(mock_retro.groups)

    ServiceV2.delete_group(mock_group1, mock_retro)

    assert before_group_number - 1 == len(mock_retro.groups)
    assert mock_issue1.group is None
    assert mock_issue4.group is None
    assert mock_group2.id == mock_issue3.group
Beispiel #3
0
def test_ungroup_issue(mock_send_retro_update):
    mock_group = retro.create_mock_group(id='a group')
    mock_issue = retro.create_mock_issueV2(id='an issue', group=mock_group.id)
    mock_retro = retro.create_mock_retroV2(id='a retro', issues=[mock_issue], groups=[mock_group])

    ServiceV2.ungroup_issue(mock_issue, mock_retro)

    assert mock_issue.group is None
Beispiel #4
0
def test_unvote_for_issue_for_group(mock_send_retro_update):

    voting_user = '******'

    mock_group = retro.create_mock_group(id='a group', votes={voting_user})
    mock_issue = retro.create_mock_issueV2(id='an issue', group=mock_group.id)
    mock_retro = retro.create_mock_retroV2(id='a retro', issues=[mock_issue], groups=[mock_group])

    ServiceV2.unvote_for_issue(mock_issue, voting_user, mock_retro)

    assert mock_issue.votes is None or voting_user not in mock_issue.votes
    assert mock_group.votes is None or voting_user not in mock_group.votes
Beispiel #5
0
    def test__group_put_group_does_not_exist_real_uuid(
            self, mock_service_function_validation, mock_token):
        non_existing_group_id = '0f3c2792-fc6c-41d5-a451-bebc3072fcc2'
        mock_group = retro.create_mock_group(id='cool_id')
        mock_issue = retro.create_mock_issueV2()
        mock_retro = retro.create_mock_retroV2(
            current_step=RetroStepV2.GROUPING.value,
            issues=[mock_issue],
            groups=[mock_group])

        object_under_test = RetroIssueViewV2()
        response = object_under_test._group_put(
            request.create_mock_request(group_id=non_existing_group_id),
            retro=mock_retro)

        validators.assert_group_not_found(response, non_existing_group_id)
Beispiel #6
0
    def test_put_group_issue(self, mock_group_put_function,
                             mock_service_function_validation, mock_token):
        request_body = {
            'group': '0f3c2792-fc6c-41d5-a451-bebc3072fcc2',
        }
        mock_issue_id = 'whatever_issue_id'
        mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro(
            current_step=RetroStepV2.VOTING.value,
            issues=[retro.create_mock_issueV2(id=mock_issue_id)])
        mock_token.token_is_valid.return_value = True

        object_under_test = RetroIssueViewV2()
        object_under_test.put(
            request.create_mock_request(request_body,
                                        retro_id='whatever',
                                        issue_id=mock_issue_id))

        assert mock_group_put_function.called is True
Beispiel #7
0
    def test_put_vote_for_issue(self, mock_super_put,
                                mock_service_function_validation, mock_token):
        request_body = {
            'vote': True,
        }
        mock_issue_id = 'whatever_issue_id'
        mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro(
            current_step=RetroStepV2.VOTING.value,
            issues=[retro.create_mock_issueV2(id=mock_issue_id)])
        mock_token.token_is_valid.return_value = True

        object_under_test = RetroIssueViewV2()
        object_under_test.put(
            request.create_mock_request(request_body,
                                        retro_id='whatever',
                                        issue_id=mock_issue_id))

        assert mock_super_put.called is True
Beispiel #8
0
    def test__group_put_retro_not_on_step(self,
                                          mock_service_function_validation,
                                          mock_token):

        mock_group = retro.create_mock_group()
        mock_issue = retro.create_mock_issueV2()
        retro_current_step = RetroStepV2.VOTING.value
        mock_retro = retro.create_mock_retroV2(current_step=retro_current_step,
                                               issues=[mock_issue],
                                               groups=[mock_group])

        object_under_test = RetroIssueViewV2()
        response = object_under_test._group_put(mock_issue,
                                                retro=mock_retro,
                                                group_id=mock_group.id)

        validators.assert_retro_not_on_step(
            response,
            viewsV2.no_group_issue_retro_wrong_step.format(retro_current_step))
Beispiel #9
0
def test_sanitize_retro_for_user_and_step():
    size = 4
    mock_user_token = 'user-token'
    mock_id = 'crazy_id'
    mock_name = 'Moof!'

    groups = [retro.create_mock_group(id='id'+str(index))for index in range(size)]

    mock_retro = retro.create_mock_retroV2(id=mock_id, name=mock_name, groups=groups,
                                           issues=[retro.create_mock_issueV2()],
                                           participants=[retro.create_mock_participant(token=mock_user_token)])

    sanitized_retro = ServiceV2.sanitize_retro_for_user_and_step(mock_retro, mock_user_token)

    assert mock_id == sanitized_retro['id']
    assert mock_name == sanitized_retro['name']
    assert len(mock_retro.participants) == len(sanitized_retro['participants'])
    assert len(mock_retro.issues) == len(sanitized_retro['issues'])
    assert size == len(sanitized_retro['groups'])
    assert 'yourself' in sanitized_retro
Beispiel #10
0
    def test__group_put_group_bool_for_group_id(
            self, mock_service_view, mock_service_function_validation,
            mock_token):
        non_existing_group_id = False
        mock_group = retro.create_mock_group(id='cool_id')
        mock_issue = retro.create_mock_issueV2()
        mock_retro = retro.create_mock_retroV2(
            current_step=RetroStepV2.GROUPING.value,
            issues=[mock_issue],
            groups=[mock_group])

        object_under_test = RetroIssueViewV2()
        response = object_under_test._group_put(
            request.create_mock_request(group_id=non_existing_group_id),
            mock_issue,
            retro=mock_retro)

        assert mock_service_view.ungroup_issue.called is True
        assert 200 == response.status_code
        assert views.content_type_text_plain == response.headers[
            validators.content_type]
        assert '' == response.body
Beispiel #11
0
    def test__group_put_group_real_group_id(self, mock_service_module,
                                            mock_service_function_validation,
                                            mock_token):
        group_id = '0f3c2792-fc6c-41d5-a451-bebc3072fcc2'
        mock_group = retro.create_mock_group(id=group_id)
        mock_issue = retro.create_mock_issueV2()
        mock_retro = retro.create_mock_retroV2(
            current_step=RetroStepV2.GROUPING.value,
            issues=[mock_issue],
            groups=[mock_group])

        object_under_test = RetroIssueViewV2()
        response = object_under_test._group_put(
            request.create_mock_request(group_id=group_id),
            mock_issue,
            retro=mock_retro)

        assert mock_service_module.group_issue.called is True
        assert 200 == response.status_code
        assert views.content_type_text_plain == response.headers[
            validators.content_type]
        assert '' == response.body