示例#1
0
def test_delete_tags_uri(request):
    """Ensure the proper endpoint URI is accessed"""
    ShaarliV1Client(SHAARLI_URL, SHAARLI_SECRET).delete_tag('some-tag', {})
    request.assert_called_once_with('DELETE',
                                    '%s/api/v1/tags/some-tag' % SHAARLI_URL,
                                    auth=mock.ANY,
                                    json={})
示例#2
0
def test_put_links_uri(request):
    """Ensure the proper endpoint URI is accessed"""
    ShaarliV1Client(SHAARLI_URL, SHAARLI_SECRET).put_link(12, {})
    request.assert_called_once_with('PUT',
                                    '%s/api/v1/links/12' % SHAARLI_URL,
                                    auth=mock.ANY,
                                    json={})
示例#3
0
def test_put_tags_uri(request):
    """Ensure the proper endpoint URI is accessed"""
    ShaarliV1Client(SHAARLI_URL, SHAARLI_SECRET).put_tag('some-tag', {})
    request.assert_called_once_with('PUT',
                                    '%s/api/v1/tags/some-tag' % SHAARLI_URL,
                                    headers=mock.ANY,
                                    json={})
示例#4
0
def test_post_links_uri(request):
    """Ensure the proper endpoint URI is accessed"""
    ShaarliV1Client(SHAARLI_URL, SHAARLI_SECRET).post_link({})
    request.assert_called_once_with('POST',
                                    '%s/api/v1/links' % SHAARLI_URL,
                                    headers=mock.ANY,
                                    json={})
示例#5
0
def test_get_tags_uri(request):
    """Ensure the proper endpoint URI is accessed"""
    ShaarliV1Client(SHAARLI_URL, SHAARLI_SECRET).get_tags({})
    request.assert_called_once_with('GET',
                                    '%s/api/v1/tags' % SHAARLI_URL,
                                    auth=mock.ANY,
                                    verify=True,
                                    params={})
示例#6
0
def test_constructor_strip_uri(test_uri):
    """Ensure trailing / are stripped"""
    client = ShaarliV1Client(test_uri, SHAARLI_SECRET)
    assert client.uri == SHAARLI_URL
示例#7
0
def test_constructor_no_secret():
    """Missing authentication secret"""
    with pytest.raises(TypeError) as exc:
        ShaarliV1Client(SHAARLI_URL, None)
    assert "Missing Shaarli secret" in str(exc.value)
示例#8
0
def test_constructor_no_uri():
    """Missing URI"""
    with pytest.raises(TypeError) as exc:
        ShaarliV1Client(None, SHAARLI_SECRET)
    assert "Missing Shaarli URI" in str(exc.value)
示例#9
0
def test_constructor():
    """Instantiate a new client"""
    ShaarliV1Client(SHAARLI_URL, SHAARLI_SECRET)
示例#10
0
def test_get_info_invalid_uri(uri, klass, msg):
    """Invalid URI format"""
    with pytest.raises(ValueError) as exc:
        ShaarliV1Client(uri, SHAARLI_SECRET).get_info()
    assert isinstance(exc.value, klass)
    assert msg in str(exc.value)