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
auth0/auth0-python
from auth0.management.core.query_encoder import encode_query def test_encode_query_with_none() -> None: encoded = encode_query(None) assert encoded is
None
assert
none_literal
tests/utils/test_query_encoding.py
test_encode_query_with_none
36
null
auth0/auth0-python
from typing import Any, List from .assets.models import ObjectWithOptionalFieldParams, ShapeParams from auth0.management.core.serialization import convert_and_respect_annotation_metadata UNION_TEST: ShapeParams = {"radius_measurement": 1.0, "shape_type": "circle", "id": "1"} UNION_TEST_CONVERTED = {"shapeType": "cir...
{ "string": "string", "long": 12345, "union": UNION_TEST_CONVERTED, "literal": "lit_one", "any": "any", }
assert
collection
tests/utils/test_serialization.py
test_convert_and_respect_annotation_metadata_in_nested_object
54
null
auth0/auth0-python
import unittest import requests from fnmatch import fnmatch from unittest import mock from unittest.mock import ANY from cryptography.hazmat.primitives import asymmetric, serialization from auth0.authentication.exceptions import RateLimitError from auth0.authentication.get_token import GetToken def get_private_key()...
RateLimitError)
self.assertRaises
variable
tests/authentication/test_get_token.py
test_backchannel_login_headers_on_slow_down
TestGetToken
351
null
auth0/auth0-python
import unittest import json from unittest import mock from auth0.authentication.pushed_authorization_requests import PushedAuthorizationRequests class TestRevokeToken(unittest.TestCase): @mock.patch("auth0.authentication.rest.RestClient.post") def test_par_custom_params(self, mock_post): a = PushedAu...
{ "client_id": "cid", "client_secret": "sh!", "response_type": "code", "redirect_uri": "https://example.com/callback", "foo": "bar", })
self.assertEqual
collection
tests/authentication/test_pushed_authorization_requests.py
test_par_custom_params
TestRevokeToken
39
null
auth0/auth0-python
import time from unittest.mock import MagicMock, patch import pytest from auth0.management import AsyncManagementClient, AsyncTokenProvider, ManagementClient, TokenProvider class TestTokenProvider: @patch("auth0.management.token_provider.httpx.Client") def test_get_token_refreshes_expired_token(self, mock_c...
"refreshed-token"
assert
string_literal
tests/management/test_management_client.py
test_get_token_refreshes_expired_token
TestTokenProvider
281
null
auth0/auth0-python
import unittest from unittest import mock import json import requests from auth0.authentication.exceptions import Auth0Error, RateLimitError from auth0.authentication.back_channel_login import BackChannelLogin class TestBackChannelLogin(unittest.TestCase): @mock.patch("auth0.authentication.rest.RestClient.post")...
{ "client_id": "cid", "client_secret": "clsec", "binding_message": "This is a binding message", "login_hint": "{ \"format\": \"iss_sub\", \"iss\": \"https://my.domain.auth0.com/\", \"sub\": \"auth0|[USER ID]\" }", "scope": "openid", })
self.assertEqual
collection
tests/authentication/test_back_channel_login.py
test_ciba
TestBackChannelLogin
25
null
auth0/auth0-python
from typing import Any, Dict import pytest from auth0.management.core.http_client import ( AsyncHttpClient, HttpClient, _build_url, get_request_body, remove_none_from_dict, ) from auth0.management.core.request_options import RequestOptions def get_request_options() -> RequestOptions: return {...
url
assert
variable
tests/utils/test_http_client.py
test_http_client_does_not_pass_empty_params_list
193
null
auth0/auth0-python
import base64 import json import sys import unittest from unittest import mock import requests from auth0.authentication.base import AuthenticationBase from auth0.authentication.exceptions import Auth0Error, RateLimitError class TestBase(unittest.TestCase): @mock.patch("requests.request") def test_post_rate...
"3")
self.assertEqual
string_literal
tests/authentication/test_base.py
test_post_rate_limit_error
TestBase
162
null
auth0/auth0-python
import json import time import unittest from unittest.mock import MagicMock, patch import jwt from auth0.authentication.token_verifier import ( AsymmetricSignatureVerifier, JwksFetcher, SignatureVerifier, SymmetricSignatureVerifier, TokenVerifier, ) from auth0.authentication.exceptions import Toke...
2)
self.assertEqual
numeric_literal
tests/authentication/test_token_verifier.py
test_get_jwks_json_twice_on_cache_expired
TestJwksFetcher
162
null
auth0/auth0-python
from auth0.management.core.query_encoder import encode_query def test_query_encoding_deep_objects() -> None: assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] assert encode_q...
[ ("hello_world[hello][world]", "today"), ("hello_world[test]", "this"), ("hi", "there"), ]
assert
collection
tests/utils/test_query_encoding.py
test_query_encoding_deep_objects
9
null
auth0/auth0-python
import time from unittest.mock import MagicMock, patch import pytest from auth0.management import AsyncManagementClient, AsyncTokenProvider, ManagementClient, TokenProvider class TestTokenProvider: @patch("auth0.management.token_provider.httpx.Client") def test_get_token_refreshes_expired_token(self, mock_c...
2
assert
numeric_literal
tests/management/test_management_client.py
test_get_token_refreshes_expired_token
TestTokenProvider
282
null
auth0/auth0-python
import unittest import requests from fnmatch import fnmatch from unittest import mock from unittest.mock import ANY from cryptography.hazmat.primitives import asymmetric, serialization from auth0.authentication.exceptions import RateLimitError from auth0.authentication.get_token import GetToken def get_private_key()...
"100")
self.assertEqual
string_literal
tests/authentication/test_get_token.py
test_backchannel_login_headers_on_slow_down
TestGetToken
356
null
auth0/auth0-python
from typing import Any, List from .assets.models import ObjectWithOptionalFieldParams, ShapeParams from auth0.management.core.serialization import convert_and_respect_annotation_metadata UNION_TEST: ShapeParams = {"radius_measurement": 1.0, "shape_type": "circle", "id": "1"} UNION_TEST_CONVERTED = {"shapeType": "cir...
UNION_TEST_CONVERTED
assert
variable
tests/utils/test_serialization.py
test_convert_and_respect_annotation_metadata_in_union
66
null
auth0/auth0-python
import base64 import json import sys import unittest from unittest import mock import requests from auth0.authentication.base import AuthenticationBase from auth0.authentication.exceptions import Auth0Error, RateLimitError class TestBase(unittest.TestCase): @mock.patch("requests.request") def test_post_incl...
1)
self.assertEqual
numeric_literal
tests/authentication/test_base.py
test_post_includes_telemetry
TestBase
92
null
auth0/auth0-python
import unittest import json from unittest import mock from auth0.authentication.pushed_authorization_requests import PushedAuthorizationRequests class TestRevokeToken(unittest.TestCase): @mock.patch("auth0.authentication.rest.RestClient.post") def test_with_authorization_details(self, mock_post): a =...
json.dumps(expected_data, sort_keys=True))
self.assertEqual
func_call
tests/authentication/test_pushed_authorization_requests.py
test_with_authorization_details
TestRevokeToken
73
null
auth0/auth0-python
import json import time import unittest from unittest.mock import MagicMock, patch import jwt from auth0.authentication.token_verifier import ( AsymmetricSignatureVerifier, JwksFetcher, SignatureVerifier, SymmetricSignatureVerifier, TokenVerifier, ) from auth0.authentication.exceptions import Toke...
JWKS_URL)
assert_*
variable
tests/authentication/test_token_verifier.py
test_get_jwks_json_twice_on_cache_expired
TestJwksFetcher
151
null
auth0/auth0-python
import unittest from unittest import mock import json import requests from auth0.authentication.exceptions import Auth0Error, RateLimitError from auth0.authentication.back_channel_login import BackChannelLogin class TestBackChannelLogin(unittest.TestCase): @mock.patch("auth0.authentication.rest.RestClient.post"...
Exception)
self.assertRaises
variable
tests/authentication/test_back_channel_login.py
test_should_require_binding_message
TestBackChannelLogin
58
null
auth0/auth0-python
import unittest import requests from fnmatch import fnmatch from unittest import mock from unittest.mock import ANY from cryptography.hazmat.primitives import asymmetric, serialization from auth0.authentication.exceptions import RateLimitError from auth0.authentication.get_token import GetToken def get_private_key()...
429)
self.assertEqual
numeric_literal
tests/authentication/test_get_token.py
test_backchannel_login_headers_on_slow_down
TestGetToken
357
null
auth0/auth0-python
import inspect import os from typing import Any, Dict, Optional import requests from auth0.management.client import Auth0 def _get_wiremock_base_url() -> str: """Returns the WireMock base URL using the dynamically assigned port.""" port = os.environ.get("WIREMOCK_PORT", "8080") return f"http://localhost:...
200
assert
numeric_literal
tests/wire/conftest.py
verify_request_count
78
null
auth0/auth0-python
import base64 import json import sys import unittest from unittest import mock import requests from auth0.authentication.base import AuthenticationBase from auth0.authentication.exceptions import Auth0Error, RateLimitError class TestBase(unittest.TestCase): @mock.patch("requests.request") def test_post_rate...
429)
self.assertEqual
numeric_literal
tests/authentication/test_base.py
test_post_rate_limit_error
TestBase
156
null
auth0/auth0-python
import inspect import os from typing import Any, Dict, Optional import requests from auth0.management.client import Auth0 def _get_wiremock_base_url() -> str: """Returns the WireMock base URL using the dynamically assigned port.""" port = os.environ.get("WIREMOCK_PORT", "8080") return f"http://localhost:...
expected
assert
variable
tests/wire/conftest.py
verify_request_count
81
null
auth0/auth0-python
import unittest from unittest import mock import json import requests from auth0.authentication.exceptions import Auth0Error, RateLimitError from auth0.authentication.back_channel_login import BackChannelLogin class TestBackChannelLogin(unittest.TestCase): @mock.patch("requests.request") def test_server_err...
'foo')
self.assertEqual
string_literal
tests/authentication/test_back_channel_login.py
test_server_error
TestBackChannelLogin
51
null
auth0/auth0-python
import base64 import json import sys import unittest from unittest import mock import requests from auth0.authentication.base import AuthenticationBase from auth0.authentication.exceptions import Auth0Error, RateLimitError class TestBase(unittest.TestCase): @mock.patch("requests.request") def test_post_rate...
"e0")
self.assertEqual
string_literal
tests/authentication/test_base.py
test_post_rate_limit_error_without_headers
TestBase
180
null
auth0/auth0-python
from typing import Any, Dict import pytest from auth0.management.core.http_client import ( AsyncHttpClient, HttpClient, _build_url, get_request_body, remove_none_from_dict, ) from auth0.management.core.request_options import RequestOptions def get_request_options() -> RequestOptions: return {...
{}
assert
collection
tests/utils/test_http_client.py
test_explicit_empty_json_body_is_preserved
112
null
auth0/auth0-python
import base64 import json import sys import unittest from unittest import mock import requests from auth0.authentication.base import AuthenticationBase from auth0.authentication.exceptions import Auth0Error, RateLimitError class TestBase(unittest.TestCase): @mock.patch("requests.request") def test_post_incl...
"d")
self.assertEqual
string_literal
tests/authentication/test_base.py
test_post_includes_telemetry
TestBase
98
null
auth0/auth0-python
import base64 import json import sys import unittest from unittest import mock import requests from auth0.authentication.base import AuthenticationBase from auth0.authentication.exceptions import Auth0Error, RateLimitError class TestBase(unittest.TestCase): @mock.patch("requests.request") def test_post_erro...
"")
self.assertEqual
string_literal
tests/authentication/test_base.py
test_post_error_with_no_response_text
TestBase
249
null
auth0/auth0-python
import unittest from unittest import mock from auth0.authentication.passwordless import Passwordless class TestPasswordless(unittest.TestCase): @mock.patch("auth0.authentication.rest.RestClient.post") def test_send_email(self, mock_post): p = Passwordless("my.domain.com", "cid") p.email(email...
"https://my.domain.com/passwordless/start")
self.assertEqual
string_literal
tests/authentication/test_passwordless.py
test_send_email
TestPasswordless
16
null
auth0/auth0-python
import base64 import json import sys import unittest from unittest import mock import requests from auth0.authentication.base import AuthenticationBase from auth0.authentication.exceptions import Auth0Error, RateLimitError class TestBase(unittest.TestCase): @mock.patch("requests.request") def test_post_rate...
"desc")
self.assertEqual
string_literal
tests/authentication/test_base.py
test_post_rate_limit_error_without_headers
TestBase
181
null
apragacz/django-rest-registration
import pytest from rest_registration.settings import registration_settings def serializer(): serializer_class = registration_settings.REGISTER_SERIALIZER_CLASS return serializer_class(data={}) def test_generated_fields(settings_with_register_verification, serializer): field_names = set(serializer.get_fie...
{ "id", "username", "first_name", "last_name", "email", "password", "password_confirm", }
assert
collection
tests/unit_tests/api/serializers/test_register.py
test_generated_fields
14
null
apragacz/django-rest-registration
import pytest from django.test.utils import override_settings from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ) from tests.helpers.constants import ( RES...
url)
assert_*
variable
tests/unit_tests/api/views/reset_password/test_send_reset_password_link.py
assert_valid_send_link_email
369
null
apragacz/django-rest-registration
import pytest from django.test.utils import override_settings from rest_framework.exceptions import ErrorDetail from rest_framework.test import force_authenticate from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_forbidden, assert_response_is_ok, ) from tests.helpers....
expected_errors
assert
variable
tests/unit_tests/api/views/test_change_password.py
test_wrong_password_fail
178
null
apragacz/django-rest-registration
import pytest from django.core.exceptions import ImproperlyConfigured from rest_registration.utils.common import identity from rest_registration.utils.email import EmailTemplateConfig, parse_template_config from rest_registration.utils.html import ( convert_html_to_text_preserving_urls as default_convert_html_to_t...
ImproperlyConfigured)
pytest.raises
variable
tests/unit_tests/utils/test_email.py
test_parse_template_config_fail
110
null
apragacz/django-rest-registration
from typing import Callable, Dict, Iterable, Optional, Tuple, Type from urllib.parse import parse_qs, urlparse import pytest from rest_registration.utils.signers import URLParamsSigner from tests.helpers.timer import Timer def assert_valid_verification_url( url: str, expected_path: Optional[str] = No...
set(expected_fields)
assert
func_call
tests/helpers/verification.py
assert_valid_verification_url
28
null
apragacz/django-rest-registration
import time from unittest import mock from unittest.mock import patch import pytest from rest_registration.api.views.register import RegisterSigner from tests.helpers.api_views import ( assert_response_status_is_bad_request, assert_response_status_is_not_found, assert_response_status_is_ok, ) from tests.h...
response2)
assert_*
variable
tests/unit_tests/api/views/register/test_verify_registration.py
test_ok_then_fail_with_one_time_use
114
null
apragacz/django-rest-registration
from typing import Callable, Dict, Iterable, Optional, Tuple, Type from urllib.parse import parse_qs, urlparse import pytest from rest_registration.utils.signers import URLParamsSigner from tests.helpers.timer import Timer def assert_valid_verification_url( url: str, expected_path: Optional[str] = No...
url_sig_timestamp
assert
variable
tests/helpers/verification.py
assert_valid_verification_url
32
null
apragacz/django-rest-registration
from unittest import mock import pytest from django.core import signing from rest_framework.test import force_authenticate from rest_registration.api.views.register_email import RegisterEmailSigner from rest_registration.exceptions import SignatureExpired, SignatureInvalid from rest_registration.utils.verification im...
expected)
pytest.raises
variable
tests/unit_tests/api/views/register_email/test_register_email.py
test_verify_signer_or_bad_request_non_field_errors
185
null
apragacz/django-rest-registration
from django.test.utils import override_settings from rest_registration.api.views.reset_password import ResetPasswordSigner def test_signer_with_different_secret_keys( settings_with_reset_password_verification, user, ): data_to_sign = {'user_id': user.pk} secrets = [ '#0ka!t#6%28imjz+2t%l(()yu)...
signatures[1]
assert
complex_expr
tests/unit_tests/signers/test_reset_password.py
test_signer_with_different_secret_keys
23
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ) ...
response)
assert_*
variable
tests/unit_tests/api/views/register_email/test_verify_email.py
test_user_with_unique_email_user_email_already_exists_non_field_errors
208
null
apragacz/django-rest-registration
from textwrap import dedent import pytest from rest_registration.utils.html import MLStripperParseFailed, convert_html_to_text @pytest.mark.parametrize( ("html", "kwargs"), [ pytest.param( "<![spam]><html><body>eggs</body><html>", {"preserve_urls": True}, id="inval...
MLStripperParseFailed, match=r"spam")
pytest.raises
complex_expr
tests/unit_tests/utils/test_html.py
test_convert_html_to_text_fails
186
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from rest_framework.exceptions import ErrorDetail from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ...
request)
assert_*
variable
tests/unit_tests/api/views/reset_password/test_reset_password.py
_assert_response_is_bad_password
342
null
apragacz/django-rest-registration
import pytest from rest_framework.authtoken.models import Token from rest_registration.auth_token_managers import RestFrameworkAuthTokenManager from rest_registration.exceptions import AuthTokenError def auth_token_manager(): return RestFrameworkAuthTokenManager() def test_when_token_created_then_revoke_token_fa...
[token_key])
assert_*
collection
tests/unit_tests/auth_token_managers/test_rest_framework.py
test_when_token_created_then_revoke_token_fails_with_another_token
32
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from rest_framework.exceptions import ErrorDetail from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ...
expected_error_code
assert
variable
tests/unit_tests/api/views/reset_password/test_reset_password.py
_assert_response_is_bad_password
350
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/reset-password/" SUCCESS_URL = "/accounts/reset-password/success/" FAILUR...
FAILURE_URL
assert
variable
tests/unit_tests/contrib/verification_redirects/test_reset_password.py
test_tampered_signature
44
null
apragacz/django-rest-registration
from unittest import mock import pytest from django.core import signing from rest_framework.test import force_authenticate from rest_registration.api.views.register_email import RegisterEmailSigner from rest_registration.exceptions import SignatureExpired, SignatureInvalid from rest_registration.utils.verification im...
sent_emails)
assert_*
variable
tests/unit_tests/api/views/register_email/test_register_email.py
test_ok
47
null
apragacz/django-rest-registration
from django.apps import apps from django.core.checks.registry import registry from django.test.utils import override_settings from rest_registration.auth_token_managers import AbstractAuthTokenManager from rest_registration.checks import ErrorCode, WarningCode from rest_registration.settings import DEFAULTS from tests...
expected_error_ids
assert
variable
tests/unit_tests/test_checks.py
assert_error_codes_match
460
null
apragacz/django-rest-registration
import pytest from rest_registration.settings import registration_settings def serializer(): serializer_class = registration_settings.REGISTER_SERIALIZER_CLASS return serializer_class(data={}) def test_no_password_generated_fields( settings_with_register_verification, settings_with_register_no_confirm, s...
{ "id", "username", "first_name", "last_name", "email", "password", }
assert
collection
tests/unit_tests/api/serializers/test_register.py
test_no_password_generated_fields
39
null
apragacz/django-rest-registration
import pytest from django.test.utils import override_settings from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ) from tests.helpers.constants import ( RES...
timer)
assert_*
variable
tests/unit_tests/api/views/reset_password/test_send_reset_password_link.py
test_ok_when_custom_verification_templates_selector
356
null
apragacz/django-rest-registration
import pytest from django.core.exceptions import ValidationError as DjangoValidationError from rest_framework.exceptions import ErrorDetail, ValidationError from rest_registration.utils.validation import ( run_validators, transform_django_validation_error, ) def fake_validator_raising_with_text(value): ra...
expected_exc_detail
assert
variable
tests/unit_tests/utils/test_validation.py
test_run_validators_fails
82
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/verify-email/" SUCCESS_URL = "/accounts/verify-email/success/" FAILURE_UR...
FAILURE_URL
assert
variable
tests/unit_tests/contrib/verification_redirects/test_register_email.py
test_tampered_signature
41
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.register import RegisterSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/verify-account/" SUCCESS_URL = "/accounts/verify-account/success/" FAILURE_URL = "/a...
SUCCESS_URL
assert
variable
tests/unit_tests/contrib/verification_redirects/test_register.py
test_ok
25
null
apragacz/django-rest-registration
import pytest from django.test.utils import override_settings from rest_registration.utils.nested_settings import NestedSettings def test_user_settings(settings_defaults): user_settings = { 'A': 1, } settings = NestedSettings( user_settings, settings_defaults, (), 'NESTED_TEST_SETTING') ...
1
assert
numeric_literal
tests/unit_tests/test_settings.py
test_user_settings
14
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/verify-email/" SUCCESS_URL = "/accounts/verify-email/success/" FAILURE_UR...
old_email
assert
variable
tests/unit_tests/contrib/verification_redirects/test_register_email.py
test_tampered_signature
43
null
apragacz/django-rest-registration
import contextlib from collections.abc import Sequence from django.core import mail def assert_one_email_sent(sent_emails): _assert_emails_sent(sent_emails, 1) return sent_emails[0] def assert_no_email_sent(sent_emails): _assert_emails_sent(sent_emails, 0) def capture_sent_emails(): sent_emails = Em...
expected_num
assert
variable
tests/helpers/email.py
_assert_emails_sent
53
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/reset-password/" SUCCESS_URL = "/accounts/reset-password/success/" FAILUR...
302
assert
numeric_literal
tests/unit_tests/contrib/verification_redirects/test_reset_password.py
test_ok
24
null
apragacz/django-rest-registration
import datetime import time from unittest.mock import patch from urllib.parse import urlencode import pytest from django.core.signing import BadSignature, SignatureExpired from rest_registration.utils.signers import DataSigner, URLParamsSigner @pytest.mark.parametrize( "signer_cls", SIGNER_CLASSES, ) def test_ve...
BadSignature)
pytest.raises
variable
tests/unit_tests/utils/test_signers.py
test_verify_tamper_email_fail
53
null
apragacz/django-rest-registration
from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner def test_signer_with_different_secret_keys( settings_with_register_email_verification, user, ): email = 'testuser1@example.com' data_to_sign = { 'user_id': user.pk, ...
signatures[1]
assert
complex_expr
tests/unit_tests/signers/test_register_email.py
test_signer_with_different_secret_keys
27
null
apragacz/django-rest-registration
from urllib.parse import quote_plus as urlquote from urllib.parse import unquote_plus as urlunquote from urllib.parse import urlparse import pytest from django.contrib.auth import get_user_model from django.core.mail.backends.base import BaseEmailBackend from django.test.utils import override_settings from rest_regis...
data)
assert_*
variable
tests/unit_tests/api/views/register/test_register.py
test_ok_with_username_as_verification_id
145
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ) ...
response.data
assert
complex_expr
tests/unit_tests/api/views/register_email/test_verify_email.py
test_user_with_unique_email_user_email_already_exists_non_field_errors
209
null
apragacz/django-rest-registration
import datetime import time from unittest.mock import patch from urllib.parse import urlencode import pytest from django.core.signing import BadSignature, SignatureExpired from rest_registration.utils.signers import DataSigner, URLParamsSigner def test_verify_expired(unsigned_data): signer_cls = ExampleTimestamp...
SignatureExpired)
pytest.raises
variable
tests/unit_tests/utils/test_signers.py
test_verify_expired
105
null
apragacz/django-rest-registration
import pytest from rest_framework.authtoken.models import Token from rest_registration.auth_token_managers import RestFrameworkAuthTokenManager from rest_registration.exceptions import AuthTokenError def auth_token_manager(): return RestFrameworkAuthTokenManager() def test_when_token_created_then_revoke_token_su...
[])
assert_*
collection
tests/unit_tests/auth_token_managers/test_rest_framework.py
test_when_token_created_then_revoke_token_succeeds
16
null
apragacz/django-rest-registration
from urllib.parse import quote_plus as urlquote from urllib.parse import unquote_plus as urlunquote from urllib.parse import urlparse import pytest from django.contrib.auth import get_user_model from django.core.mail.backends.base import BaseEmailBackend from django.test.utils import override_settings from rest_regis...
user)
assert_*
variable
tests/unit_tests/api/views/register/test_register.py
test_ok_with_username_as_verification_id
149
null
apragacz/django-rest-registration
import contextlib from rest_registration.utils.signers import get_current_timestamp def capture_time(current_timestamp_getter=get_current_timestamp): timer = Timer(current_timestamp_getter=current_timestamp_getter) timer.set_start_time() try: yield timer finally: timer.set_end_time() ...
None
assert
none_literal
tests/helpers/timer.py
start_time
Timer
26
null
apragacz/django-rest-registration
from textwrap import dedent import rest_framework from django.contrib.sessions.middleware import SessionMiddleware from rest_framework import status from rest_framework.test import APIRequestFactory from .views import ViewProvider rest_framework_version_info = tuple( int(s) for s in rest_framework.__version__.sp...
status_code
assert
variable
tests/helpers/api_views.py
_assert_response
129
null
apragacz/django-rest-registration
import pytest from rest_framework.test import force_authenticate from tests.helpers.api_views import assert_response_is_ok from tests.helpers.constants import USERNAME from tests.helpers.views import ViewProvider def api_view_provider(): return ViewProvider("profile") def old_email(email_change): return emai...
old_email
assert
variable
tests/unit_tests/api/views/test_profile.py
test_update_email_via_profile
128
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from rest_framework.exceptions import ErrorDetail from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ...
response)
assert_*
variable
tests/unit_tests/api/views/reset_password/test_reset_password.py
test_reset_ok
28
null
apragacz/django-rest-registration
from unittest import mock import pytest from django.core import signing from rest_framework.test import force_authenticate from rest_registration.api.views.register_email import RegisterEmailSigner from rest_registration.exceptions import SignatureExpired, SignatureInvalid from rest_registration.utils.verification im...
url)
assert_*
variable
tests/unit_tests/api/views/register_email/test_register_email.py
assert_valid_register_email_verification_email
278
null
apragacz/django-rest-registration
from django.apps import apps from django.core.checks.registry import registry from django.test.utils import override_settings from rest_registration.auth_token_managers import AbstractAuthTokenManager from rest_registration.checks import ErrorCode, WarningCode from rest_registration.settings import DEFAULTS from tests...
expected_messages
assert
variable
tests/unit_tests/test_checks.py
test_fail_when_no_templates_preferred_setup
281
null
apragacz/django-rest-registration
from django.apps import apps from django.core.checks.registry import registry from django.test.utils import override_settings from rest_registration.auth_token_managers import AbstractAuthTokenManager from rest_registration.checks import ErrorCode, WarningCode from rest_registration.settings import DEFAULTS from tests...
[])
assert_*
collection
tests/unit_tests/test_checks.py
test_ok_when_minimal_setup
236
null
apragacz/django-rest-registration
import pytest from django.test.utils import override_settings from rest_registration.utils.nested_settings import NestedSettings def test_user_settings(settings_defaults): user_settings = { 'A': 1, } settings = NestedSettings( user_settings, settings_defaults, (), 'NESTED_TEST_SETTING') ...
3
assert
numeric_literal
tests/unit_tests/test_settings.py
test_user_settings
15
null
apragacz/django-rest-registration
from textwrap import dedent import rest_framework from django.contrib.sessions.middleware import SessionMiddleware from rest_framework import status from rest_framework.test import APIRequestFactory from .views import ViewProvider rest_framework_version_info = tuple( int(s) for s in rest_framework.__version__.sp...
expected_status_code
assert
variable
tests/helpers/api_views.py
_assert_response
127
null
apragacz/django-rest-registration
from unittest import mock import pytest from django.core import signing from rest_framework.test import force_authenticate from rest_registration.api.views.register_email import RegisterEmailSigner from rest_registration.exceptions import SignatureExpired, SignatureInvalid from rest_registration.utils.verification im...
[new_email]
assert
collection
tests/unit_tests/api/views/register_email/test_register_email.py
assert_valid_register_email_verification_email
275
null
apragacz/django-rest-registration
import time from unittest import mock from unittest.mock import patch import pytest from rest_registration.api.views.register import RegisterSigner from tests.helpers.api_views import ( assert_response_status_is_bad_request, assert_response_status_is_not_found, assert_response_status_is_ok, ) from tests.h...
response1)
assert_*
variable
tests/unit_tests/api/views/register/test_verify_registration.py
test_ok_then_fail_with_one_time_use
109
null
apragacz/django-rest-registration
from unittest import mock import pytest from django.core import signing from rest_framework.test import force_authenticate from rest_registration.api.views.register_email import RegisterEmailSigner from rest_registration.exceptions import SignatureExpired, SignatureInvalid from rest_registration.utils.verification im...
new_email)
assert_*
variable
tests/unit_tests/api/views/register_email/test_register_email.py
test_user_with_unique_email_ok_but_notification_already_exists
103
null
apragacz/django-rest-registration
import pytest from django.core.exceptions import ValidationError as DjangoValidationError from rest_framework.exceptions import ErrorDetail, ValidationError from rest_registration.utils.validation import ( run_validators, transform_django_validation_error, ) def fake_validator_raising_with_text(value): ra...
expected_output_exc.args[0]
assert
complex_expr
tests/unit_tests/utils/test_validation.py
test_transform_django_validation_error
138
null
apragacz/django-rest-registration
import pytest from rest_framework.test import force_authenticate from tests.helpers.api_views import assert_response_is_ok from tests.helpers.constants import USERNAME from tests.helpers.views import ViewProvider def test_retrieve_ok( settings_minimal, user, api_view_provider, api_factory, ): requ...
user.id
assert
complex_expr
tests/unit_tests/api/views/test_profile.py
test_retrieve_ok
20
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.register import RegisterSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/verify-account/" SUCCESS_URL = "/accounts/verify-account/success/" FAILURE_URL = "/a...
FAILURE_URL
assert
variable
tests/unit_tests/contrib/verification_redirects/test_register.py
test_tampered_signature
43
null
apragacz/django-rest-registration
import pytest from django.test.utils import override_settings from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ) from tests.helpers.constants import ( RES...
response)
assert_*
variable
tests/unit_tests/api/views/reset_password/test_send_reset_password_link.py
test_ok_when_custom_verification_templates_selector
350
null
apragacz/django-rest-registration
import pytest from rest_registration.settings import registration_settings def serializer(): serializer_class = registration_settings.REGISTER_SERIALIZER_CLASS return serializer_class(data={}) def test_simple_email_based_user_generated_fields( settings_with_register_verification, settings_with_simple...
{"id", "email", "password", "password_confirm"}
assert
collection
tests/unit_tests/api/serializers/test_register.py
test_simple_email_based_user_generated_fields
32
null
apragacz/django-rest-registration
import time from unittest import mock from unittest.mock import patch import pytest from rest_registration.api.views.register import RegisterSigner from tests.helpers.api_views import ( assert_response_status_is_bad_request, assert_response_status_is_not_found, assert_response_status_is_ok, ) from tests.h...
response)
assert_*
variable
tests/unit_tests/api/views/register/test_verify_registration.py
test_ok
28
null
apragacz/django-rest-registration
import pytest from django.test.utils import modify_settings, override_settings from rest_framework.authtoken.models import Token from rest_framework.test import force_authenticate from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_forbidden, assert_response_is_ok, ) fr...
"Authentication token cannot be revoked"
assert
string_literal
tests/unit_tests/api/views/login/test_logout.py
test_fail_when_faulty_auth_token_manager
159
null
apragacz/django-rest-registration
import pytest from django.core.exceptions import ValidationError as DjangoValidationError from rest_framework.exceptions import ErrorDetail, ValidationError from rest_registration.utils.validation import ( run_validators, transform_django_validation_error, ) def fake_validator_raising_with_text(value): ra...
ValidationError)
pytest.raises
variable
tests/unit_tests/utils/test_validation.py
test_run_validators_fails
79
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from rest_framework.exceptions import ErrorDetail from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ...
expected_error_message
assert
variable
tests/unit_tests/api/views/reset_password/test_reset_password.py
_assert_response_is_bad_password
349
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/verify-email/" SUCCESS_URL = "/accounts/verify-email/success/" FAILURE_UR...
SUCCESS_URL
assert
variable
tests/unit_tests/contrib/verification_redirects/test_register_email.py
test_ok
24
null
apragacz/django-rest-registration
from textwrap import dedent import rest_framework from django.contrib.sessions.middleware import SessionMiddleware from rest_framework import status from rest_framework.test import APIRequestFactory from .views import ViewProvider rest_framework_version_info = tuple( int(s) for s in rest_framework.__version__.sp...
response)
assert_*
variable
tests/helpers/api_views.py
assert_response_status_is_ok
48
null
apragacz/django-rest-registration
import pytest from rest_framework.authtoken.models import Token from rest_registration.auth_token_managers import RestFrameworkAuthTokenManager from rest_registration.exceptions import AuthTokenError def auth_token_manager(): return RestFrameworkAuthTokenManager() def assert_token_keys_equals(user, expected_toke...
expected_token_keys
assert
variable
tests/unit_tests/auth_token_managers/test_rest_framework.py
assert_token_keys_equals
36
null
apragacz/django-rest-registration
import pytest from rest_framework.test import force_authenticate from tests.helpers.api_views import assert_response_is_ok from tests.helpers.constants import USERNAME from tests.helpers.views import ViewProvider def test_patch_names_ok( settings_minimal, user, api_view_provider, api_factory, ): r...
"Donald"
assert
string_literal
tests/unit_tests/api/views/test_profile.py
test_patch_names_ok
42
null
apragacz/django-rest-registration
import django import pytest from rest_framework.authtoken.models import Token from rest_framework.settings import api_settings from rest_framework.test import APIRequestFactory from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_ok, ) from tests.helpers.settings import ( ...
user
assert
variable
tests/unit_tests/api/views/login/test_login.py
test_ok_with_session_and_token
71
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ) ...
email_change.old_value
assert
complex_expr
tests/unit_tests/api/views/register_email/test_verify_email.py
assertion
236
null
apragacz/django-rest-registration
import time from unittest import mock from unittest.mock import patch import pytest from rest_registration.api.views.register import RegisterSigner from tests.helpers.api_views import ( assert_response_status_is_bad_request, assert_response_status_is_not_found, assert_response_status_is_ok, ) from tests.h...
user)
assert_*
variable
tests/unit_tests/api/views/register/test_verify_registration.py
test_ok_login
134
null
apragacz/django-rest-registration
import pytest from django.core.exceptions import ImproperlyConfigured from rest_registration.utils.common import identity from rest_registration.utils.email import EmailTemplateConfig, parse_template_config from rest_registration.utils.html import ( convert_html_to_text_preserving_urls as default_convert_html_to_t...
expected_result
assert
variable
tests/unit_tests/utils/test_email.py
test_parse_template_config_ok
84
null
apragacz/django-rest-registration
from textwrap import dedent import pytest from rest_registration.utils.html import MLStripperParseFailed, convert_html_to_text @pytest.mark.parametrize( ("html", "kwargs", "expected_text"), [ pytest.param( dedent( """\ <!DOCTYPE html> <html><body> ...
expected_text
assert
variable
tests/unit_tests/utils/test_html.py
test_convert_html_to_text_succeeds
172
null
apragacz/django-rest-registration
import pytest from rest_registration.exceptions import UserNotFound from rest_registration.utils.users import ( authenticate_by_login_data, get_user_field_names, get_user_public_field_names, ) from tests.helpers.constants import USER_PASSWORD, USERNAME from tests.helpers.settings import override_rest_regis...
UserNotFound)
pytest.raises
variable
tests/unit_tests/utils/test_users.py
test_authenticate_by_login_data_fails
216
null
apragacz/django-rest-registration
import pytest from rest_registration.exceptions import BadRequest, ErrorDetail, _extract_details from tests.helpers.settings import override_rest_registration_settings @pytest.mark.parametrize( ("detail", "code", "expected_obj_detail"), [ ("test err", "test-err", ErrorDetail("test err", code="test-err")),...
expected_obj_detail
assert
variable
tests/unit_tests/test_exceptions.py
test_bad_request_detail
15
null
apragacz/django-rest-registration
import django import pytest from rest_framework.authtoken.models import Token from rest_framework.settings import api_settings from rest_framework.test import APIRequestFactory from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_ok, ) from tests.helpers.settings import ( ...
response)
assert_*
variable
tests/unit_tests/api/views/login/test_login.py
test_ok_with_session_and_token
67
null
apragacz/django-rest-registration
import time from unittest.mock import patch import pytest from rest_framework.exceptions import ErrorDetail from rest_registration.api.views.reset_password import ResetPasswordSigner from tests.helpers.api_views import ( assert_response_is_bad_request, assert_response_is_not_found, assert_response_is_ok, ...
1
assert
numeric_literal
tests/unit_tests/api/views/reset_password/test_reset_password.py
_assert_response_is_bad_password
346
null
apragacz/django-rest-registration
import pytest from rest_framework.test import force_authenticate from tests.helpers.api_views import assert_response_is_ok from tests.helpers.constants import USERNAME from tests.helpers.views import ViewProvider def test_patch_username_ok( settings_minimal, user, api_view_provider, api_factory, ): ...
"dknuth"
assert
string_literal
tests/unit_tests/api/views/test_profile.py
test_patch_username_ok
65
null
apragacz/django-rest-registration
import pytest from django.test.utils import override_settings from rest_registration.utils.nested_settings import NestedSettings @override_settings( REST_REGISTRATION={ 'A': 5, } ) def test_django_settings(settings_defaults): settings = NestedSettings( None, settings_defaults, (), 'REST_RE...
5
assert
numeric_literal
tests/unit_tests/test_settings.py
test_django_settings
26
null
apragacz/django-rest-registration
import pytest from django.conf import settings from django.test.utils import override_settings from rest_registration.api.views.register_email import RegisterEmailSigner from tests.helpers.views import ViewProvider VERIFICATION_URL = "/accounts/verify-email/" SUCCESS_URL = "/accounts/verify-email/success/" FAILURE_UR...
new_email
assert
variable
tests/unit_tests/contrib/verification_redirects/test_register_email.py
test_ok
26
null
apragacz/django-rest-registration
import re def assert_no_url_in_text(text): _assert_urls_in_text(text, 0, r'https?://.*') def assert_one_url_line_in_text(text): url_lines = _assert_urls_in_text(text, 1, r'^(?P<url>https?://.*)$') return url_lines[0] def assert_one_url_in_brackets_in_text(text): urls = _assert_urls_in_text(text, 1, r...
expected_num
assert
variable
tests/helpers/text.py
_assert_urls_in_text
27
null
apragacz/django-rest-registration
import pytest from rest_framework.test import force_authenticate from tests.helpers.api_views import assert_response_is_ok from tests.helpers.constants import USERNAME from tests.helpers.views import ViewProvider def test_patch_username_ok( settings_minimal, user, api_view_provider, api_factory, ): ...
old_first_name
assert
variable
tests/unit_tests/api/views/test_profile.py
test_patch_username_ok
66
null