def test_put_user_ready_success_true(self, mock_service_function_validation, mock_service_view, mock_token): request_body = {'ready': True} mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro( ) mock_token.token_is_valid.return_value = True object_under_test = RetroUserView() response = object_under_test.put( request.create_mock_request(request_body, retro_id='whatever')) assert response.status_code == 200 assert response.headers[ validators.content_type] == views.content_type_text_plain assert response.body == ''
def test_post_new_user_success(self, mock_service_function_validation, mock_service_view, mock_token): request_body = {'name': 'new_user'} mock_service_function_validation.return_value.get_retro.return_value = retro.create_mock_retro( ) new_user_token = 'a-special-new-token' mock_service_view.add_participant.return_value = new_user_token object_under_test = RetroUserView() retro_id = 'whatever_retro_id' response = object_under_test.post( request.create_mock_request(request_body, retro_id=retro_id)) assert response.status_code == 201 assert response.headers[ validators.content_type] == content_type_application_json assert json.loads(response.body) == {'token': new_user_token}
def test_put_user_not_valid(self, mock_service_function_validation, mock_service_view, mock_token): object_under_test = RetroUserView() validators.assert_function_returns_user_not_valid( object_under_test.put, mock_service_function_validation, mock_token, retro.create_mock_retro())
def test_put_retro_not_found(self, mock_service_function_validation, mock_service_view, mock_token): object_under_test = RetroUserView() validators.assert_function_returns_retrospective_does_not_exist( object_under_test.put, mock_service_function_validation)
def test_post_api_mismatch(self, mock_service_function_validation, mock_service_view, mock_token): object_under_test = RetroUserView() validators.assert_function_returns_api_mismatch( object_under_test.post, mock_service_function_validation, retro.create_mock_retro())