def execute(obj, url, **kwargs): """Execute a GraphQL executable Parameters ---------- obj: :data:`~quiz.execution.Executable` The object to execute. This may be a raw string or a query url: str The URL of the target endpoint **kwargs ``auth`` and/or ``client``, passed to :func:`snug.query.execute`. Returns ------- JSON The response data Raises ------ ErrorResponse If errors are present in the response HTTPError If the response has a non 2xx response code """ snug_query = irelay(_exec(obj), partial(middleware, url)) return snug.execute(snug_query, **kwargs)
def execute(obj, url, **kwargs): """Execute a GraphQL executable Parameters ---------- obj: :data:`~quiz.execution.Executable` The object to execute. This may be a raw string or a query url: str The URL of the target endpoint **kwargs ``auth`` and/or ``client``, passed to :func:`snug.query.execute`. Returns ------- RawResult (a dict) or the schema's return type In case of a raw string, a raw result. Otherwise, an instance of the schema's type queried for. Raises ------ ErrorResponse If errors are present in the response HTTPError If the response has a non 2xx response code """ snug_query = irelay(_exec(obj), partial(middleware, url)) return snug.execute(snug_query, **kwargs)
def test_any_iterable(self, MyMax, try_until_positive): relayed = gentools.irelay(MyMax(4), try_until_positive) assert next(relayed) == 4 assert relayed.send(7) == 7 assert relayed.send(6) == 7 assert relayed.send(-1) == 'NOT POSITIVE!' assert relayed.send(-4) == 'NOT POSITIVE!' assert relayed.send(0) == 7 assert gentools.sendreturn(relayed, 102) == 306
def test_combine_mappers(mymax, try_until_even): gen = gentools.imap_return( 'result: {}'.format, gentools.imap_send( int, gentools.imap_yield(str, gentools.irelay(mymax(4), try_until_even)))) assert next(gen) == '4' assert gen.send(3) == 'NOT EVEN!' assert gen.send('5') == 'NOT EVEN!' assert gen.send(8.4) == '8' assert gentools.sendreturn(gen, 104) == 'result: 312'
def test_empty(self, emptygen, try_until_positive): try: next(gentools.irelay(emptygen(), try_until_positive)) except StopIteration as e: assert e.args[0] == 99