def test_avg_difficulty_level_query(self, client): res = client.get(build_query(self.api, ['?level=6'])) assert res.status_code == 200 assert res.mimetype == JSON_MIME_TYPE assert validate(res.json['data'], self.schema) is None assert res.json['data']['avgDifficulty'] == 6
def get_transaction(self, id: str): endpoint = inspect.currentframe().f_code.co_name url = f"{self.url_base}/{endpoint}" args = locals() query = build_query(args) if query is None: raise Exception("Must provide at least one query parameter") return get_resp(f"{url}?{query}")
def test_list_id_not_found(self, client): res = client.get( build_query(self.api, ['?last-id=5fbd9fbcd48b40737d3c14db'])) assert res.status_code == 200 assert res.mimetype == JSON_MIME_TYPE # When an `_id` cannot be found or is the last `_id` in the collection # and empty array will be returned assert res.json['data'] == []
def test_list_paginate(self, client): res_orig = client.get(url_for(self.api)) last_id = res_orig.json['data'][-1]['_id']['$oid'] res = client.get(build_query(self.api, ['?last-id=', last_id])) assert res.status_code == 200 assert res.mimetype == JSON_MIME_TYPE assert validate(res.json['data'], self.schema) is None assert res_orig.json != res.json
def get_schedule( self, producer: str = None, key: str = None, after: str = None, before: str = None, version: int = None, ): endpoint = inspect.currentframe().f_code.co_name url = f"{self.url_base}/{endpoint}" args = locals() query = build_query(args) if query is None: raise Exception("Must provide at least one query parameter") return get_resp(f"{url}?{query}")
def get_deltas( self, limit: int = None, skip: int = None, code: str = None, scope: str = None, table: str = None, payer: str = None, ) -> requests.models.Response: endpoint = inspect.currentframe().f_code.co_name url = f"{self.url_base}/{endpoint}" args = locals() query = build_query(args) if query is None: raise Exception("Must provide at least one query parameter") return get_resp(f"{url}?{query}")
def get_actions( self, limit: int = None, skip: int = None, account: str = None, track: int = None, filter: str = None, sort: str = None, after: str = None, before: str = None, simple: bool = None, noBinary: bool = None, checkLib: bool = None, ) -> requests.models.Response: endpoint = inspect.currentframe().f_code.co_name url = f"{self.url_base}/{endpoint}" args = locals() query = build_query(args) if query is None: raise Exception("Must provide at least one query parameter") return get_resp(f"{url}?{query}")
def test_list_bad_id(self, client): res = client.get(build_query(self.api, ['?last-id=123'])) assert res.status_code == 400 assert res.mimetype == JSON_MIME_TYPE assert res.json == {'error': 'Bad Request'}
def test_search_not_found(self, client): res = client.get(build_query(self.api, ['?message=foobar'])) assert res.status_code == 404 assert res.mimetype == JSON_MIME_TYPE assert res.json == {'error': 'Not Found'}
def test_search(self, client): res = client.get(build_query(self.api, ['?message=fastfinger'])) assert res.status_code == 200 assert res.mimetype == JSON_MIME_TYPE assert validate(res.json['data'], self.schema) is None
def test_avg_difficulty_level_not_found(self, client): res = client.get(build_query(self.api, ['?level=10000'])) assert res.status_code == 404 assert res.mimetype == JSON_MIME_TYPE assert res.json == {'error': 'Not Found'}