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={})
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={})
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={})
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={})
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={})
def test_constructor_strip_uri(test_uri): """Ensure trailing / are stripped""" client = ShaarliV1Client(test_uri, SHAARLI_SECRET) assert client.uri == SHAARLI_URL
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)
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)
def test_constructor(): """Instantiate a new client""" ShaarliV1Client(SHAARLI_URL, SHAARLI_SECRET)
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)