fix: use aiohttp ClientSession as a context manager
This commit is contained in:
@@ -35,24 +35,24 @@ class TestWallabag:
|
||||
"original_url": "http://localhost",
|
||||
}
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
@pytest.fixture(scope="function")
|
||||
async def configuration(self):
|
||||
return load_test_config(CONFIG_PATH)
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
@pytest.fixture(scope="function")
|
||||
async def setup_class(self, configuration):
|
||||
access_token = await Wallabag.get_token(**configuration)
|
||||
async with aiohttp.ClientSession() as session:
|
||||
wallabag = Wallabag(
|
||||
host=configuration["host"],
|
||||
token=access_token,
|
||||
client_id=configuration["client_id"],
|
||||
client_secret=configuration["client_secret"],
|
||||
aio_sess=aiohttp.ClientSession(),
|
||||
aio_sess=session,
|
||||
)
|
||||
entry = await wallabag.post_entries(**self.entry_data)
|
||||
yield wallabag, entry
|
||||
await wallabag.delete_entries(entry["id"])
|
||||
await wallabag.aio_sess.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_token(self, configuration):
|
||||
@@ -105,7 +105,7 @@ class TestWallabag:
|
||||
entry_data = self.entry_data.copy()
|
||||
entry_data["url"] = "https://example.org"
|
||||
data = await wallabag.post_entries(**entry_data)
|
||||
assert data is True
|
||||
assert data
|
||||
assert isinstance(data["id"], int)
|
||||
await wallabag.delete_entries(data["id"])
|
||||
|
||||
@@ -133,7 +133,7 @@ class TestWallabag:
|
||||
entry_id = await self._create_entry(wallabag)
|
||||
assert isinstance(entry_id, int)
|
||||
data = await wallabag.delete_entries(entry_id)
|
||||
assert data is True
|
||||
assert data
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_post_entry_tags(self, setup_class):
|
||||
@@ -143,7 +143,7 @@ class TestWallabag:
|
||||
tags = ["foo", "bar"]
|
||||
assert isinstance(tags, list)
|
||||
data = await wallabag.post_entry_tags(entry_id, tags)
|
||||
assert data is True
|
||||
assert data
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_entry_tag(self, setup_class):
|
||||
|
||||
Reference in New Issue
Block a user