def test_user_lookup_handler_missing(conn): values = {'format': 'json', 'client': 'app1key', 'user': '******'} builder = EnvironBuilder(method='POST', data=values) handler = UserLookupHandler(connect=provider(conn)) resp = handler.handle(Request(builder.get_environ())) assert_equals('application/json; charset=UTF-8', resp.content_type) assert_equals('400 BAD REQUEST', resp.status) data = json.loads(resp.data) assert_equal('error', data['status']) assert_equal(6, data['error']['code'])
def test_user_lookup_handler(conn): values = {'format': 'json', 'client': 'app1key', 'user': '******'} builder = EnvironBuilder(method='POST', data=values) handler = UserLookupHandler(connect=provider(conn)) resp = handler.handle(Request(builder.get_environ())) assert_equals('application/json; charset=UTF-8', resp.content_type) assert_equals('200 OK', resp.status) data = json.loads(resp.data) assert_equal('ok', data['status']) assert_equal('user1key', data['user']['apikey'])