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
django-commons/django-unicorn
import pytest from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView from example.coffee.models import Flavor, Taste @pytest.mark.django_db def test_m2m_overwriting(client): # Setup flavor1 = Flavor.objects.create(name="Flavor 1") flavor2 = Flavor.obj...
taste.flavor.all()
assert
func_call
tests/views/test_m2m_overwriting.py
test_m2m_overwriting
62
null
django-commons/django-unicorn
from django_unicorn.components import UnicornView from django_unicorn.views.utils import _is_component_field_model_or_unicorn_field from example.coffee.models import Flavor def test_type_hint(): component = TypeHintView(component_name="asdf", component_id="test_type_hint") name = "model" actual = _is_compo...
Flavor
assert
variable
tests/views/test_is_component_field_model_or_unicorn_field.py
test_type_hint
21
null
django-commons/django-unicorn
from unittest.mock import MagicMock, patch import pytest from django_unicorn.cacher import ( CacheableComponent, PointerUnicornView, cache_full_tree, restore_from_cache, ) from django_unicorn.components import UnicornView from django_unicorn.errors import UnicornCacheError def test_cacheable_componen...
request
assert
variable
tests/test_cacher.py
test_cacheable_component_request_is_none_then_restored
36
null
django-commons/django-unicorn
import time from copy import deepcopy from multiprocessing.dummy import Pool as ThreadPool import orjson import pytest import shortuuid from django_unicorn.components import UnicornView from django_unicorn.utils import generate_checksum def _set_serial( settings, enabled, timeout, cache_backend="djan...
2
assert
numeric_literal
tests/views/message/test_call_method_multiple.py
test_message_two
118
null
django-commons/django-unicorn
import time import shortuuid from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_element from django_unicorn.utils import generate_checksum def test_message_target_only_key(client): data = {"clicked": False} message = { "actionQue...
"test-target-key"
assert
string_literal
tests/views/message/test_target.py
test_message_target_only_key
175
null
django-commons/django-unicorn
import pytest from django_unicorn.typer import _construct_model from example.books.models import Author, Book from example.coffee.models import Flavor def test_construct_model_simple_model(): model_data = { "pk": 1, "name": "test-name", } actual = _construct_model(Flavor, model_data) ...
"test-name"
assert
string_literal
tests/views/utils/test_construct_model.py
test_construct_model_simple_model
17
null
django-commons/django-unicorn
import json from unittest.mock import Mock import pytest from django_unicorn.components import Component from django_unicorn.errors import RenderNotModifiedError from django_unicorn.utils import generate_checksum from django_unicorn.views.action import CallMethod, Refresh, SyncInput, Toggle from django_unicorn.views....
(1,)
assert
collection
tests/views/test_unit_views.py
test_action_call_method
25
null
django-commons/django-unicorn
from django.utils.functional import cached_property from django_unicorn.components.unicorn_view import UnicornView, constructed_views_cache def test_issue_650_property_access_on_restore(settings, rf): request = rf.get("/") request.user = User() # Register component settings.UNICORN = {**settings.UNIC...
1
assert
numeric_literal
tests/components/test_issue_650.py
test_issue_650_property_access_on_restore
34
null
django-commons/django-unicorn
import pytest from django_unicorn.views.utils import set_property_from_data from example.coffee.models import Flavor @pytest.mark.django_db def test_set_property_fk_with_pk_int(): # Arrange parent = Flavor.objects.create(name="Parent") child = Flavor.objects.create(name="Child") # No parent initially ...
parent.pk
assert
complex_expr
tests/views/test_utils_set_property_fk.py
test_set_property_fk_with_pk_int
18
null
django-commons/django-unicorn
import time from uuid import uuid4 import pytest from django.http import JsonResponse from django_unicorn.errors import ComponentClassLoadError, ComponentModuleLoadError from django_unicorn.views import message def assert_json_error(response, error): assert isinstance(response, JsonResponse) assert response....
"Missing meta")
assert_*
string_literal
tests/views/message/test_message.py
test_message_no_meta
54
null
django-commons/django-unicorn
import pytest from django.template.backends.django import Template from django_unicorn.utils import ( create_template, generate_checksum, get_method_arguments, is_non_string_sequence, sanitize_html, ) def test_generate_checksum_invalid(settings): settings.SECRET_KEY = "asdf" with pytest....
TypeError)
pytest.raises
variable
tests/test_utils.py
test_generate_checksum_invalid
44
null
django-commons/django-unicorn
import shortuuid from tests.views.fake_components import FakeComponent from tests.views.message.test_calls import FakeCallsComponent from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_ele...
0
assert
numeric_literal
tests/views/message/test_hash.py
test_message_hash_no_change_but_parent
282
null
django-commons/django-unicorn
import time import shortuuid from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_element from django_unicorn.utils import generate_checksum def test_message_target_id(client): data = {"clicked": False} message = { "actionQueue": [...
"test-target-id"
assert
string_literal
tests/views/message/test_target.py
test_message_target_id
113
null
django-commons/django-unicorn
from datetime import datetime import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.utils import set_property_value from example.coffee.models import Flavor, Taste @pytest.mark.django_db def test_set_property_value_queryset(): component = FakeComponent(component...
2
assert
numeric_literal
tests/views/action_parsers/utils/test_set_property_value.py
test_set_property_value_queryset
101
null
django-commons/django-unicorn
import time import orjson import shortuuid from django_unicorn.utils import generate_checksum def _post_message_and_get_body(client, message): response = client.post( "/message/tests.views.fake_components.FakeComponent", message, content_type="application/json", ) body = orjson.l...
True
assert
bool_literal
tests/views/message/test_toggle.py
test_message_toggle
35
null
django-commons/django-unicorn
import types import orjson import pytest from tests.views.fake_components import ( FakeAuthenticationComponent, FakeValidationComponent, ) from django_unicorn.components import UnicornView from django_unicorn.serializer import InvalidFieldNameError def component(): return ExampleComponent(component_id="a...
None
assert
none_literal
tests/components/test_component.py
test_init_with_get_template_names
40
null
django-commons/django-unicorn
from unittest.mock import MagicMock, patch import pytest from django_unicorn.cacher import ( CacheableComponent, PointerUnicornView, cache_full_tree, restore_from_cache, ) from django_unicorn.components import UnicornView from django_unicorn.errors import UnicornCacheError def test_cacheable_componen...
[child.parent]
assert
collection
tests/test_cacher.py
test_cacheable_component_restores_state_on_pickle_failure
248
null
django-commons/django-unicorn
import time from copy import deepcopy from multiprocessing.dummy import Pool as ThreadPool import orjson import pytest import shortuuid from django_unicorn.components import UnicornView from django_unicorn.utils import generate_checksum def _set_serial( settings, enabled, timeout, cache_backend="djan...
1
assert
numeric_literal
tests/views/message/test_call_method_multiple.py
test_message_single
90
null
django-commons/django-unicorn
import datetime from dataclasses import dataclass from typing import get_type_hints as typing_get_type_hints from pydantic import BaseModel from django_unicorn.components import UnicornView from django_unicorn.typer import cast_attribute_value, cast_value, get_type_hints from example.coffee.models import Flavor def ...
"abc"
assert
string_literal
tests/test_typer.py
test_cast_value_tuple_of_dicts_gh641
192
null
django-commons/django-unicorn
import pytest from django_unicorn.settings import ( get_cache_alias, get_minify_html_enabled, get_morpher_settings, get_script_location, get_serial_enabled, ) def test_get_serial_enabled(settings): settings.UNICORN = {**settings.UNICORN, "SERIAL": {**settings.UNICORN.get("SERIAL", {}), "ENABLE...
False
assert
bool_literal
tests/test_settings.py
test_get_serial_enabled
31
null
django-commons/django-unicorn
import datetime from dataclasses import dataclass from typing import get_type_hints as typing_get_type_hints from pydantic import BaseModel from django_unicorn.components import UnicornView from django_unicorn.typer import cast_attribute_value, cast_value, get_type_hints from example.coffee.models import Flavor def ...
{"id": 1}
assert
collection
tests/test_typer.py
test_cast_value_model_dict
95
null
django-commons/django-unicorn
import time import orjson import shortuuid from django_unicorn.utils import generate_checksum def _post_message_and_get_body(client, message, url="/message/tests.views.fake_components.FakeComponent"): response = client.post( url, message, content_type="application/json", ) body =...
True
assert
bool_literal
tests/views/message/test_set_property.py
test_setter
35
null
django-commons/django-unicorn
import time from typing import Any import orjson import shortuuid from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView, unicorn_view from django_unicorn.utils import generate_checksum def _post_to_component( client, method_name: str, component_name...
{}
assert
collection
tests/views/message/test_call_method.py
test_message_call_method_return_value
132
null
django-commons/django-unicorn
from django_unicorn.templatetags.unicorn import unicorn_scripts def test_unicorn_scripts(): actual = unicorn_scripts() assert actual["CSRF_HEADER_NAME"] ==
"X-CSRFTOKEN"
assert
string_literal
tests/templatetags/test_unicorn_scripts.py
test_unicorn_scripts
7
null
django-commons/django-unicorn
import pytest from django_unicorn.components import UnicornView from django_unicorn.serializer import dumps, loads from django_unicorn.typer import _construct_model from django_unicorn.views.utils import set_property_from_data from example.coffee.models import Flavor @pytest.mark.django_db def test_model_foreign_key(...
parent.pk
assert
complex_expr
tests/test_model_lifecycle.py
test_model_foreign_key
49
null
django-commons/django-unicorn
import io import os import uuid import pytest from django.core.management.base import CommandError from django_unicorn.management.commands.startunicorn import Command def test_handle_reply_n(settings, tmp_path, monkeypatch, capsys): settings.BASE_DIR = tmp_path # Reply "n" monkeypatch.setattr("sys.stdin...
CommandError)
pytest.raises
variable
tests/management/commands/startunicorn/test_handle.py
test_handle_reply_n
170
null
django-commons/django-unicorn
from django_unicorn.templatetags.unicorn import unicorn_scripts def test_unicorn_scripts_csrf_cookie_name(settings): settings.CSRF_COOKIE_NAME = "unicorn-csrftoken" actual = unicorn_scripts() assert actual["CSRF_COOKIE_NAME"] ==
"unicorn-csrftoken"
assert
string_literal
tests/templatetags/test_unicorn_scripts.py
test_unicorn_scripts_csrf_cookie_name
48
null
django-commons/django-unicorn
import orjson import pytest from django.template import Context from django.template.base import Parser, Token, TokenType from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_element from django_unicorn.errors import ComponentNotValidError from djan...
actual
assert
variable
tests/templatetags/test_unicorn_render.py
test_unicorn_render_arg
153
null
django-commons/django-unicorn
import shortuuid from django.test import Client, RequestFactory from django_unicorn.components import UnicornView from django_unicorn.signals import ( component_completed, component_hydrated, component_method_called, component_method_calling, component_mounted, component_post_parsed, compon...
"boom"
assert
string_literal
tests/test_signals.py
test_component_method_called_signal_failure
183
null
django-commons/django-unicorn
import datetime from dataclasses import dataclass from typing import get_type_hints as typing_get_type_hints from pydantic import BaseModel from django_unicorn.components import UnicornView from django_unicorn.typer import cast_attribute_value, cast_value, get_type_hints from example.coffee.models import Flavor def ...
expected
assert
variable
tests/test_typer.py
test_get_type_hints
18
null
django-commons/django-unicorn
from datetime import date, datetime, time, timedelta from types import MappingProxyType from uuid import UUID, uuid4 import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.call_method import _call_method_name from example.coffee.models import Flavor def _get_actual(m...
"test"
assert
string_literal
tests/views/action_parsers/call_method/test_call_method_name.py
test_call_method_name_with_custom_class_type_hint
253
null
django-commons/django-unicorn
import shortuuid from django.test import Client, RequestFactory from django_unicorn.components import UnicornView from django_unicorn.signals import ( component_completed, component_hydrated, component_method_called, component_method_calling, component_mounted, component_post_parsed, compon...
True
assert
bool_literal
tests/test_signals.py
test_component_method_called_signal_success
149
null
django-commons/django-unicorn
import pytest from django_unicorn.settings import ( get_cache_alias, get_minify_html_enabled, get_morpher_settings, get_script_location, get_serial_enabled, ) def test_get_script_location(settings): assert get_script_location() ==
"after"
assert
string_literal
tests/test_settings.py
test_get_script_location
62
null
django-commons/django-unicorn
import sys from datetime import datetime, timezone from typing import List # noqa: UP035 import pytest from django.db.models import Model, QuerySet from django_unicorn.components import UnicornView from django_unicorn.typing import QuerySetType from django_unicorn.views.utils import set_property_from_data from examp...
"test-qs"
assert
string_literal
tests/views/utils/test_set_property_from_data.py
component_queryset_field_asserts
59
null
django-commons/django-unicorn
import json from unittest.mock import Mock import pytest from django_unicorn.components import Component from django_unicorn.errors import RenderNotModifiedError from django_unicorn.utils import generate_checksum from django_unicorn.views.action import CallMethod, Refresh, SyncInput, Toggle from django_unicorn.views....
{}
assert
collection
tests/views/test_unit_views.py
test_component_request_parsing
55
null
django-commons/django-unicorn
import types import orjson import pytest from tests.views.fake_components import ( FakeAuthenticationComponent, FakeValidationComponent, ) from django_unicorn.components import UnicornView from django_unicorn.serializer import InvalidFieldNameError def component(): return ExampleComponent(component_id="a...
1
assert
numeric_literal
tests/components/test_component.py
test_init_attribute_names_cache
45
null
django-commons/django-unicorn
import shortuuid from tests.views.message.utils import post_and_get_response from django_unicorn.cacher import cache_full_tree from django_unicorn.components import UnicornView def test_nested_method_call_on_parent(client): """ Test that calling a method on a parent component (e.g. $parent.increment()) works ...
1
assert
numeric_literal
tests/views/message/test_nested_method_call.py
test_nested_method_call_on_parent
57
null
django-commons/django-unicorn
import types import orjson import pytest from tests.views.fake_components import ( FakeAuthenticationComponent, FakeValidationComponent, ) from django_unicorn.components import UnicornView from django_unicorn.serializer import InvalidFieldNameError def component(): return ExampleComponent(component_id="a...
actual
assert
variable
tests/components/test_component.py
test_meta_javascript_exclude_nested_multiple_with_spaces
290
null
django-commons/django-unicorn
from django_unicorn.call_method_parser import parse_call_method_name def setup_function(): """Clears lru_cache before every test in the module.""" parse_call_method_name.cache_clear() def test_single_int_arg(): expected = ("set_name", (1,), {}) actual = parse_call_method_name("set_name(1)") asse...
expected
assert
variable
tests/call_method_parser/test_parse_call_method_name.py
test_single_int_arg
13
null
django-commons/django-unicorn
from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView def test_html_entities_encoded(client): data = {"hello": "test"} action_queue = [ { "payload": {"name": "hello", "value": "<b>test1</b>"}, "type": "syncInput", ...
response["dom"]
assert
complex_expr
tests/views/test_process_component_request.py
test_html_entities_encoded
38
null
django-commons/django-unicorn
from datetime import datetime import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.utils import set_property_value from example.coffee.models import Flavor, Taste @pytest.mark.django_db def test_set_property_value_queryset(): component = FakeComponent(component...
queryset
assert
variable
tests/views/action_parsers/utils/test_set_property_value.py
test_set_property_value_queryset
102
null
django-commons/django-unicorn
import time import shortuuid from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_element from django_unicorn.utils import generate_checksum def test_message_generated_checksum_matches_dom_checksum(client): data = {"clicked": False} messag...
True
assert
bool_literal
tests/views/message/test_target.py
test_message_generated_checksum_matches_dom_checksum
46
null
django-commons/django-unicorn
import sys from datetime import datetime, timezone from typing import List # noqa: UP035 import pytest from django.db.models import Model, QuerySet from django_unicorn.components import UnicornView from django_unicorn.typing import QuerySetType from django_unicorn.views.utils import set_property_from_data from examp...
"test-test"
assert
string_literal
tests/views/utils/test_set_property_from_data.py
test_set_property_from_data_model
184
null
django-commons/django-unicorn
from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView def test_message_nested_child_calls(client): """Test that grandchild component calls are included in deeply nested scenarios.""" action_queue = [ { "payload": {"name": "call_nested...
3
assert
numeric_literal
tests/views/message/test_calls.py
test_message_nested_child_calls
202
null
django-commons/django-unicorn
import pytest from django.template.backends.django import Template from django_unicorn.utils import ( create_template, generate_checksum, get_method_arguments, is_non_string_sequence, sanitize_html, ) def test_generate_checksum_bytes(settings): settings.SECRET_KEY = "asdf" expected = "Tfx...
actual
assert
variable
tests/test_utils.py
test_generate_checksum_bytes
19
null
django-commons/django-unicorn
import datetime from dataclasses import dataclass from typing import get_type_hints as typing_get_type_hints from pydantic import BaseModel from django_unicorn.components import UnicornView from django_unicorn.typer import cast_attribute_value, cast_value, get_type_hints from example.coffee.models import Flavor def ...
1
assert
numeric_literal
tests/test_typer.py
test_cast_value_model_int
116
null
django-commons/django-unicorn
import types import orjson import pytest from tests.views.fake_components import ( FakeAuthenticationComponent, FakeValidationComponent, ) from django_unicorn.components import UnicornView from django_unicorn.serializer import InvalidFieldNameError def component(): return ExampleComponent(component_id="a...
4
assert
numeric_literal
tests/components/test_component.py
test_get_context_data
160
null
django-commons/django-unicorn
import pytest from django_unicorn.components import UnicornView from django_unicorn.serializer import dumps, loads from django_unicorn.typer import _construct_model from django_unicorn.views.utils import set_property_from_data from example.coffee.models import Flavor @pytest.mark.django_db def test_model_foreign_key(...
parent.name
assert
complex_expr
tests/test_model_lifecycle.py
test_model_foreign_key
50
null
django-commons/django-unicorn
import time import orjson import shortuuid from django_unicorn.utils import generate_checksum def _post_message_and_get_body(client, message, url="/message/tests.views.fake_components.FakeComponent"): response = client.post( url, message, content_type="application/json", ) body =...
3
assert
numeric_literal
tests/views/message/test_set_property.py
test_setter_resolved
84
null
django-commons/django-unicorn
import json import uuid from datetime import timedelta from decimal import Decimal from types import MappingProxyType from typing import cast import pytest from django.db import models from django.db.models import Model from django.utils.timezone import now from pydantic import BaseModel from django_unicorn import se...
actual
assert
variable
tests/serializer/test_dumps.py
test_int
95
null
django-commons/django-unicorn
import time from uuid import uuid4 import pytest from django.http import JsonResponse from django_unicorn.errors import ComponentClassLoadError, ComponentModuleLoadError from django_unicorn.views import message def assert_json_error(response, error): assert isinstance(response, JsonResponse) assert response....
expected
assert
variable
tests/views/message/test_message.py
test_message_component_with_dot
218
null
django-commons/django-unicorn
import time import shortuuid from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_element from django_unicorn.utils import generate_checksum def test_message_generated_checksum_matches_dom_checksum(client): data = {"clicked": False} messag...
expected_meta
assert
variable
tests/views/message/test_target.py
test_message_generated_checksum_matches_dom_checksum
55
null
django-commons/django-unicorn
from datetime import date, datetime, time, timedelta from types import MappingProxyType from uuid import UUID, uuid4 import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.call_method import _call_method_name from example.coffee.models import Flavor @pytest.mark.djan...
flavor.pk
assert
complex_expr
tests/views/action_parsers/call_method/test_call_method_name.py
test_call_method_name_arg_with_model_type_annotation
115
null
django-commons/django-unicorn
import io import os import uuid import pytest from django.core.management.base import CommandError from django_unicorn.management.commands.startunicorn import Command def test_handle_new_app(settings, tmp_path, monkeypatch, capsys): settings.BASE_DIR = tmp_path # Reply "y" to create new app then "n" to star...
captured.out
assert
complex_expr
tests/management/commands/startunicorn/test_handle.py
test_handle_new_app
46
null
django-commons/django-unicorn
from dataclasses import dataclass import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.utils import set_property_value from example.coffee.models import Flavor @pytest.mark.django_db def test_set_property_value_array(): flavor_one = Flavor(name="initial 1") ...
"test 1"
assert
string_literal
tests/views/test_unicorn_set_property_value.py
test_set_property_value_array
61
null
django-commons/django-unicorn
import time from copy import deepcopy from multiprocessing.dummy import Pool as ThreadPool import orjson import pytest import shortuuid from django_unicorn.components import UnicornView from django_unicorn.utils import generate_checksum def _set_serial( settings, enabled, timeout, cache_backend="djan...
len(messages)
assert
func_call
tests/views/message/test_call_method_multiple.py
test_message_two
114
null
django-commons/django-unicorn
import orjson import pytest from django.template import Context from django.template.base import Parser, Token, TokenType from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_element from django_unicorn.errors import ComponentNotValidError from djan...
content
assert
variable
tests/templatetags/test_unicorn_render.py
test_unicorn_template_renders
102
null
django-commons/django-unicorn
import pytest from django_unicorn.components import UnicornView from django_unicorn.serializer import dumps, loads from django_unicorn.typer import _construct_model from django_unicorn.views.utils import set_property_from_data from example.coffee.models import Flavor @pytest.mark.django_db def test_queryset(): te...
1
assert
numeric_literal
tests/test_model_lifecycle.py
test_queryset
68
null
django-commons/django-unicorn
from django.template.base import Parser, Token, TokenType from django_unicorn.templatetags.unicorn import unicorn def test_unicorn(): token = Token(TokenType.TEXT, "unicorn 'todo'") unicorn_node = unicorn(Parser([]), token) assert unicorn_node.component_name.resolve({}) ==
"todo"
assert
string_literal
tests/templatetags/test_unicorn.py
test_unicorn
10
null
django-commons/django-unicorn
import shortuuid from django.test import Client, RequestFactory from django_unicorn.components import UnicornView from django_unicorn.signals import ( component_completed, component_hydrated, component_method_called, component_method_calling, component_mounted, component_post_parsed, compon...
5
assert
numeric_literal
tests/test_signals.py
test_component_property_updating_and_updated_signals
232
null
django-commons/django-unicorn
import pytest from django_unicorn.call_method_parser import InvalidKwargError, parse_kwarg def test_kwargs_int(): expected = {"test": 2} actual = parse_kwarg("test=2") assert actual == expected assert isinstance(actual["test"], int) assert actual["test"] ==
2
assert
numeric_literal
tests/call_method_parser/test_parse_kwarg.py
test_kwargs_int
21
null
django-commons/django-unicorn
from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import redirect from django.test import RequestFactory from django_unicorn.components.unicorn_view import UnicornView, construct_component def test_render_redirect_template_tag(): component = construct_component(RedirectView, "123", ...
html
assert
variable
tests/components/test_mount_redirect.py
test_render_redirect_template_tag
51
null
django-commons/django-unicorn
import shortuuid from tests.views.fake_components import FakeComponent from tests.views.message.test_calls import FakeCallsComponent from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_ele...
1
assert
numeric_literal
tests/views/message/test_hash.py
test_message_hash_changes
85
null
django-commons/django-unicorn
import time import shortuuid from django_unicorn.components import UnicornView from django_unicorn.components.unicorn_template_response import get_root_element from django_unicorn.utils import generate_checksum def test_message_target_id(client): data = {"clicked": False} message = { "actionQueue": [...
1
assert
numeric_literal
tests/views/message/test_target.py
test_message_target_id
112
null
django-commons/django-unicorn
import json import uuid from datetime import timedelta from decimal import Decimal from types import MappingProxyType from typing import cast import pytest from django.db import models from django.db.models import Model from django.utils.timezone import now from pydantic import BaseModel from django_unicorn import se...
"1.0"
assert
string_literal
tests/serializer/test_dumps.py
test_tuple_of_dicts_mixed_types
870
null
django-commons/django-unicorn
import pytest from django_unicorn.components.unicorn_template_response import ( assert_has_single_wrapper_element, get_root_element, ) from django_unicorn.errors import MultipleRootComponentElementError def test_issue_668_unicorn_view_no_poll(): # Control case html = "<div unicorn:view>Content</div>" ...
"test-component")
assert_*
string_literal
tests/components/test_issue_668_repro.py
test_issue_668_unicorn_view_no_poll
27
null
django-commons/django-unicorn
import datetime from dataclasses import dataclass from typing import get_type_hints as typing_get_type_hints from pydantic import BaseModel from django_unicorn.components import UnicornView from django_unicorn.typer import cast_attribute_value, cast_value, get_type_hints from example.coffee.models import Flavor def ...
test_data
assert
variable
tests/test_typer.py
test_cast_value_dataclass
142
null
django-commons/django-unicorn
import pytest from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView from example.coffee.models import Flavor @pytest.mark.django_db def test_fk_loading(client): # Setup parent_flavor = Flavor.objects.create(name="Parent") child_flavor = Flavor.object...
data
assert
variable
tests/views/test_fk_loading.py
test_fk_loading
48
null
django-commons/django-unicorn
import time from uuid import uuid4 import pytest from django.http import JsonResponse from django_unicorn.errors import ComponentClassLoadError, ComponentModuleLoadError from django_unicorn.views import message def assert_json_error(response, error): assert isinstance(response, JsonResponse) assert response....
"Invalid JSON body")
assert_*
string_literal
tests/views/message/test_message.py
test_message_no_data
43
null
django-commons/django-unicorn
import pytest from django.template.backends.django import Template from django_unicorn.components import UnicornView def test_init_component_name_valid_template_name(): component = UnicornView(component_id="test_init_component_name_valid_template_name", component_name="test") assert component.template_name =...
"unicorn/test.html"
assert
string_literal
tests/views/test_unicorn_view_init.py
test_init_component_name_valid_template_name
35
null
django-commons/django-unicorn
import pytest from django_unicorn.typer import _construct_model from example.books.models import Author, Book from example.coffee.models import Flavor @pytest.mark.django_db def test_construct_model_many_to_many(): author = Author(name="author 1") author.save() book = Book(title="book 1", date_published="...
author.name
assert
complex_expr
tests/views/utils/test_construct_model.py
test_construct_model_many_to_many
82
null
django-commons/django-unicorn
from django_unicorn.typer import get_type_hints def test_get_type_hints_inheritance(): """ Verify that get_type_hints returns type hints from parent classes when called with an instance of a subclass. """ instance = Child() type_hints = get_type_hints(instance) assert "name" in type_hints ...
str
assert
variable
tests/components/test_typer_inheritance.py
test_get_type_hints_inheritance
21
null
django-commons/django-unicorn
import pytest from django_unicorn.serializer import ( InvalidFieldAttributeError, InvalidFieldNameError, _exclude_field_attributes, ) def test_exclude_field_attributes(): expected = {"1": {"2": {}}} dict_data = {"1": {"2": {"3": "4"}}} _exclude_field_attributes(dict_data, ("1.2.3",)) ass...
expected
assert
variable
tests/serializer/test_exclude_field_attributes.py
test_exclude_field_attributes
15
null
django-commons/django-unicorn
from datetime import date, datetime, time, timedelta from types import MappingProxyType from uuid import UUID, uuid4 import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.call_method import _call_method_name from example.coffee.models import Flavor @pytest.mark.djan...
flavor_two.pk
assert
complex_expr
tests/views/action_parsers/call_method/test_call_method_name.py
test_call_method_name_arg_with_model_type_annotation_multiple
126
null
django-commons/django-unicorn
import datetime from dataclasses import dataclass from typing import get_type_hints as typing_get_type_hints from pydantic import BaseModel from django_unicorn.components import UnicornView from django_unicorn.typer import cast_attribute_value, cast_value, get_type_hints from example.coffee.models import Flavor def ...
actual
assert
variable
tests/test_typer.py
test_get_type_hints_gh_639
36
null
django-commons/django-unicorn
import time from typing import Any import orjson import shortuuid from tests.views.message.utils import post_and_get_response from django_unicorn.components import UnicornView, unicorn_view from django_unicorn.utils import generate_checksum def _post_to_component( client, method_name: str, component_name...
""
assert
string_literal
tests/views/message/test_call_method.py
test_gh_628_custom_setter_empty_string
428
null
django-commons/django-unicorn
import pytest from django_unicorn.views.utils import set_property_from_data from example.coffee.models import Flavor @pytest.mark.django_db def test_set_property_non_fk_field(): # Arrange child = Flavor.objects.create(name="Child") # Act set_property_from_data(child, "name", "Updated Name") # As...
"Updated Name"
assert
string_literal
tests/views/test_utils_set_property_fk.py
test_set_property_non_fk_field
83
null
django-commons/django-unicorn
from tests.views.message.utils import post_and_get_response def test_message_sync_input_choices_with_select_widget(client): """ ModelForms with a Model that have a field with `choices` and the form's field uses a Select widget. Need to handle Select widget specifically otherwise `field.widget.format_value`...
2
assert
numeric_literal
tests/views/message/test_sync_input.py
test_message_sync_input_choices_with_select_widget
45
null
django-commons/django-unicorn
from datetime import datetime import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.utils import set_property_value from example.coffee.models import Flavor, Taste def test_set_property_value_model(): component = FakeComponent(component_name="test", component_id...
model
assert
variable
tests/views/action_parsers/utils/test_set_property_value.py
test_set_property_value_model
79
null
django-commons/django-unicorn
import pytest from django_unicorn.call_method_parser import InvalidKwargError, parse_kwarg def test_kwargs_raise_unparseable_value(): with pytest.raises(ValueError) as e: parse_kwarg("test=some_context_variable", raise_if_unparseable=True) assert e.type is
ValueError
assert
variable
tests/call_method_parser/test_parse_kwarg.py
test_kwargs_raise_unparseable_value
72
null
django-commons/django-unicorn
import pytest from django_unicorn.call_method_parser import InvalidKwargError, parse_kwarg def test_kwargs_string(): expected = {"test": "1"} actual = parse_kwarg("test='1'") assert actual ==
expected
assert
variable
tests/call_method_parser/test_parse_kwarg.py
test_kwargs_string
10
null
django-commons/django-unicorn
import sys from datetime import datetime, timezone from typing import List # noqa: UP035 import pytest from django.db.models import Model, QuerySet from django_unicorn.components import UnicornView from django_unicorn.typing import QuerySetType from django_unicorn.views.utils import set_property_from_data from examp...
"test-initial"
assert
string_literal
tests/views/utils/test_set_property_from_data.py
test_set_property_from_data_model
178
null
django-commons/django-unicorn
import time from uuid import uuid4 import pytest from django.http import JsonResponse from django_unicorn.errors import ComponentClassLoadError, ComponentModuleLoadError from django_unicorn.views import message def assert_json_error(response, error): assert isinstance(response, JsonResponse) assert response....
e.exconly()
assert
func_call
tests/views/message/test_message.py
test_message_component_class_with_attribute_error
161
null
django-commons/django-unicorn
import json from unittest.mock import Mock import pytest from django_unicorn.components import Component from django_unicorn.errors import RenderNotModifiedError from django_unicorn.utils import generate_checksum from django_unicorn.views.action import CallMethod, Refresh, SyncInput, Toggle from django_unicorn.views....
3
assert
numeric_literal
tests/views/test_unit_views.py
test_component_request_action_parsing
78
null
django-commons/django-unicorn
import time from uuid import uuid4 import pytest from django.http import JsonResponse from django_unicorn.errors import ComponentClassLoadError, ComponentModuleLoadError from django_unicorn.views import message def assert_json_error(response, error): assert isinstance(response, JsonResponse) assert response....
error
assert
variable
tests/views/message/test_message.py
assert_json_error
14
null
django-commons/django-unicorn
import pytest from django_unicorn.call_method_parser import InvalidKwargError, parse_kwarg def test_kwargs_string(): expected = {"test": "1"} actual = parse_kwarg("test='1'") assert actual == expected assert isinstance(actual["test"], str) assert actual["test"] ==
"1"
assert
string_literal
tests/call_method_parser/test_parse_kwarg.py
test_kwargs_string
12
null
django-commons/django-unicorn
from unittest.mock import MagicMock, patch import pytest from django_unicorn.cacher import ( CacheableComponent, PointerUnicornView, cache_full_tree, restore_from_cache, ) from django_unicorn.components import UnicornView from django_unicorn.errors import UnicornCacheError def test_cacheable_componen...
None
assert
none_literal
tests/test_cacher.py
test_cacheable_component_request_is_none_then_restored
34
null
django-commons/django-unicorn
from django_unicorn.components.unicorn_view import convert_to_dash_case def test_convert_to_dash_case(): expected = "hello-world" actual = convert_to_dash_case("hello_world") assert expected ==
actual
assert
variable
tests/components/test_convert_to_dash_case.py
test_convert_to_dash_case
8
null
django-commons/django-unicorn
import json from unittest.mock import Mock import pytest from django_unicorn.components import Component from django_unicorn.errors import RenderNotModifiedError from django_unicorn.utils import generate_checksum from django_unicorn.views.action import CallMethod, Refresh, SyncInput, Toggle from django_unicorn.views....
"bar"
assert
string_literal
tests/views/test_unit_views.py
test_action_sync_input
18
null
django-commons/django-unicorn
import time from copy import deepcopy from multiprocessing.dummy import Pool as ThreadPool import orjson import pytest import shortuuid from django_unicorn.components import UnicornView from django_unicorn.utils import generate_checksum def _set_serial( settings, enabled, timeout, cache_backend="djan...
4
assert
numeric_literal
tests/views/message/test_call_method_multiple.py
test_message_multiple_with_updated_data
227
null
django-commons/django-unicorn
import json from unittest.mock import Mock import pytest from django_unicorn.components import Component from django_unicorn.errors import RenderNotModifiedError from django_unicorn.utils import generate_checksum from django_unicorn.views.action import CallMethod, Refresh, SyncInput, Toggle from django_unicorn.views....
{"a": 2}
assert
collection
tests/views/test_unit_views.py
test_action_call_method
26
null
django-commons/django-unicorn
import json import uuid from datetime import timedelta from decimal import Decimal from types import MappingProxyType from typing import cast import pytest from django.db import models from django.db.models import Model from django.utils.timezone import now from pydantic import BaseModel from django_unicorn import se...
"3.4"
assert
string_literal
tests/serializer/test_dumps.py
test_tuple_float
852
null
django-commons/django-unicorn
import pytest from django_unicorn.components.unicorn_template_response import ( assert_has_single_wrapper_element, get_root_element, ) from django_unicorn.errors import ( MissingComponentElementError, MissingComponentViewElementError, MultipleRootComponentElementError, NoRootComponentElementErr...
expected
assert
variable
tests/components/test_unicorn_template_response.py
test_get_root_element
20
null
django-commons/django-unicorn
import pytest from django.template.backends.django import Template from django_unicorn.utils import ( create_template, generate_checksum, get_method_arguments, is_non_string_sequence, sanitize_html, ) def test_get_method_arguments(): def test_func(input_str): return input_str expe...
expected
assert
variable
tests/test_utils.py
test_get_method_arguments
58
null
django-commons/django-unicorn
from tests.views.message.utils import post_and_get_response def test_message_nested_sync_input(client): data = {"dictionary": {"name": "test"}} action_queue = [ { "payload": {"name": "dictionary.name", "value": "test1"}, "type": "syncInput", } ] response = post_a...
{"name": "test1"}
assert
collection
tests/views/message/test_sync_input.py
test_message_nested_sync_input
20
null
django-commons/django-unicorn
from datetime import datetime import pytest from django_unicorn.components import UnicornView from django_unicorn.views.action_parsers.utils import set_property_value from example.coffee.models import Flavor, Taste def test_set_property_value_datetime(): component = FakeComponent(component_name="test", component...
dt
assert
variable
tests/views/action_parsers/utils/test_set_property_value.py
test_set_property_value_datetime
60
null
django-commons/django-unicorn
import time from copy import deepcopy from multiprocessing.dummy import Pool as ThreadPool import orjson import pytest import shortuuid from django_unicorn.components import UnicornView from django_unicorn.utils import generate_checksum def _set_serial( settings, enabled, timeout, cache_backend="djan...
True
assert
bool_literal
tests/views/message/test_call_method_multiple.py
test_message_two
122
null
django-commons/django-unicorn
import pytest from django_unicorn.components import UnicornView from django_unicorn.serializer import dumps, loads from django_unicorn.typer import _construct_model from django_unicorn.views.utils import set_property_from_data from example.coffee.models import Flavor @pytest.mark.django_db def test_model(): flavo...
None
assert
none_literal
tests/test_model_lifecycle.py
test_model
31
null
django-commons/django-unicorn
import pytest from django_unicorn.settings import ( get_cache_alias, get_minify_html_enabled, get_morpher_settings, get_script_location, get_serial_enabled, ) def test_get_script_location(settings): assert get_script_location() == "after" settings.UNICORN = {**settings.UNICORN, "SCRIPT_LO...
"append"
assert
string_literal
tests/test_settings.py
test_get_script_location
66
null
django-commons/django-unicorn
import shortuuid from django.test import Client, RequestFactory from django_unicorn.components import UnicornView from django_unicorn.signals import ( component_completed, component_hydrated, component_method_called, component_method_calling, component_mounted, component_post_parsed, compon...
1
assert
numeric_literal
tests/test_signals.py
test_component_mounted_signal
54
null