Exemplo n.º 1
0
    def test_delete_issue_doesnt_exist(self, mock_service_function_validation,
                                       mock_service_view, mock_token):
        issue_id = 'non-existing_id'
        mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro(
            current_step=RetroStep.ADDING_ISSUES.value,
            issues=[retro.create_mock_issue(id='some_other_id')])
        mock_token.token_is_valid.return_value = True

        object_under_test = RetroIssueView()
        response = object_under_test.delete(
            request.create_mock_request(retro_id='whatever',
                                        issue_id=issue_id))

        validators.assert_issue_not_found(response, issue_id)
Exemplo n.º 2
0
    def test_delete_issue_not_owned_by_user(self,
                                            mock_service_function_validation,
                                            mock_service_view, mock_token):
        issue_id = 'issue_id'
        mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro(
            current_step=RetroStep.ADDING_ISSUES.value,
            issues=[retro.create_mock_issue(id=issue_id)])
        mock_token.token_is_valid.return_value = True
        mock_token.issue_owned_by_participant.return_value = False

        object_under_test = RetroIssueView()
        response = object_under_test.delete(
            request.create_mock_request(retro_id='whatever',
                                        issue_id=issue_id))

        validators.assert_user_not_owner_of_issue(response, issue_id)
Exemplo n.º 3
0
    def test_delete_success(self, mock_service_function_validation,
                            mock_service_view, mock_token):
        issue_id = 'issue_id'
        mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro(
            current_step=RetroStep.ADDING_ISSUES.value,
            issues=[retro.create_mock_issue(id=issue_id)])
        mock_token.token_is_valid.return_value = True
        mock_token.issue_owned_by_participant.return_value = True

        object_under_test = RetroIssueView()
        response = object_under_test.delete(
            request.create_mock_request(retro_id='whatever',
                                        issue_id=issue_id))

        assert 204 == response.status_code
        assert views.content_type_text_plain == response.headers[
            validators.content_type]
        assert '' == response.body
Exemplo n.º 4
0
 def test_put_not_voting_step(self, mock_service_function_validation,
                              mock_service_view, mock_token):
     object_under_test = RetroIssueView()
     mock_retro = retro.create_mock_retro(
         current_step=RetroStep.ADDING_ISSUES.value)
     validators.assert_function_returns_retro_not_on_step(
         object_under_test.put, mock_service_function_validation,
         mock_token, mock_retro,
         views.no_vote_issue_retro_wrong_step.format(
             mock_retro.current_step))
Exemplo n.º 5
0
 def test_delete_retro_step_not_valid(self,
                                      mock_service_function_validation,
                                      mock_service_view, mock_token):
     object_under_test = RetroIssueView()
     mock_retro = retro.create_mock_retro(
         current_step=RetroStep.VOTING.value)
     validators.assert_function_returns_retro_not_on_step(
         object_under_test.delete, mock_service_function_validation,
         mock_token, mock_retro,
         views.no_delete_issue_retro_wrong_step.format(
             mock_retro.current_step))
Exemplo n.º 6
0
    def test_post_new_issue_success(self, mock_service_function_validation,
                                    mock_service_view, mock_token):
        request_body = {
            'title': 'More timely PR reviews',
            'section': 'Needs Improvement'
        }
        mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro(
        )
        mock_token.token_is_valid.return_value = True
        mock_issue_id = 'new_issue_id'
        mock_service_view.add_new_issue.return_value = mock_issue_id

        object_under_test = RetroIssueView()
        response = object_under_test.post(
            request.create_mock_request(request_body, retro_id='whatever'))

        assert response.status_code == 201
        assert response.headers[
            validators.content_type] == content_type_application_json
        assert json.loads(response.body) == {'id': mock_issue_id}
Exemplo n.º 7
0
    def test_put_issue_unvote_success(self, mock_service_function_validation,
                                      mock_service_view, mock_token):
        request_body = {
            'vote': False,
        }
        mock_issue_id = 'some_issue_id'
        mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro(
            current_step=RetroStep.VOTING.value,
            issues=[retro.create_mock_issue(id=mock_issue_id)])
        mock_token.token_is_valid.return_value = True

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

        assert mock_service_view.unvote_for_issue.called is True
        assert 200 == response.status_code
        assert views.content_type_text_plain == response.headers[
            validators.content_type]
        assert '' == response.body
Exemplo n.º 8
0
 def test_delete_user_not_valid(self, mock_service_function_validation,
                                mock_service_view, mock_token):
     object_under_test = RetroIssueView()
     validators.assert_function_returns_user_not_valid(
         object_under_test.delete, mock_service_function_validation,
         mock_token, retro.create_mock_retro())
Exemplo n.º 9
0
 def test_delete_retro_not_found(self, mock_service_function_validation,
                                 mock_service_view, mock_token):
     object_under_test = RetroIssueView()
     validators.assert_function_returns_retrospective_does_not_exist(
         object_under_test.delete, mock_service_function_validation)
Exemplo n.º 10
0
 def test_put_api_mismatch(self, mock_service_function_validation,
                           mock_service_view, mock_token):
     object_under_test = RetroIssueView()
     validators.assert_function_returns_api_mismatch(
         object_under_test.put, mock_service_function_validation,
         retro.create_mock_retro())