def team_join(data): return APIResponse( body={ 'ok': True, 'ts': '1234.5678' }, status=200, headers={}, )
def team_join(data): return APIResponse( body={ "ok": True, "ts": "1234.5678" }, status=200, headers={}, )
def callback(data): return APIResponse( body={ "ok": True, "channel": { "id": data["users"].split(",")[0].replace("U", "D"), }, }, status=200, headers={}, )
def im_open(data): return APIResponse( body={ 'ok': True, 'channel': { 'id': data['user'].replace('U', 'D'), }, }, status=200, headers={}, )
def callback(data): return APIResponse( body={ 'ok': True, 'channel': { 'id': data['users'].split(',')[0].replace('U', 'D'), }, }, status=200, headers={}, )
async def test_call(event_loop, bot_config, response_mock): token = 'asdf1234' response_mock.post( 'https://slack.com/api/test11', body=json.dumps({'res': 'hello world!'}), headers={'content-type': 'application/json'}, status=200, ) response_mock.post( 'https://slack.com/api/test12', body=json.dumps({ 'res': 'hello world!', 'data': { 'extra': 'wow' } }), headers={'content-type': 'application/json'}, status=200, ) response_mock.post( 'https://slack.com/api/test21', body=json.dumps({'error': 'aaa'}), headers={'content-type': 'application/json'}, status=404, ) response_mock.post( 'https://slack.com/api/test22', body=json.dumps({'error': 'aaa'}), headers={'content-type': 'application/json'}, status=404, ) response_mock.post( 'https://slack.com/api/test3', body=json.dumps({'res': 'hello world!'}), headers={'content-type': 'application/json'}, status=200, ) box = Box() bot = Bot(bot_config, event_loop, using_box=box) bot.api.throttle_interval = defaultdict(lambda: timedelta(0)) res = await bot.call('test11') assert res == APIResponse( body={'res': 'hello world!'}, status=200, headers={'content-type': 'application/json'}, ) res = await bot.call('test12', data={'extra': 'wow'}) assert res == APIResponse( body={ 'res': 'hello world!', 'data': { 'extra': 'wow' } }, status=200, headers={'content-type': 'application/json'}, ) res = await bot.call('test21') assert res == APIResponse( body={'error': 'aaa'}, status=404, headers={'content-type': 'application/json'}, ) res = await bot.call('test22', data={'extra': 'wow'}) assert res == APIResponse( body={'error': 'aaa'}, status=404, headers={'content-type': 'application/json'}, ) res = await bot.call('test3', token=token) assert res == APIResponse( body={'res': 'hello world!'}, status=200, headers={'content-type': 'application/json'}, )
async def test_call(fx_config, response_mock): token = 'asdf1234' response_mock.post( 'https://slack.com/api/test11', body=json.dumps({'res': 'hello world!'}), headers={'content-type': 'application/json'}, status=200, ) response_mock.post( 'https://slack.com/api/test12', body=json.dumps({ 'res': 'hello world!', 'data': { 'extra': 'wow' } }), headers={'content-type': 'application/json'}, status=200, ) response_mock.post( 'https://slack.com/api/test21', body=json.dumps({'error': 'aaa'}), headers={'content-type': 'application/json'}, status=404, ) response_mock.post( 'https://slack.com/api/test22', body=json.dumps({'error': 'aaa'}), headers={'content-type': 'application/json'}, status=404, ) response_mock.post( 'https://slack.com/api/test3', body=json.dumps({'res': 'hello world!'}), headers={'content-type': 'application/json'}, status=200, ) box = Box() bot = Bot(fx_config, using_box=box) res = await bot.call('test11') assert res == APIResponse( body={'res': 'hello world!'}, status=200, headers={'content-type': 'application/json'}, ) res = await bot.call('test12', data={'extra': 'wow'}) assert res == APIResponse( body={ 'res': 'hello world!', 'data': { 'extra': 'wow' } }, status=200, headers={'content-type': 'application/json'}, ) res = await bot.call('test21') assert res == APIResponse( body={'error': 'aaa'}, status=404, headers={'content-type': 'application/json'}, ) res = await bot.call('test22', data={'extra': 'wow'}) assert res == APIResponse( body={'error': 'aaa'}, status=404, headers={'content-type': 'application/json'}, ) res = await bot.call('test3', token=token) assert res == APIResponse( body={'res': 'hello world!'}, status=200, headers={'content-type': 'application/json'}, )
async def test_call(bot_config, response_mock): token = "asdf1234" response_mock.post( "https://slack.com/api/test11", body=json.dumps({"res": "hello world!"}), headers={"content-type": "application/json"}, status=200, ) response_mock.post( "https://slack.com/api/test12", body=json.dumps({ "res": "hello world!", "data": { "extra": "wow" } }), headers={"content-type": "application/json"}, status=200, ) response_mock.post( "https://slack.com/api/test21", body=json.dumps({"error": "aaa"}), headers={"content-type": "application/json"}, status=404, ) response_mock.post( "https://slack.com/api/test22", body=json.dumps({"error": "aaa"}), headers={"content-type": "application/json"}, status=404, ) response_mock.post( "https://slack.com/api/test3", body=json.dumps({"res": "hello world!"}), headers={"content-type": "application/json"}, status=200, ) box = Box() bot = Bot(bot_config, using_box=box) bot.api.throttle_interval = defaultdict(lambda: timedelta(0)) res = await bot.call("test11") assert res == APIResponse( body={"res": "hello world!"}, status=200, headers={"content-type": "application/json"}, ) res = await bot.call("test12", data={"extra": "wow"}) assert res == APIResponse( body={ "res": "hello world!", "data": { "extra": "wow" } }, status=200, headers={"content-type": "application/json"}, ) res = await bot.call("test21") assert res == APIResponse( body={"error": "aaa"}, status=404, headers={"content-type": "application/json"}, ) res = await bot.call("test22", data={"extra": "wow"}) assert res == APIResponse( body={"error": "aaa"}, status=404, headers={"content-type": "application/json"}, ) res = await bot.call("test3", token=token) assert res == APIResponse( body={"res": "hello world!"}, status=200, headers={"content-type": "application/json"}, )