add more tests
This commit is contained in:
@@ -174,6 +174,142 @@ class TestWallabag:
|
|||||||
assert tag_id not in resp_tags_id
|
assert tag_id not in resp_tags_id
|
||||||
await self._delete_entry(wallabag, entry_id)
|
await self._delete_entry(wallabag, entry_id)
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_put_annotations(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
annotation = await wallabag.post_annotations(
|
||||||
|
entry_id,
|
||||||
|
ranges=[
|
||||||
|
{"start": "/p[1]", "startOffset": 0, "end": "/p[1]", "endOffset": 10}
|
||||||
|
],
|
||||||
|
quote="test quote",
|
||||||
|
text="test annotation",
|
||||||
|
)
|
||||||
|
annotation_id = annotation["id"]
|
||||||
|
data = await wallabag.put_annotations(annotation_id)
|
||||||
|
assert data is not None
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_reload_entry(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
assert isinstance(entry_id, int)
|
||||||
|
try:
|
||||||
|
data = await wallabag.patch_entry_reload(entry_id)
|
||||||
|
assert data
|
||||||
|
except Exception as e:
|
||||||
|
if "304" in str(e):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_entries_exists(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_url = entry["url"]
|
||||||
|
data = await wallabag.entries_exists(url=entry_url)
|
||||||
|
if isinstance(data, dict) and "exists" in data:
|
||||||
|
assert data["exists"] is True
|
||||||
|
data = await wallabag.entries_exists(url="https://nonexistent.example.com")
|
||||||
|
if isinstance(data, dict) and "exists" in data:
|
||||||
|
assert data["exists"] is False
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delete_tag(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
tags = ["tag_for_deletion"]
|
||||||
|
await wallabag.post_entry_tags(entry_id, tags)
|
||||||
|
all_tags = await wallabag.get_tags()
|
||||||
|
tag_to_delete = next(
|
||||||
|
(t for t in all_tags if t["label"] == "tag_for_deletion"), None
|
||||||
|
)
|
||||||
|
if tag_to_delete:
|
||||||
|
data = await wallabag.delete_tag(tag_to_delete["id"])
|
||||||
|
assert data
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delete_tag_label(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
tags = ["label_for_deletion"]
|
||||||
|
await wallabag.post_entry_tags(entry_id, tags)
|
||||||
|
data = await wallabag.delete_tag_label("label_for_deletion")
|
||||||
|
assert data
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delete_tags_label(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
tags = ["multi_delete_1", "multi_delete_2"]
|
||||||
|
await wallabag.post_entry_tags(entry_id, tags)
|
||||||
|
data = await wallabag.delete_tags_label(tags)
|
||||||
|
assert data is not None
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_annotations(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
data = await wallabag.get_annotations(entry_id)
|
||||||
|
assert isinstance(data, (dict, list))
|
||||||
|
if isinstance(data, dict):
|
||||||
|
assert "rows" in data or "total" in data
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_post_annotations(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
data = await wallabag.post_annotations(
|
||||||
|
entry_id,
|
||||||
|
ranges=[
|
||||||
|
{"start": "/p[1]", "startOffset": 0, "end": "/p[1]", "endOffset": 10}
|
||||||
|
],
|
||||||
|
quote="test quote",
|
||||||
|
text="test annotation",
|
||||||
|
)
|
||||||
|
assert data
|
||||||
|
assert "id" in data
|
||||||
|
return data["id"]
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_put_annotations(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
annotation = await wallabag.post_annotations(
|
||||||
|
entry_id,
|
||||||
|
ranges=[
|
||||||
|
{"start": "/p[1]", "startOffset": 0, "end": "/p[1]", "endOffset": 10}
|
||||||
|
],
|
||||||
|
quote="test quote",
|
||||||
|
text="test annotation",
|
||||||
|
)
|
||||||
|
annotation_id = annotation["id"]
|
||||||
|
data = await wallabag.put_annotations(annotation_id)
|
||||||
|
assert data is not None
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delete_annotations(self, setup_class):
|
||||||
|
wallabag, entry = setup_class
|
||||||
|
entry_id = entry["id"]
|
||||||
|
annotation = await wallabag.post_annotations(
|
||||||
|
entry_id,
|
||||||
|
ranges=[
|
||||||
|
{"start": "/p[1]", "startOffset": 0, "end": "/p[1]", "endOffset": 10}
|
||||||
|
],
|
||||||
|
quote="test quote",
|
||||||
|
text="test annotation",
|
||||||
|
)
|
||||||
|
annotation_id = annotation["id"]
|
||||||
|
data = await wallabag.delete_annotations(annotation_id)
|
||||||
|
assert data
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_version(self, setup_class):
|
||||||
|
wallabag, _ = setup_class
|
||||||
|
data = await wallabag.version
|
||||||
|
assert data
|
||||||
|
|
||||||
async def _create_entry(self, wallabag):
|
async def _create_entry(self, wallabag):
|
||||||
data = self.entry_data.copy()
|
data = self.entry_data.copy()
|
||||||
data["title"] = "Some title 2"
|
data["title"] = "Some title 2"
|
||||||
|
|||||||
@@ -219,20 +219,6 @@ class Wallabag(object):
|
|||||||
ext=self.format)
|
ext=self.format)
|
||||||
return await self.query(url, "get", **params)
|
return await self.query(url, "get", **params)
|
||||||
|
|
||||||
async def reaload_entry(self, entry):
|
|
||||||
"""
|
|
||||||
PATCH /api/entries/{entry}/reload.{_format}
|
|
||||||
|
|
||||||
Reload a single entry
|
|
||||||
|
|
||||||
:param entry: \w+ an integer The Entry ID
|
|
||||||
:return data related to the ext
|
|
||||||
"""
|
|
||||||
params = {'access_token': self.token}
|
|
||||||
url = '/api/entries/{entry}/reload.{ext}'.format(entry=entry,
|
|
||||||
ext=self.format)
|
|
||||||
return await self.query(url, "patch", **params)
|
|
||||||
|
|
||||||
async def patch_entries(self, entry, **kwargs):
|
async def patch_entries(self, entry, **kwargs):
|
||||||
"""
|
"""
|
||||||
PATCH /api/entries/{entry}.{_format}
|
PATCH /api/entries/{entry}.{_format}
|
||||||
|
|||||||
Reference in New Issue
Block a user