Skip to content

Commit

Permalink
async test updates #2
Browse files Browse the repository at this point in the history
  • Loading branch information
prawn-cake committed Oct 27, 2017
1 parent 164161a commit d3d9aad
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions vk_requests/tests/test_session_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
import asyncio
import pytest
import aiohttp
from vk_requests import settings, API
from vk_requests.async.session import AsyncVKSession


@pytest.mark.skipIf(sys.version_info < (3, 0))
class TestAsyncVKSession(object):
@staticmethod
def get_real_vk_session(**kwargs):
return AsyncVKSession(app_id=settings.APP_ID,
user_login=settings.USER_LOGIN,
user_password=settings.USER_PASSWORD,
phone_number=settings.PHONE_NUMBER, **kwargs)

@pytest.mark.asyncio
async def test_something(self):
session = aiohttp.ClientSession()
Expand All @@ -16,3 +25,17 @@ async def test_something(self):
print("resp2: " + str(await resp.json()))

session.close()

def test_run_future(self):
loop = asyncio.get_event_loop()
session = aiohttp.ClientSession()
f = asyncio.ensure_future(session.get('https://api.github.com/events'))
loop.run_until_complete(f)
print(f.result())

@pytest.mark.asyncio
async def test_async_api(self):
session = self.get_real_vk_session()
api = API(session=session)
result = await api.wall.get(owner_id=1)
print(result)

0 comments on commit d3d9aad

Please sign in to comment.