示例#1
0
async def test_client_get_raises_error(aresponses):
    host = 'realestates.com'
    path = '/list'
    aresponses.add(host, path, 'get', response=aiohttp.ClientOSError)

    webclient = client.Client()
    assert await webclient.get(f'https://{host}{path}') == ''
    await webclient.close()
示例#2
0
async def test_client_close(amocker):
    webclient = client.Client()

    with amocker.patch.object(webclient.session, 'close') as close_mock:
        assert await webclient.close() is None

    assert close_mock.called
    assert close_mock.call_args == amocker.call()
示例#3
0
def record_session(duration, interval, mode, format):
    app = client.Client()
    t1 = threading.Thread(app.start(recording=True, mode=mode))
    t1.start()
    sc = utils_capture.InputRecord(recording_folder,
                                   config.capture_mode.get(mode)[0],
                                   config.capture_mode.get(mode)[1],
                                   interval=interval)
    t2 = threading.Thread(target=sc.begin_recording())
    t2.start()
    sleep(duration)
    sc.stop_recording(format)
    app.stop()
    return
示例#4
0
from app.parser.parser import Parser

import logging
import sys

root = logging.getLogger()
root.setLevel(logging.INFO)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.INFO)
formatter = logging.Formatter('[%(asctime)s] %(levelname)s in %(module)s: %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)

telegram_api_id = int(environ.get("TELEGRAM_API_ID", 0))
telegram_api_hash = str(environ.get("TELEGRAM_API_HASH", ""))
telegram_key = str(environ.get("TELEGRAM_KEY",""))
telegram_bot_token = str(environ.get("TELEGRAM_BOT_TOKEN", ""))

loop = asyncio.get_event_loop()
dynamoDb = boto3.resource('dynamodb')
parser = Parser()
bot = telegram.Bot(token=telegram_bot_token)
comparator = Compare(dynamoDb, parser)
t_client = client.Client(telegram_key, telegram_api_id, telegram_api_hash, comparator, bot, root)

try:
    loop.run_until_complete(t_client.start())
    t_client.run_until_disconnected()
finally:
    t_client.disconnect()
示例#5
0
def run():
    app = client.Client()
    app.start()
    return
示例#6
0
async def test_client_init():
    webclient = client.Client()
    assert isinstance(webclient.session, aiohttp.ClientSession)
    await webclient.close()