Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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'
Esempio n. 4
0
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'
Esempio n. 5
0
def test_ban_link_api_view(db_session, dummy_request, fake_link_service,
                           fake_task_service, fake_file_service):
    from suma.api.views import LinkView
    l = Link(url="http://google.com", hashid='1234')
    db_session.add(l)
    db_session.flush()
    dummy_request.method = 'POST'
    dummy_request.post = '{"mode": "url"}'
    dummy_request.json_body = {"mode": "url"}
    view = LinkView(LinkResource(l), dummy_request)
    response = view.ban()
    assert response.status_code == 201
Esempio n. 6
0
def test_ban_link_api_view(db_session, dummy_request,
                           fake_link_service, fake_task_service, fake_file_service):
    from suma.api.views import LinkView
    l = Link(url="http://google.com", hashid='1234')
    db_session.add(l)
    db_session.flush()
    dummy_request.method = 'POST'
    dummy_request.post = '{"mode": "url"}'
    dummy_request.json_body = {"mode": "url"}
    view = LinkView(LinkResource(l), dummy_request)
    response = view.ban()
    assert response.status_code == 201