def test_create_link_api_view_fail_validation(dummy_request, fake_link_service, fake_task_service, fake_file_service): from suma.api.views import LinkView dummy_request.method = 'POST' dummy_request.post = '{"unknown": "http://google.com"}' dummy_request.json_body = {"unknown": "http://google.com"} view = LinkView(LinkFactory(dummy_request), dummy_request) response = view.create_link() assert response.status_code == 400
def test_create_link_api_view(dummy_request, fake_link_service, fake_task_service, fake_file_service): from suma.api.views import LinkView dummy_request.method = 'POST' dummy_request.post = '{"url": "http://google.com"}' dummy_request.json_body = {"url": "http://google.com"} view = LinkView(LinkFactory(dummy_request), dummy_request) response_obj = view.create_link() assert dummy_request.response.status_code == 201 assert response_obj["data"]["id"] == 1 assert response_obj["data"]["attributes"]["hashid"] == '1234'