def test_put_group_does_not_exist(self, mock_service_function_validation, mock_token): object_under_test = RetroGroupViewV2() mock_retro = retro.create_mock_retroV2( current_step=RetroStepV2.VOTING.value) validators.assert_function_returns_group_not_found( object_under_test.put, mock_service_function_validation, mock_token, mock_retro)
def test_put_retro_step_not_valid(self, mock_service_function_validation, mock_token): object_under_test = RetroGroupViewV2() mock_retro = retro.create_mock_retroV2( current_step=RetroStepV2.GROUPING.value) validators.assert_function_returns_retro_not_on_step( object_under_test.put, mock_service_function_validation, mock_token, mock_retro, viewsV2.no_vote_group_retro_wrong_step.format( mock_retro.current_step))
def test_delete_success(self, mock_service_view, mock_service_function_validation, mock_token): existing_group_id = 'a_group_id' mock_retro = retro.create_mock_retroV2( current_step=RetroStepV2.GROUPING.value, groups=[retro.create_mock_group(id=existing_group_id)]) mock_service_function_validation.return_value.get_retro.return_value = mock_retro mock_token.token_is_valid.return_value = True mock_request = request.create_mock_request( api_version=mock_retro.version, retro_id='whatever', group_id=existing_group_id) object_under_test = RetroGroupViewV2() response = object_under_test.delete(mock_request) assert mock_service_view.delete_group.called is True assert response.status_code == 204 assert response.headers[ validators.content_type] == views.content_type_text_plain
def test_post_success(self, mock_service_view, mock_service_function_validation, mock_token): existing_group_id = 'a_group_id' mock_retro = retro.create_mock_retroV2( current_step=RetroStepV2.GROUPING.value, groups=[retro.create_mock_group(id=existing_group_id)]) mock_service_function_validation.return_value.get_retro.return_value = mock_retro mock_token.token_is_valid.return_value = True request_body = {'title': 'new title', 'section': 'Needs Improvement'} mock_request = request.create_mock_request( api_version=mock_retro.version, request_body=request_body, retro_id='whatever', group_id=existing_group_id) mock_service_view.add_new_group.return_value = existing_group_id object_under_test = RetroGroupViewV2() response = object_under_test.post(mock_request) assert mock_service_view.add_new_group.called is True assert response.status_code == 201 assert response.headers[ validators.content_type] == content_type_application_json assert json.loads(response.body) == {'id': existing_group_id}
def test_delete_user_not_valid(self, mock_service_function_validation, mock_token): object_under_test = RetroGroupViewV2() validators.assert_function_returns_user_not_valid( object_under_test.delete, mock_service_function_validation, mock_token, retro.create_mock_retroV2())
def test_delete_retro_does_not_exist(self, mock_service_function_validation, mock_token): object_under_test = RetroGroupViewV2() validators.assert_function_returns_retrospective_does_not_exist( object_under_test.delete, mock_service_function_validation)
def test_put_api_mismatch(self, mock_service_function_validation, mock_token): object_under_test = RetroGroupViewV2() validators.assert_function_returns_api_mismatch( object_under_test.put, mock_service_function_validation, retro.create_mock_retroV2())