git reimport
This commit is contained in:
0
tests/zvk/util/__init__.py
Normal file
0
tests/zvk/util/__init__.py
Normal file
23
tests/zvk/util/test_db.py
Normal file
23
tests/zvk/util/test_db.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from pytest import fixture
|
||||
from sqlalchemy import Integer, String, Column
|
||||
|
||||
from zvk.util.db import Database, DBBase
|
||||
|
||||
|
||||
|
||||
|
||||
class SomeTable(DBBase):
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
s = Column(String)
|
||||
|
||||
|
||||
def test_db(db):
|
||||
db.create_all()
|
||||
|
||||
with db as session:
|
||||
session.add(SomeTable(s='123'))
|
||||
session.add(SomeTable(s='132'))
|
||||
session.add(SomeTable(s='1232132132'))
|
||||
|
||||
assert len(session.query(SomeTable).all()) == 3
|
28
tests/zvk/util/test_download.py
Normal file
28
tests/zvk/util/test_download.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
|
||||
from zvk.event.consumer import on_startup
|
||||
from zvk.util.download import download_file
|
||||
from zvk.util.zlogging import logger
|
||||
|
||||
|
||||
@on_startup
|
||||
async def test_action(bot, net, db):
|
||||
filename = await download_file(
|
||||
db,
|
||||
net,
|
||||
'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
|
||||
)
|
||||
logger.info(f'{filename}')
|
||||
filename = await download_file(
|
||||
db,
|
||||
net,
|
||||
'https://yastatic.net/www/_/x/Q/xk8YidkhGjIGOrFm_dL5781YA.svg',
|
||||
)
|
||||
logger.info(f'{filename}')
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download(bot):
|
||||
bot.event_queue.register_consumer(test_action)
|
||||
|
||||
assert await bot.run()
|
19
tests/zvk/util/test_network.py
Normal file
19
tests/zvk/util/test_network.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
from zvk.util.network import Network
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_request():
|
||||
net = Network({
|
||||
'net': {
|
||||
'timeout': 10
|
||||
}
|
||||
})
|
||||
net.initialize()
|
||||
|
||||
response, text = await net.get_text('http://ya.ru')
|
||||
|
||||
assert response.status == 200
|
||||
|
||||
assert len(text) > 200
|
Reference in New Issue
Block a user