repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
keon/algorithms
import unittest from algorithms.string import ( add_binary, atbash, bracket, caesar_cipher, check_pangram, contain_string, convert_morse_word, count_binary_substring, decode, decode_string, delete_reoccurring_characters, domain_name_1, domain_name_2, encode, ...
res)
self.assertEqual
variable
tests/test_string.py
test_empty_string
TestPanagram
673
null
keon/algorithms
import unittest from algorithms.dynamic_programming import ( Item, Job, climb_stairs, climb_stairs_optimized, combination_sum_bottom_up, combination_sum_topdown, count, edit_distance, egg_drop, fib_iter, fib_list, fib_recursive, find_k_factor, get_maximum_value, ...
2)
self.assertEqual
numeric_literal
tests/test_dynamic_programming.py
test_climb_stairs
TestClimbingStairs
42
null
keon/algorithms
import random import unittest from algorithms.bit_manipulation import ( add_bitwise_operator, binary_gap, bytes_big_endian_to_int, bytes_little_endian_to_int, clear_bit, count_flips_to_convert, count_ones_iter, count_ones_recur, find_difference, find_missing_number, find_mis...
remove_bit(21, 4))
self.assertEqual
func_call
tests/test_bit_manipulation.py
test_remove_bit
TestSuite
280
null
keon/algorithms
import unittest from algorithms.backtracking import ( add_operators, anagram, array_sum_combinations, combination_sum, find_words, generate_abbreviations, generate_parenthesis_v1, generate_parenthesis_v2, get_factors, letter_combinations, palindromic_substrings, pattern_...
sorted(answer2))
self.assertEqual
func_call
tests/test_backtracking.py
test_permute
TestPermute
376
null
keon/algorithms
from __future__ import annotations import unittest from algorithms.common.tree_node import TreeNode from algorithms.data_structures import SqrtDecomposition from algorithms.graph.dijkstra_heapq import dijkstra from algorithms.math.goldbach import goldbach, verify_goldbach from algorithms.tree.binary_tree_views import...
1)
self.assertEqual
numeric_literal
tests/test_issue_fixes.py
test_direct_neighbor
TestDijkstraHeapq
46
null
keon/algorithms
import unittest from algorithms.data_structures.veb_tree import VEBTree class TestVEBTree(unittest.TestCase): def setUp(self): self.veb = VEBTree(16) def test_min_max(self): self.veb.insert(10) self.veb.insert(2) self.veb.insert(15) self.assertEqual(2,
self.veb.minimum())
self.assertEqual
func_call
tests/test_veb_tree.py
test_min_max
TestVEBTree
25
null
prkumar/uplink
import collections import pytest from uplink import decorators, interfaces def method_annotation(): return decorators.MethodAnnotation() def method_annotation_mock(mocker): return mocker.Mock(spec=decorators.MethodAnnotation) def method_handler_builder(): return decorators.MethodAnnotationHandlerBuilde...
ValueError)
pytest.raises
variable
tests/unit/test_decorators.py
test_json
223
null
prkumar/uplink
import pytest from uplink import auth, utils class TestMultiAuth: def setup_basic_auth(self): return auth.BasicAuth("apiuser", "apipass") def verify_basic_auth(self, basic_auth, request_builder): basic_auth_str = basic_auth._header_value assert request_builder.info["headers"]["Authori...
param_auth
assert
variable
tests/unit/test_auth.py
test_four_methods
TestMultiAuth
173
null
prkumar/uplink
import pytest from uplink.clients.io import interfaces, state, transitions def request_execution_mock(mocker): return mocker.Mock(spec=interfaces.RequestExecution) def request_state_mock(mocker): return mocker.Mock(spec=interfaces.RequestState) class TestFinish: def test_execute(self, request_execution_...
response)
assert_*
variable
tests/unit/test_io.py
test_execute
TestFinish
135
null
prkumar/uplink
from uplink import session def test_auth(uplink_builder_mock): # Setup uplink_builder_mock.auth = ("username", "password") sess = session.Session(uplink_builder_mock) # Run & Verify assert uplink_builder_mock.auth ==
sess.auth
assert
complex_expr
tests/unit/test_session.py
test_auth
44
null
prkumar/uplink
import collections import pytest from uplink import decorators, interfaces def method_annotation(): return decorators.MethodAnnotation() def method_annotation_mock(mocker): return mocker.Mock(spec=decorators.MethodAnnotation) def method_handler_builder(): return decorators.MethodAnnotationHandlerBuilde...
method_annotation)
assert_*
variable
tests/unit/test_decorators.py
test_call_with_class
TestMethodAnnotation
82
null
prkumar/uplink
from uplink import retry from uplink.retry import backoff, stop, when def test_compose_backoff(mocker): left = backoff.from_iterable([0, 1]) right = backoff.from_iterable([2]) mocker.spy(left, "handle_after_final_retry") mocker.spy(right, "handle_after_final_retry") strategy = left | right # S...
1
assert
numeric_literal
tests/unit/test_retry.py
test_compose_backoff
47
null
prkumar/uplink
import pytest from uplink import arguments, hooks from uplink.converters import keys inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]]) def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) def named_argument_mock(mocker): return mocker.Mock(spec=arguments.N...
body
assert
variable
tests/unit/test_arguments.py
test_modify_request
TestBody
385
null
prkumar/uplink
import pytest from uplink.clients.io import interfaces, state, transitions def request_execution_mock(mocker): return mocker.Mock(spec=interfaces.RequestExecution) def request_state_mock(mocker): return mocker.Mock(spec=interfaces.RequestState) def test_send_transition(request_state_mock): request = obj...
request)
assert_*
variable
tests/unit/test_io.py
test_send_transition
146
null
prkumar/uplink
import collections import uplink BASE_URL = "https://api.github.com/" User = collections.namedtuple("User", "id name") Repo = collections.namedtuple("Repo", "owner name") def user_reader(cls, response): return cls(**response.json()) def repo_json_reader(cls, json): return cls(**json) def repo_json_writer(...
mock_response
assert
variable
tests/integration/test_returns.py
test_returns_response_when_type_has_no_converter
106
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://example.com/" def handle_response_with_consumer(consumer, response): consumer.flagged = True return response def handle_response(response): response.flagged = True return response def handle_error_with_consumer(consumer, exc_type, exc_value, exc_tb): ...
True
assert
bool_literal
tests/integration/test_handlers.py
test_class_response_handler
81
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://api.github.com" def github_error(response): if "errors" in response.json(): raise GitHubError() return response def test_get_repository2_failure(mock_client, mock_response): data = { "query": """\ query { repository(owner: "prkumar", na...
GitHubError)
pytest.raises
variable
tests/integration/test_extend.py
test_get_repository2_failure
88
null
prkumar/uplink
import pytest from uplink import hooks class TestTransactionHookChain: def test_delegate_handle_response(self, transaction_hook_mock): chain = hooks.TransactionHookChain(transaction_hook_mock) chain.handle_response("consumer", {}) transaction_hook_mock.handle_response.assert_called_with(...
{})
assert_*
collection
tests/unit/test_hooks.py
test_delegate_handle_response
TestTransactionHookChain
42
null
prkumar/uplink
import contextlib import pytest from uplink.clients import ( interfaces, io, register, requests_, twisted_, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: setattr(obj, attr,...
("username", "password")
assert
collection
tests/unit/test_clients.py
test_init_with_kwargs
TestRequests
62
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://api.github.com" def github_error(response): if "errors" in response.json(): raise GitHubError() return response def test_get_repository(mock_client, mock_response): data = { "query": """\ query { repository(owner: "prkumar", name: "upli...
"/graphql"
assert
string_literal
tests/integration/test_extend.py
test_get_repository
59
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestURIDefinitionBuilder: def test_is_dynamic_setter_fails_when_is_static(self): uri = commands.URIDefinitionBuilder(True) assert uri.is_static with pytest.raises(
ValueError)
pytest.raises
variable
tests/unit/test_commands.py
test_is_dynamic_setter_fails_when_is_static
TestURIDefinitionBuilder
100
null
prkumar/uplink
import pytest import uplink from uplink.ratelimit import RateLimitExceeded, now BASE_URL = "https://api.github.com/" DIFFERENT_BASE_URL = "https://hostedgithub.com/" def test_limit_exceeded_by_1(mock_client): # Setup github = GitHub(base_url=BASE_URL, client=mock_client) # Run github.get_user("prkum...
RateLimitExceeded)
pytest.raises
variable
tests/integration/test_ratelimit.py
test_limit_exceeded_by_1
56
null
prkumar/uplink
from uplink import returns def test_returns(request_builder): custom = returns(str) request_builder.get_converter.return_value = str request_builder.return_type = returns.ReturnType.with_decorator(None, custom) custom.modify_request(request_builder) assert request_builder.return_type(2) ==
"2"
assert
string_literal
tests/unit/test_returns.py
test_returns
10
null
prkumar/uplink
import pytest from uplink.clients.io import interfaces, state, transitions def request_execution_mock(mocker): return mocker.Mock(spec=interfaces.RequestExecution) def request_state_mock(mocker): return mocker.Mock(spec=interfaces.RequestState) class BasicStateTest: def create_state(self, request): ...
state.Finish(request, response)
assert
func_call
tests/unit/test_io.py
test_finish
BasicStateTest
50
null
prkumar/uplink
import contextlib import pytest from uplink.clients import ( interfaces, io, register, requests_, twisted_, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: setattr(obj, attr,...
1
assert
numeric_literal
tests/unit/test_clients.py
test_close_auto_generated_session
TestRequests
117
null
prkumar/uplink
import pytest from uplink import auth, builder, converters, exceptions, helpers from uplink.clients import io def fake_service_cls(request_definition_builder, request_definition): class Service: builder = request_definition_builder request_definition_builder.build.return_value = request_definition ...
execution_builder)
assert_*
variable
tests/unit/test_builder.py
test_call
TestCallFactory
99
null
prkumar/uplink
import pytest from uplink.clients.io import interfaces, state, transitions def request_execution_mock(mocker): return mocker.Mock(spec=interfaces.RequestExecution) def request_state_mock(mocker): return mocker.Mock(spec=interfaces.RequestState) class BasicStateTest: def create_state(self, request): ...
state.SendRequest(request)
assert
func_call
tests/unit/test_io.py
test_send
BasicStateTest
36
null
prkumar/uplink
import pytest from uplink.clients import io from . import test_retry @pytest.mark.asyncio async def test_retry_with_asyncio(mock_client, mock_response): async def coroutine(): return mock_response # Setup mock_response.with_json({"id": 123, "name": "prkumar"}) mock_client.with_side_effect([E...
2
assert
numeric_literal
tests/integration/test_retry_aiohttp.py
test_retry_with_asyncio
25
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://api.github.com" def github_error(response): if "errors" in response.json(): raise GitHubError() return response def test_get_repository(mock_client, mock_response): data = { "query": """\ query { repository(owner: "prkumar", name: "upli...
10
assert
numeric_literal
tests/integration/test_extend.py
test_get_repository
60
null
prkumar/uplink
import pytest from uplink import returns from uplink.decorators import json from uplink.models import dumps, loads @pytest.mark.parametrize( ("cls", "method"), [ (loads, "create_response_body_converter"), (dumps, "create_request_body_converter"), ], ) def test_models(mocker, cls, method, r...
1
assert
numeric_literal
tests/unit/test_models.py
test_models
26
null
prkumar/uplink
import asyncio import contextlib import aiohttp import pytest from uplink.clients import ( AiohttpClient, aiohttp_, io, register, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: ...
awaitable_callback
assert
variable
tests/unit/test_aiohttp_client.py
test_wrap_callback
TestAiohttp
122
null
prkumar/uplink
import sys import marshmallow import pytest from uplink import converters from uplink.converters import register, standard def schema_mock_and_argument(request, mocker): class Schema(marshmallow.Schema): def __new__(cls, *args, **kwargs): return schema schema = mocker.Mock(spec=marshmal...
1
assert
numeric_literal
tests/unit/test_converters.py
test_register_converter_factory_pass
TestRegistry
386
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestRequestDefinitionBuilder: def test_auto_fill_when_not_done(self, mocker, annotation_handler_builder_mock): # Setup argument_handler_builder = mocker.Mock( stub=arguments.ArgumentAnnotationHandlerBuilder ...
{"arg1": arguments.Path})
assert_*
collection
tests/unit/test_commands.py
test_auto_fill_when_not_done
TestRequestDefinitionBuilder
178
null
prkumar/uplink
from uplink import Consumer, FieldMap, form_url_encoded, put BASE_URL = "https://example.com/" def test_without_converter(mock_response, mock_client): class Calendar(Consumer): @form_url_encoded @put("/user/repos", args={"event_data": FieldMap}) def add_event(self, **event_data): ...
{"name": "Weekly Stand-up", "public": True}
assert
collection
tests/integration/test_form_url_encoded.py
test_without_converter
23
null
prkumar/uplink
import pytest from uplink import hooks class TestTransactionHookChain: def test_delegate_handle_exception(self, transaction_hook_mock): class CustomException(Exception): pass err = CustomException() chain = hooks.TransactionHookChain(transaction_hook_mock) with pytes...
None)
assert_*
none_literal
tests/unit/test_hooks.py
test_delegate_handle_exception
TestTransactionHookChain
68
null
prkumar/uplink
from uplink import returns def test_returns_with_multiple_decorators(request_builder, mocker): decorator1 = returns(str) decorator2 = returns.json() request_builder.get_converter.return_value = str first_type = returns.ReturnType.with_decorator(None, decorator1) second_type = request_builder.return...
str(mock_response.json())
assert
func_call
tests/unit/test_returns.py
test_returns_with_multiple_decorators
30
null
prkumar/uplink
import pytest from uplink import hooks class TestTransactionHookChain: def test_delegate_handle_response_multiple(self, mocker): # Include one hook that can't handle responses mock_response_handler = mocker.Mock() mock_request_auditor = mocker.Mock() chain = hooks.TransactionHook...
0
assert
numeric_literal
tests/unit/test_hooks.py
test_delegate_handle_response_multiple
TestTransactionHookChain
56
null
prkumar/uplink
import pytest from uplink import hooks class TestTransactionHookChain: def test_delegate_handle_exception(self, transaction_hook_mock): class CustomException(Exception): pass err = CustomException() chain = hooks.TransactionHookChain(transaction_hook_mock) with pyte...
CustomException)
pytest.raises
variable
tests/unit/test_hooks.py
test_delegate_handle_exception
TestTransactionHookChain
65
null
prkumar/uplink
import asyncio import contextlib import aiohttp import pytest from uplink.clients import ( AiohttpClient, aiohttp_, io, register, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: ...
callback)
assert_*
variable
tests/unit/test_aiohttp_client.py
test_wrap_callback
TestAiohttp
116
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestURIDefinitionBuilder: def test_remaining_variables(self): uri = commands.URIDefinitionBuilder("/path/with/{variable}") assert uri.remaining_variables ==
{"variable"}
assert
collection
tests/unit/test_commands.py
test_remaining_variables
TestURIDefinitionBuilder
105
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://api.github.com" def github_error(response): if "errors" in response.json(): raise GitHubError() return response def test_get_repository(mock_client, mock_response): data = { "query": """\ query { repository(owner: "prkumar", name: "upli...
"POST"
assert
string_literal
tests/integration/test_extend.py
test_get_repository
57
null
prkumar/uplink
import collections import pytest from uplink import decorators, interfaces def method_annotation(): return decorators.MethodAnnotation() def method_annotation_mock(mocker): return mocker.Mock(spec=decorators.MethodAnnotation) def method_handler_builder(): return decorators.MethodAnnotationHandlerBuilde...
mocker.ANY)
assert_*
complex_expr
tests/unit/test_decorators.py
test_static_call_with_class
TestMethodAnnotation
90
null
prkumar/uplink
import collections import pytest from uplink import decorators, interfaces def method_annotation(): return decorators.MethodAnnotation() def method_annotation_mock(mocker): return mocker.Mock(spec=decorators.MethodAnnotation) def method_handler_builder(): return decorators.MethodAnnotationHandlerBuilde...
header
assert
variable
tests/unit/test_decorators.py
test_headers
158
null
prkumar/uplink
from uplink import returns def test_returns_with_multiple_decorators(request_builder, mocker): decorator1 = returns(str) decorator2 = returns.json() request_builder.get_converter.return_value = str first_type = returns.ReturnType.with_decorator(None, decorator1) second_type = request_builder.return...
second_type
assert
variable
tests/unit/test_returns.py
test_returns_with_multiple_decorators
24
null
prkumar/uplink
import pytest from uplink import helpers class TestRequestBuilder: def test_context(self): # Setup builder = helpers.RequestBuilder(None, {}, "base_url") # Run builder.context["key"] = "value" # Verify assert builder.context["key"] ==
"value"
assert
string_literal
tests/unit/test_helpers.py
test_context
TestRequestBuilder
58
null
prkumar/uplink
from uplink import utils class TestURIBuilder: def test_set_variable(self): builder = utils.URIBuilder("/path/to/{variable}") assert builder.build() == "/path/to/" builder.set_variable(variable="resource") assert builder.build() ==
"/path/to/resource"
assert
string_literal
tests/unit/test_utils.py
test_set_variable
TestURIBuilder
34
null
prkumar/uplink
import pytest from uplink import auth, utils class TestGetAuth: def test_none(self): authentication = auth.get_auth(None) assert authentication ==
utils.no_op
assert
complex_expr
tests/unit/test_auth.py
test_none
TestGetAuth
11
null
prkumar/uplink
import pytest from uplink import auth, utils class TestGetAuth: def test_callable(self): def func(): pass output = auth.get_auth(func) assert output is
func
assert
variable
tests/unit/test_auth.py
test_callable
TestGetAuth
22
null
prkumar/uplink
import pytest from uplink import arguments, hooks from uplink.converters import keys inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]]) def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) def named_argument_mock(mocker): return mocker.Mock(spec=arguments.N...
1
assert
numeric_literal
tests/unit/test_arguments.py
test_add_annotation_that_is_not_an_annotation
TestArgumentAnnotationHandlerBuilder
134
null
prkumar/uplink
import pytest from uplink import arguments, hooks from uplink.converters import keys inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]]) def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) def named_argument_mock(mocker): return mocker.Mock(spec=arguments.N...
None
assert
none_literal
tests/unit/test_arguments.py
test_set_type
TestTypedArgument
203
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://api.github.com/" def test_list_repo_wrapper(mock_client): """Ensures that the consumer method looks like the original func.""" github = GitHubService(base_url=BASE_URL, client=mock_client) assert
GitHubService.list_repos.__doc__
assert
complex_expr
tests/integration/test_basic.py
test_list_repo_wrapper
35
null
prkumar/uplink
import collections import uplink BASE_URL = "https://api.github.com/" User = collections.namedtuple("User", "id name") Repo = collections.namedtuple("Repo", "owner name") def user_reader(cls, response): return cls(**response.json()) def repo_json_reader(cls, json): return cls(**json) def repo_json_writer(...
300
assert
numeric_literal
tests/integration/test_returns.py
test_returns_json_by_key
177
null
prkumar/uplink
from uplink import returns class TestReturnsJsonCast: default_value = {"key": "1"} def prepare_test(request_builder, mocker, value=default_value, **kwargs): mock_response = mocker.Mock() mock_response.json.return_value = value request_builder.get_converter.return_value = None r...
"1"
assert
string_literal
tests/unit/test_returns.py
test_without_type
TestReturnsJsonCast
88
null
prkumar/uplink
from uplink import returns class TestReturnsJsonCast: default_value = {"key": "1"} def prepare_test(request_builder, mocker, value=default_value, **kwargs): mock_response = mocker.Mock() mock_response.json.return_value = value request_builder.get_converter.return_value = None r...
self.default_value
assert
complex_expr
tests/unit/test_returns.py
test_with_not_callable_cast
TestReturnsJsonCast
108
null
prkumar/uplink
import pytest from uplink import auth, builder, converters, exceptions, helpers from uplink.clients import io def fake_service_cls(request_definition_builder, request_definition): class Service: builder = request_definition_builder request_definition_builder.build.return_value = request_definition ...
request_definition_builder.copy()
assert
func_call
tests/unit/test_builder.py
test_setting_request_method
176
null
prkumar/uplink
import sys import marshmallow import pytest from uplink import converters from uplink.converters import register, standard def schema_mock_and_argument(request, mocker): class Schema(marshmallow.Schema): def __new__(cls, *args, **kwargs): return schema schema = mocker.Mock(spec=marshmal...
None
assert
none_literal
tests/unit/test_converters.py
test_create_string_converter
TestMarshmallowConverter
264
null
prkumar/uplink
import collections import uplink BASE_URL = "https://api.github.com/" User = collections.namedtuple("User", "id name") Repo = collections.namedtuple("Repo", "owner name") def user_reader(cls, response): return cls(**response.json()) def repo_json_reader(cls, json): return cls(**json) def repo_json_writer(...
user
assert
variable
tests/integration/test_returns.py
test_returns_with_type
119
null
prkumar/uplink
import asyncio import contextlib import aiohttp import pytest from uplink.clients import ( AiohttpClient, aiohttp_, io, register, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: ...
expected_response
assert
variable
tests/unit/test_aiohttp_client.py
test_request_send
TestAiohttp
79
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://api.github.com" def github_error(response): if "errors" in response.json(): raise GitHubError() return response def test_get_repository(mock_client, mock_response): data = { "query": """\ query { repository(owner: "prkumar", name: "upli...
BASE_URL
assert
variable
tests/integration/test_extend.py
test_get_repository
58
null
prkumar/uplink
from uplink import returns def test_returns_json(request_builder, mocker): mock_response = mocker.Mock() mock_response.json.return_value = {"key": "value"} request_builder.get_converter.return_value = str returns_json = returns.json(str, ()) request_builder.return_type = returns.ReturnType.with_dec...
mock_response.json()
assert
func_call
tests/unit/test_returns.py
test_returns_json
56
null
prkumar/uplink
import pytest from uplink import auth, builder, converters, exceptions, helpers from uplink.clients import io def fake_service_cls(request_definition_builder, request_definition): class Service: builder = request_definition_builder request_definition_builder.build.return_value = request_definition ...
"example"
assert
string_literal
tests/unit/test_builder.py
test_base_url
TestBuilder
121
null
prkumar/uplink
import contextlib import pytest from uplink.clients import ( interfaces, io, register, requests_, twisted_, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: setattr(obj, attr,...
exceptions.InvalidURL)
pytest.raises
complex_expr
tests/unit/test_clients.py
test_exceptions
TestRequests
143
null
prkumar/uplink
import pytest from uplink import auth, builder, converters, exceptions, helpers from uplink.clients import io def fake_service_cls(request_definition_builder, request_definition): class Service: builder = request_definition_builder request_definition_builder.build.return_value = request_definition ...
uplink_builder.client.io())
assert_*
func_call
tests/unit/test_builder.py
test_prepare_request
TestRequestPreparer
41
null
prkumar/uplink
import pytest from uplink import arguments, hooks from uplink.converters import keys inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]]) def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) def named_argument_mock(mocker): return mocker.Mock(spec=arguments.N...
args[0]
assert
complex_expr
tests/unit/test_arguments.py
test_add_named_annotation_without_name
TestArgumentAnnotationHandlerBuilder
99
null
prkumar/uplink
import contextlib import pytest from uplink.clients import ( interfaces, io, register, requests_, twisted_, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: setattr(obj, attr,...
(1, 2, 3))
assert_*
collection
tests/unit/test_clients.py
test_client_send
TestTwisted
164
null
prkumar/uplink
import asyncio import contextlib import aiohttp import pytest from uplink.clients import ( AiohttpClient, aiohttp_, io, register, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: ...
1
assert
numeric_literal
tests/unit/test_aiohttp_client.py
test_threaded_callback
TestAiohttp
147
null
prkumar/uplink
from uplink import retry from uplink.retry import backoff, stop, when def test_retry_decorator_exposes_submodules_as_properties(): assert retry.backoff is backoff assert retry.stop is
stop
assert
variable
tests/unit/test_retry.py
test_retry_decorator_exposes_submodules_as_properties
100
null
prkumar/uplink
from uplink import session def test_base_url(uplink_builder_mock): # Setup uplink_builder_mock.base_url = "https://api.github.com" sess = session.Session(uplink_builder_mock) # Run & Verify assert uplink_builder_mock.base_url ==
sess.base_url
assert
complex_expr
tests/unit/test_session.py
test_base_url
11
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestRequestDefinition: def test_argument_annotations(self, annotation_handler_mock): annotation_handler_mock.annotations = ["arg1", "arg2"] definition = commands.RequestDefinition( None, None, None, annotatio...
["arg1", "arg2"]
assert
collection
tests/unit/test_commands.py
test_argument_annotations
TestRequestDefinition
213
null
prkumar/uplink
import collections import pytest from uplink import decorators, interfaces def method_annotation(): return decorators.MethodAnnotation() def method_annotation_mock(mocker): return mocker.Mock(spec=decorators.MethodAnnotation) def method_handler_builder(): return decorators.MethodAnnotationHandlerBuilde...
(str, str))
assert_*
collection
tests/unit/test_decorators.py
test_args
254
null
prkumar/uplink
import pytest from uplink import arguments, hooks from uplink.converters import keys inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]]) def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) def named_argument_mock(mocker): return mocker.Mock(spec=arguments.N...
func
assert
variable
tests/unit/test_arguments.py
test_static_call_with_function
FuncDecoratorTestCase
51
null
prkumar/uplink
import sys import marshmallow import pytest from uplink import converters from uplink.converters import register, standard def schema_mock_and_argument(request, mocker): class Schema(marshmallow.Schema): def __new__(cls, *args, **kwargs): return schema schema = mocker.Mock(spec=marshmal...
["1"]
assert
collection
tests/unit/test_converters.py
test_list_converter
TestTypingConverter
442
null
prkumar/uplink
from uplink import retry from uplink.retry import backoff, stop, when class TestClientExceptionProxies: def _get_exception(proxy, request_builder): return proxy(request_builder.client.exceptions) def test_basic_client_exception(self, request_builder): exc = self._get_exception(retry.BASE_CLIE...
exc
assert
variable
tests/unit/test_retry.py
test_basic_client_exception
TestClientExceptionProxies
214
null
prkumar/uplink
from uplink import retry from uplink.retry import backoff, stop, when def test_compose_backoff(mocker): left = backoff.from_iterable([0, 1]) right = backoff.from_iterable([2]) mocker.spy(left, "handle_after_final_retry") mocker.spy(right, "handle_after_final_retry") strategy = left | right # S...
None
assert
none_literal
tests/unit/test_retry.py
test_compose_backoff
49
null
prkumar/uplink
import pytest from uplink import auth, builder, converters, exceptions, helpers from uplink.clients import io def fake_service_cls(request_definition_builder, request_definition): class Service: builder = request_definition_builder request_definition_builder.build.return_value = request_definition ...
kwargs)
assert_*
variable
tests/unit/test_builder.py
test_call
TestCallFactory
96
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://api.github.com/" def test_get_repo(mock_client, mock_response): """ This integration test ensures that the returns.json returns the Json body when a model is not provided. """ # Setup: return a mock response expected_json = {"key": "value"} ...
"Bearer token"
assert
string_literal
tests/integration/test_basic.py
test_get_repo
72
null
prkumar/uplink
import pytest from uplink.clients.io import interfaces, state, transitions def request_execution_mock(mocker): return mocker.Mock(spec=interfaces.RequestExecution) def request_state_mock(mocker): return mocker.Mock(spec=interfaces.RequestState) class TestSendRequest: def test_execute(self, request_execu...
state.AfterResponse(request, response)
assert
func_call
tests/unit/test_io.py
test_execute
TestSendRequest
113
null
prkumar/uplink
from uplink import retry from uplink.retry import backoff, stop, when def test_fixed_backoff(): iterator = backoff.fixed(10)() assert next(iterator) ==
10
assert
numeric_literal
tests/unit/test_retry.py
test_fixed_backoff
33
null
prkumar/uplink
from uplink import utils def test_get_arg_spec(): def func(pos1, *args: 2, **kwargs: 3) -> 4: pass signature = utils.get_arg_spec(func) assert isinstance(signature, utils.Signature) assert signature.args == ["pos1", "args", "kwargs"] assert signature.annotations ==
{"args": 2, "kwargs": 3}
assert
collection
tests/unit/test_utils.py
test_get_arg_spec
14
null
prkumar/uplink
import pytest from uplink import arguments, hooks from uplink.converters import keys inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]]) def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) def named_argument_mock(mocker): return mocker.Mock(spec=arguments.N...
"type"
assert
string_literal
tests/unit/test_arguments.py
test_set_type
TestTypedArgument
205
null
prkumar/uplink
import pytest import pytest_twisted from uplink import Consumer, get, retry from uplink.clients import io BASE_URL = "https://api.github.com/" def backoff_once(): yield 0.1 def test_retry(mock_client, mock_response): # Setup mock_response.with_json({"id": 123, "name": "prkumar"}) mock_client.with_si...
{"id": 123, "name": "prkumar"}
assert
collection
tests/integration/test_retry.py
test_retry
59
null
prkumar/uplink
import contextlib import pytest from uplink.clients import ( interfaces, io, register, requests_, twisted_, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: setattr(obj, attr,...
session_mock.request.return_value)
assert_*
complex_expr
tests/unit/test_clients.py
test_client_send
TestRequests
81
null
prkumar/uplink
import pytest from uplink.clients import io from . import test_retry @pytest.mark.asyncio async def test_retry_with_asyncio(mock_client, mock_response): async def coroutine(): return mock_response # Setup mock_response.with_json({"id": 123, "name": "prkumar"}) mock_client.with_side_effect([E...
{"id": 123, "name": "prkumar"}
assert
collection
tests/integration/test_retry_aiohttp.py
test_retry_with_asyncio
26
null
prkumar/uplink
from uplink import retry from uplink.retry import backoff, stop, when def test_stop_or(): stop_gen = (stop.after_delay(2) | stop.after_attempt(3))() next(stop_gen) assert stop_gen.send(3) is
True
assert
bool_literal
tests/unit/test_retry.py
test_stop_or
81
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestRequestDefinition: def test_define_request(self, request_builder, mocker): method = "method" uri = "uri" definition = commands.RequestDefinition( method, uri, str, mocker.Mock(), mocker.Mock() ...
str
assert
variable
tests/unit/test_commands.py
test_define_request
TestRequestDefinition
231
null
prkumar/uplink
import collections import pytest from uplink import decorators, interfaces def method_annotation(): return decorators.MethodAnnotation() def method_annotation_mock(mocker): return mocker.Mock(spec=decorators.MethodAnnotation) def method_handler_builder(): return decorators.MethodAnnotationHandlerBuilde...
request_builder)
assert_*
variable
tests/unit/test_decorators.py
test_handle_builder
TestMethodAnnotationHandler
65
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestHttpMethod: def test_call_with_return_annotation(self, mocker): # Setup def func(): pass sig = utils.Signature( args=[], annotations={}, return_annotation="return_annotation" ...
sig.return_annotation)
assert_*
complex_expr
tests/unit/test_commands.py
test_call_with_return_annotation
TestHttpMethod
63
null
prkumar/uplink
from uplink import utils class TestURIBuilder: def test_remaining_variables(self): builder = utils.URIBuilder("{variable}") assert builder.remaining_variables() == {"variable"} builder.set_variable(variable="resource") assert len(builder.remaining_variables()) ==
0
assert
numeric_literal
tests/unit/test_utils.py
test_remaining_variables
TestURIBuilder
40
null
prkumar/uplink
import pytest from uplink import arguments, hooks from uplink.converters import keys inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]]) def argument_mock(mocker): return mocker.Mock(spec=arguments.ArgumentAnnotation) def named_argument_mock(mocker): return mocker.Mock(spec=arguments.N...
"hello"
assert
string_literal
tests/unit/test_arguments.py
test_type
TestTypedArgument
197
null
prkumar/uplink
import pytest from uplink import hooks class TestResponseHandler: def test_handle_response(self, mocker): converter = mocker.Mock() input_value = "converted" converter.return_value = input_value rc = hooks.ResponseHandler(converter) assert rc.handle_response(None) is
input_value
assert
variable
tests/unit/test_hooks.py
test_handle_response
TestResponseHandler
14
null
prkumar/uplink
from uplink import returns def test_returns_JsonStrategy(mocker): response = mocker.Mock(spec=["json"]) response.json.return_value = {"hello": "world"} converter = returns.JsonStrategy(lambda x: x, "hello") assert converter(response) ==
"world"
assert
string_literal
tests/unit/test_returns.py
test_returns_JsonStrategy
115
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestHttpMethod: def test_call(self, mocker, annotation_mock): # Setup def func(): pass sig = utils.Signature( args=["self", "arg1", "arg2"], annotations={"arg1": annotation_mo...
["hello"]
assert
collection
tests/unit/test_commands.py
test_call
TestHttpMethod
43
null
prkumar/uplink
import pytest from uplink import returns from uplink.decorators import json from uplink.models import dumps, loads @pytest.mark.parametrize( ("cls", "method"), [ (loads, "create_response_body_converter"), (dumps, "create_request_body_converter"), ], ) def test_models(mocker, cls, method, r...
None
assert
none_literal
tests/unit/test_models.py
test_models
32
null
prkumar/uplink
import asyncio import contextlib import aiohttp import pytest from uplink.clients import ( AiohttpClient, aiohttp_, io, register, ) def _patch(obj, attr, value): if obj is not None: old_value = getattr(obj, attr) setattr(obj, attr, value) yield if obj is not None: ...
exceptions.InvalidURL)
pytest.raises
complex_expr
tests/unit/test_aiohttp_client.py
test_exceptions
TestAiohttp
256
null
prkumar/uplink
from uplink import utils def test_get_arg_spec(): def func(pos1, *args: 2, **kwargs: 3) -> 4: pass signature = utils.get_arg_spec(func) assert isinstance(signature, utils.Signature) assert signature.args == ["pos1", "args", "kwargs"] assert signature.annotations == {"args": 2, "kwargs": 3}...
4
assert
numeric_literal
tests/unit/test_utils.py
test_get_arg_spec
15
null
prkumar/uplink
import pytest from uplink import arguments, commands, converters, utils class TestHttpMethod: def test_call(self, mocker, annotation_mock): # Setup def func(): pass sig = utils.Signature( args=["self", "arg1", "arg2"], annotations={"arg1": annotation_mo...
expected_missing
assert
variable
tests/unit/test_commands.py
test_call
TestHttpMethod
47
null
prkumar/uplink
import pytest import uplink BASE_URL = "https://example.com/" def handle_response_with_consumer(consumer, response): consumer.flagged = True return response def handle_response(response): response.flagged = True return response def handle_error_with_consumer(consumer, exc_type, exc_value, exc_tb): ...
WrappedException)
pytest.raises
variable
tests/integration/test_handlers.py
test_error_handler_with_consumer
128
null
prkumar/uplink
import pytest from uplink import _extras def test_install(mocker): # Setup func = mocker.stub() installers = {list: func} obj = [] # Run: Success _extras.install(obj, _installers=installers) # Verify func.assert_called_with(obj) # Run & Verify Failure with pytest.raises(
TypeError)
pytest.raises
variable
tests/unit/test__extras.py
test_install
40
null
prkumar/uplink
from uplink import session def test_auth_set(uplink_builder_mock): # Setup sess = session.Session(uplink_builder_mock) # Run sess.auth = ("username", "password") # Verify assert ("username", "password") ==
uplink_builder_mock.auth
assert
complex_expr
tests/unit/test_session.py
test_auth_set
55
null
prkumar/uplink
import collections import pytest from uplink import decorators, interfaces def method_annotation(): return decorators.MethodAnnotation() def method_annotation_mock(mocker): return mocker.Mock(spec=decorators.MethodAnnotation) def method_handler_builder(): return decorators.MethodAnnotationHandlerBuilde...
60
assert
numeric_literal
tests/unit/test_decorators.py
test_timeout
247
null