diff --git a/glQiwiApi/core/basic_requests_api.py b/glQiwiApi/core/basic_requests_api.py index 3f1da7de..4a1b39bf 100644 --- a/glQiwiApi/core/basic_requests_api.py +++ b/glQiwiApi/core/basic_requests_api.py @@ -2,7 +2,8 @@ from itertools import repeat from typing import ( Dict, - AsyncGenerator + AsyncGenerator, + NoReturn ) from typing import Optional, List, Union @@ -32,7 +33,7 @@ class HttpXParser(AbstractParser): _sleep_time = 2 - def __init__(self): + def __init__(self) -> NoReturn: super(HttpXParser, self).__init__() self.base_headers = { 'User-Agent': USER_AGENT, diff --git a/glQiwiApi/core/web_hooks/filter.py b/glQiwiApi/core/web_hooks/filter.py index 2fc7c5fe..3ed71e8e 100644 --- a/glQiwiApi/core/web_hooks/filter.py +++ b/glQiwiApi/core/web_hooks/filter.py @@ -31,7 +31,7 @@ def or_(func1: CF, func2: CF, event: Any) -> bool: class Filter: """ Base Filter object, callback container - Same approach used in https://github.com/uwinx/garnet + """ __name__: str diff --git a/glQiwiApi/qiwi/qiwi_api.py b/glQiwiApi/qiwi/qiwi_api.py index a28b61ef..a1eaeaf1 100644 --- a/glQiwiApi/qiwi/qiwi_api.py +++ b/glQiwiApi/qiwi/qiwi_api.py @@ -9,7 +9,6 @@ from aiohttp import web, ClientSession from aiohttp.abc import AbstractAccessLogger -import glQiwiApi.utils.basics as api_helper from glQiwiApi.core import ( AbstractPaymentWrapper, RequestManager, @@ -42,6 +41,7 @@ ) from glQiwiApi.types.basics import DEFAULT_CACHE_TIME from glQiwiApi.types.qiwi_types.bill import RefundBill +from glQiwiApi.utils import basics as api_helper from glQiwiApi.utils.exceptions import ( InvalidData, InvalidCardNumber, diff --git a/setup.py b/setup.py index 7355814f..a87c0e5a 100644 --- a/setup.py +++ b/setup.py @@ -1,27 +1,35 @@ +import pathlib + import setuptools -with open("README.md", "r") as fh: - long_description = fh.read() +PATH = pathlib.Path(__file__).parent + +README = (PATH / "README.md").read_text() setuptools.setup( - packages=setuptools.find_packages(), - include_package_data=True, + packages=setuptools.find_packages(exclude=( + 'tests', 'examples', 'examples.*') + ), name="glQiwiApi", # Replace with your own username - version="0.2.18", + version="0.2.19", author="GLEF1X", author_email="glebgar567@gmail.com", description="Light and fast wrapper for qiwi and yoomoney", package_data={"glQiwiApi": ["py.typed", "*.pyi", "**/*.pyi"]}, # Длинное описание, которое будет отображаться на странице PyPi. # Использует README.md репозитория для заполнения. - long_description=long_description, + long_description=README, # Определяет тип контента, используемый в long_description. long_description_content_type="text/markdown", + license="MIT", url="https://github.com/GLEF1X/glQiwiApi", classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Build Tools', ], install_requires=[ "pytz==2021.1", diff --git a/tests/qiwi_test.py b/tests/qiwi_test.py index 5658e8e6..30cea0da 100644 --- a/tests/qiwi_test.py +++ b/tests/qiwi_test.py @@ -1,12 +1,13 @@ import datetime import unittest -from glQiwiApi import QiwiWrapper, types, sync, RequestError, InvalidData +from glQiwiApi import QiwiWrapper, types, sync, RequestError, \ + InvalidData, QiwiMaps from glQiwiApi.core import AioTestCase -TOKEN = 'token' -WALLET = '+number' -QIWI_SECRET = 'p2p token' +TOKEN = 'TOKEN' +WALLET = '+NUMBER' +QIWI_SECRET = 'P2P TOKEN' class SyncQiwiTestCase(unittest.TestCase): @@ -20,11 +21,11 @@ def test_account_info(self): self.assertTrue(isinstance(info, types.QiwiAccountInfo)) def test_commission(self) -> None: - commission = sync(self.wallet.commission, to_account='+number', + commission = sync(self.wallet.commission, to_account='+74957556983', pay_sum=1) self.assertTrue(isinstance(commission, types.Commission)) with self.assertRaises(RequestError): - sync(self.wallet.commission, to_account='+number', + sync(self.wallet.commission, to_account='+380985272064', pay_sum=-1) def test_fail(self): @@ -36,10 +37,10 @@ def test_fail(self): end_date=datetime.datetime.now() ) with self.assertRaises(RequestError): - sync(self.wallet.to_wallet, to_number='+wrong_number', + sync(self.wallet.to_wallet, to_number='+38056546456454', trans_sum=1) with self.assertRaises(RequestError): - sync(self.wallet.to_wallet, to_number='+number', + sync(self.wallet.to_wallet, to_number='+74957556983', trans_sum=-1) def test_transactions_history(self): @@ -64,11 +65,11 @@ def test_transaction_info(self): self.wallet.transaction_info, info[0].transaction_id, info[0].type - ), types.Transaction) + ) , types.Transaction) ) def test_to_wallet(self): - txn_id = sync(self.wallet.to_wallet, to_number='+number', + txn_id = sync(self.wallet.to_wallet, to_number='+74957556983', trans_sum=1) self.assertTrue(isinstance(txn_id, str)) @@ -104,11 +105,11 @@ def test_available_balances(self): ) def test_to_card(self): - txn_id = sync(self.wallet.to_card, to_card='card_number', + txn_id = sync(self.wallet.to_card, to_card='4890494688391549', trans_sum=1) self.assertTrue(isinstance(txn_id, str)) with self.assertRaises(RequestError): - sync(self.wallet.to_card, to_card='+wrong_number', trans_sum=1) + sync(self.wallet.to_card, to_card='+74957556983', trans_sum=1) def test_test_limits(self): limits = sync(self.wallet.get_limits) @@ -135,8 +136,15 @@ def test_webhook_delete_fail(self): class AsyncQiwiTestCase(AioTestCase): + """ + Async qiwi unit test, which using async with context manager + Can raise many exceptions, because there aren't native async unit tests + in Python + """ + def setUp(self) -> None: self.wallet = QiwiWrapper(TOKEN, WALLET, secret_p2p=QIWI_SECRET) + self.maps = QiwiMaps() async def test_account_info(self): async with self.wallet as w: @@ -145,21 +153,23 @@ async def test_account_info(self): async def test_commission(self) -> None: async with self.wallet as w: - commission = await (w.commission(to_account='+number', + commission = await (w.commission(to_account='+74957556983', pay_sum=1)) self.assertTrue(isinstance(commission, types.Commission)) with self.assertRaises(RequestError): async with self.wallet as w: - await w.commission(to_account='+number', + await w.commission(to_account='+74957556983', pay_sum=-1) async def test_fail(self): with self.assertRaises(InvalidData): async with self.wallet as w: - await w.fetch_statistics( - start_date=datetime.datetime.now() - datetime.timedelta( - days=100), - end_date=datetime.datetime.now()) + start_date = datetime.datetime.now() - datetime.timedelta(days=100) + with self.assertRaises(InvalidData): + await w.fetch_statistics( + start_date=start_date, + end_date=datetime.datetime.now() + ) with self.assertRaises(RequestError): async with self.wallet as w: @@ -167,7 +177,7 @@ async def test_fail(self): trans_sum=1) with self.assertRaises(RequestError): async with self.wallet as w: - await w.to_wallet(to_number='+number', + await w.to_wallet(to_number='+74957556983', trans_sum=-1) async def test_transactions_history(self): @@ -200,7 +210,7 @@ async def test_transaction_info(self): async def test_to_wallet(self): async with self.wallet as w: - txn_id = await w.to_wallet(to_number='+number', + txn_id = await w.to_wallet(to_number='+74957556983', trans_sum=1) self.assertTrue(isinstance(txn_id, str)) @@ -244,11 +254,10 @@ async def test_available_balances(self): async def test_to_card(self): async with self.wallet as w: - txn_id = await w.to_card(to_card='card', + txn_id = await w.to_card(to_card='4890494688391549', trans_sum=1) with self.assertRaises(RequestError): - txn_id = await w.to_card(to_card='+380985272064', - trans_sum=1) + sync(w.to_card, to_card='+74957556983', trans_sum=1) self.assertTrue(isinstance(txn_id, str)) async def test_test_limits(self): @@ -278,6 +287,13 @@ async def test_webhook_delete_fail(self): await self.wallet.bind_webhook(url=hook_url, delete_old=True) + async def test_qiwi_maps(self): + async with self.maps as map_manager: + partners = await map_manager.partners() + self.assertTrue( + all(isinstance(partner, types.Partner) for partner in partners) + ) + if __name__ == '__main__': unittest.main()