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 |
|---|---|---|---|---|---|---|---|---|---|
GitGuardian/ggshield | import sys
from unittest.mock import patch
from ggshield.core.plugin.platform import (
PlatformInfo,
format_platform_tag,
get_platform_info,
get_wheel_platform_tags,
)
class TestPlatformInfo:
def test_platform_info_creation(self) -> None:
"""Test creating PlatformInfo."""
info = P... | "linux" | assert | string_literal | tests/unit/core/plugin/test_platform.py | test_platform_info_creation | TestPlatformInfo | 21 | null |
GitGuardian/ggshield | import json
from datetime import datetime, timezone
from typing import Tuple
import jsonschema
import pytest
from pytest_voluptuous import S
from voluptuous import Any, In
from voluptuous.validators import All, Match
from ggshield.__main__ import cli
from ggshield.core.config import Config
from ggshield.core.config.u... | dct | assert | variable | tests/unit/cmd/test_config.py | test_list_json_output | TestConfigList | 101 | null |
GitGuardian/ggshield | import click
from ggshield.core.plugin.base import GGShieldPlugin, PluginMetadata
from ggshield.core.plugin.registry import PluginRegistry
def mock_command() -> None:
"""A mock command for testing."""
pass
class TestPluginRegistry:
def test_register_plugin(self) -> None:
"""Test registering a pl... | plugin | assert | variable | tests/unit/core/plugin/test_registry.py | test_register_plugin | TestPluginRegistry | 49 | null |
GitGuardian/ggshield | import zipfile
from pathlib import Path
from typing import Optional
import pytest
from ggshield.core.plugin.wheel_utils import (
InvalidWheelError,
MetadataNotFoundError,
WheelError,
WheelMetadata,
extract_wheel_metadata,
validate_wheel_file,
)
def create_test_wheel(
tmp_path: Path,
n... | "1.0.0" | assert | string_literal | tests/unit/core/plugin/test_wheel_utils.py | test_dataclass_fields | TestWheelMetadata | 195 | null |
GitGuardian/ggshield | from pathlib import Path
from typing import Any, Dict
import pytest
from ggshield.core.config.utils import (
find_local_config_path,
remove_common_dict_items,
remove_url_trailing_slash,
replace_dash_in_keys,
update_dict_from_other,
)
from ggshield.utils.os import cd
from tests.repository import Re... | 1 | assert | numeric_literal | tests/unit/core/config/test_utils.py | test_update_dict_from_other | 71 | null | |
GitGuardian/ggshield | from pathlib import Path
from unittest.mock import Mock, patch
import pytest
import requests.exceptions
from _pytest.monkeypatch import MonkeyPatch
from pyfakefs.fake_filesystem import FakeFilesystem
import ggshield.core
from ggshield.core.check_updates import (
CACHE_FILE,
check_for_updates,
load_last_ch... | None | assert | none_literal | tests/unit/core/test_check_updates.py | test_check_for_updates_twice_only_notifies_once | 73 | null | |
GitGuardian/ggshield | import sys
from unittest.mock import patch
from ggshield.core.plugin.platform import (
PlatformInfo,
format_platform_tag,
get_platform_info,
get_wheel_platform_tags,
)
class TestGetPlatformInfo:
@patch("platform.machine")
def test_detect_arm64(self, mock_machine: object) -> None:
"""T... | "arm64" | assert | string_literal | tests/unit/core/plugin/test_platform.py | test_detect_arm64 | TestGetPlatformInfo | 72 | null |
GitGuardian/ggshield | import io
import tarfile
import tempfile
from pathlib import Path
from typing import Dict, List, Optional
from unittest.mock import Mock, patch
import click
import pytest
from ggshield.__main__ import cli
from ggshield.core import ui
from ggshield.core.errors import ExitCode
from ggshield.core.git_hooks.ci.commit_ran... | result) | assert_* | variable | tests/unit/cmd/scan/test_ci.py | test_ci_cmd_uses_right_mode_header | 158 | null | |
GitGuardian/ggshield | from pathlib import Path
from click.testing import CliRunner
from ggshield.__main__ import cli
from tests.unit.conftest import assert_invoke_exited_with, assert_invoke_ok, my_vcr
@my_vcr.use_cassette
def test_hmsl_query_prefix(cli_fs_runner: CliRunner, tmp_path: Path) -> None:
"""
GIVEN a common prefix
W... | result) | assert_* | variable | tests/unit/cmd/hmsl/test_query.py | test_hmsl_query_prefix | 23 | null | |
GitGuardian/ggshield | import os
import tempfile
from unittest.mock import Mock, patch
from pygitguardian.models import Match, PolicyBreak
from ggshield.__main__ import cli
from ggshield.cmd.secret.ignore import ignore_last_found
from ggshield.core.cache import Cache
from ggshield.core.config import Config
from ggshield.core.errors import ... | ignore.name | assert | complex_expr | tests/unit/cmd/test_ignore.py | test_cache_catches_last_found_secrets | 124 | null | |
GitGuardian/ggshield | import sys
from unittest.mock import patch
from ggshield.core.plugin.platform import (
PlatformInfo,
format_platform_tag,
get_platform_info,
get_wheel_platform_tags,
)
class TestGetWheelPlatformTags:
@patch("ggshield.core.plugin.platform.get_platform_info")
def test_returns_list_of_tags(self,... | tags | assert | variable | tests/unit/core/plugin/test_platform.py | test_returns_list_of_tags | TestGetWheelPlatformTags | 134 | null |
GitGuardian/ggshield | import zipfile
from pathlib import Path
from typing import Optional
import pytest
from ggshield.core.plugin.wheel_utils import (
InvalidWheelError,
MetadataNotFoundError,
WheelError,
WheelMetadata,
extract_wheel_metadata,
validate_wheel_file,
)
def create_test_wheel(
tmp_path: Path,
n... | "MIT" | assert | string_literal | tests/unit/core/plugin/test_wheel_utils.py | test_extract_valid_wheel | TestExtractWheelMetadata | 64 | null |
GitGuardian/ggshield | import json
from unittest import mock
import jsonschema
import pytest
from pygitguardian.models import HealthCheckResponse
from pytest_voluptuous import S
from voluptuous.validators import All, In, Match
from ggshield.__main__ import cli
from ggshield.core.config.config import ConfigSource
from ggshield.utils.os impo... | dct | assert | variable | tests/unit/cmd/test_status.py | test_api_status | 39 | null | |
GitGuardian/ggshield | import os
import sys
from copy import deepcopy
from enum import IntEnum
from pathlib import Path
from typing import Optional
import pytest
from click import UsageError
from ggshield.core.config import AccountConfig, Config, InstanceConfig
from ggshield.core.config.utils import get_auth_config_filepath, load_yaml_dict... | [] | assert | collection | tests/unit/core/config/test_config.py | test_user_config_url_no_configured_instance | TestConfig | 221 | null |
GitGuardian/ggshield | from pathlib import Path
from unittest.mock import ANY, Mock, patch
import pytest
from click.testing import CliRunner
from ggshield.__main__ import cli
from ggshield.cmd.secret.scan.secret_scan_common_options import (
IGNORED_DEFAULT_WILDCARDS,
)
from ggshield.core.errors import ExitCode
from ggshield.core.filter... | result.output | assert | complex_expr | tests/unit/cmd/scan/test_prepush.py | test_prepush_no_commits | TestPrepush | 46 | null |
GitGuardian/ggshield | import os
import tempfile
from unittest.mock import Mock, patch
from pygitguardian.models import Match, PolicyBreak
from ggshield.__main__ import cli
from ggshield.cmd.secret.ignore import ignore_last_found
from ggshield.core.cache import Cache
from ggshield.core.config import Config
from ggshield.core.errors import ... | [ignored_match] | assert | collection | tests/unit/cmd/test_ignore.py | test_ignore_sha | 57 | null | |
GitGuardian/ggshield | import json
from unittest import mock
import jsonschema
import pytest
from pygitguardian.models import HealthCheckResponse
from pytest_voluptuous import S
from voluptuous.validators import All, In, Match
from ggshield.__main__ import cli
from ggshield.core.config.config import ConfigSource
from ggshield.utils.os impo... | verify | assert | variable | tests/unit/cmd/test_status.py | test_ssl_verify | 135 | null | |
GitGuardian/ggshield | import json
import os
from unittest.mock import patch
import jsonschema
import pytest
from tests.conftest import GG_VALID_TOKEN
from tests.functional.utils import recreate_censored_content, run_ggshield_scan
from tests.repository import Repository
LEAK_CONTENT = f"password = {GG_VALID_TOKEN}"
def leaky_repo(tmp_pat... | result.stdout | assert | complex_expr | tests/functional/secret/test_scan_repo.py | test_scan_repo_exclude_patterns | 103 | null | |
GitGuardian/ggshield | import json
from datetime import datetime, timezone
from typing import Tuple
import jsonschema
import pytest
from pytest_voluptuous import S
from voluptuous import Any, In
from voluptuous.validators import All, Match
from ggshield.__main__ import cli
from ggshield.core.config import Config
from ggshield.core.config.u... | None | assert | none_literal | tests/unit/cmd/test_config.py | test_set_instance | TestConfigSet | 261 | null |
GitGuardian/ggshield | from datetime import datetime, timezone
from typing import Optional
import pytest
from ggshield.core.config import Config
from ggshield.core.config.user_config import CURRENT_CONFIG_VERSION, UserConfig
from ggshield.core.errors import ParseError, UnexpectedError
from ggshield.core.types import IgnoredMatch
from tests... | {"d1", "d2"} | assert | collection | tests/unit/core/config/test_user_config.py | test_load_v1 | TestUserConfig | 132 | null |
GitGuardian/ggshield | from pathlib import Path
from unittest import mock
from ggshield.__main__ import cli
from ggshield.cmd.plugin.install import detect_source_type
from ggshield.core.errors import ExitCode
from ggshield.core.plugin.client import (
PluginCatalog,
PluginDownloadInfo,
PluginInfo,
PluginSourceType,
)
class T... | result.output | assert | complex_expr | tests/unit/cmd/plugin/test_install.py | test_install_requires_plugin_source | TestPluginInstall | 31 | null |
GitGuardian/ggshield | from pygitguardian.models import Match
from ggshield.core.config.user_config import SecretConfig
from ggshield.verticals.secret import Results, SecretScanCollection
from ggshield.verticals.secret.output.secret_gitlab_webui_output_handler import (
SecretGitLabWebUIOutputHandler,
format_secret,
)
from tests.fact... | out | assert | variable | tests/unit/verticals/secret/output/test_gitlab_webui_output.py | test_format_secret | 21 | null | |
GitGuardian/ggshield | from pathlib import Path
import pytest
from click.testing import CliRunner
from ggshield.__main__ import cli
from ggshield.verticals.hmsl.crypto import hash_string
from tests.unit.conftest import assert_invoke_exited_with, assert_invoke_ok
RESULTS_CONTENT = (
'{"hint": "f7f17c88638b42465b6c620a0c7648ef470e611c1f... | 1 | assert | numeric_literal | tests/unit/cmd/hmsl/test_decrypt.py | test_hmsl_decrypt_default_behavior | 117 | null | |
GitGuardian/ggshield | from copy import deepcopy
from pathlib import Path
from typing import List
from unittest.mock import MagicMock, patch
import pytest
from ggshield.core.config.user_config import SecretConfig
from ggshield.core.scan import Commit
from ggshield.core.scan.commit_information import CommitInformation
from ggshield.core.sca... | len(expected_batch) | assert | func_call | tests/unit/verticals/secret/test_scan_repo.py | test_get_commits_content_by_batch | 81 | null | |
GitGuardian/ggshield | from pygitguardian.models import Match
from ggshield.core.config.user_config import SecretConfig
from ggshield.verticals.secret import Results, SecretScanCollection
from ggshield.verticals.secret.output.secret_gitlab_webui_output_handler import (
SecretGitLabWebUIOutputHandler,
format_secret,
)
from tests.fact... | "" | assert | string_literal | tests/unit/verticals/secret/output/test_gitlab_webui_output.py | test_gitlab_web_ui_output_no_secrets | 55 | null | |
GitGuardian/ggshield | import os
import re
from copy import deepcopy
from datetime import datetime, timezone
import pytest
from ggshield.core.config import Config
from ggshield.core.config.auth_config import (
InstanceConfig,
prepare_auth_config_dict_for_save,
)
from ggshield.core.config.utils import get_auth_config_filepath
from g... | [] | assert | collection | tests/unit/core/config/test_auth_config.py | test_load_file_not_existing | TestAuthConfig | 120 | null |
GitGuardian/ggshield | from typing import List
import pytest
from ggshield.core.lines import Line, get_lines_from_patch, get_offset, get_padding
from ggshield.utils.git_shell import Filemode
def test_get_lines_set_indices_for_line_on_hunk_header():
"""
GIVEN a patch with content on the same line as the patch header
WHEN parsed... | 2 | assert | numeric_literal | tests/unit/core/test_lines.py | test_get_lines_set_indices_for_line_on_hunk_header | 125 | null | |
GitGuardian/ggshield | from pathlib import Path
from typing import Optional
from zipfile import ZipFile
import pytest
from ggshield.utils.archive import (
UnsafeArchive,
_zip_get_symlink_target,
check_archive_content,
safe_unpack,
)
from tests.unit.conftest import DATA_PATH
ARCHIVES_PATH = DATA_PATH / "archives"
BAD_ZIP_PA... | message | assert | variable | tests/unit/utils/test_archive.py | test_check_archive_content_raises_exception | 61 | null | |
GitGuardian/ggshield | import json
from unittest import mock
import jsonschema
import pytest
from pygitguardian.models import HealthCheckResponse
from pytest_voluptuous import S
from voluptuous.validators import All, In, Match
from ggshield.__main__ import cli
from ggshield.core.config.config import ConfigSource
from ggshield.utils.os impo... | result) | assert_* | variable | tests/unit/cmd/test_status.py | test_quota | 21 | null | |
GitGuardian/ggshield | from typing import List
import pytest
from pygitguardian.models import ScanResult
from ggshield.core.lines import get_lines_from_content
from ggshield.core.match_span import MatchSpan
from ggshield.utils.git_shell import Filemode
from tests.unit.conftest import (
_MULTI_SECRET_ONE_LINE_PATCH,
_MULTI_SECRET_ON... | len(matches) | assert | func_call | tests/unit/core/test_match_span.py | test_from_match | 93 | null | |
GitGuardian/ggshield | import json
import os
from unittest.mock import patch
import jsonschema
import pytest
from tests.conftest import GG_VALID_TOKEN
from tests.functional.utils import recreate_censored_content, run_ggshield_scan
from tests.repository import Repository
LEAK_CONTENT = f"password = {GG_VALID_TOKEN}"
def leaky_repo(tmp_pat... | proc.stderr | assert | complex_expr | tests/functional/secret/test_scan_repo.py | test_scan_repo_quota_limit_reached | 78 | null | |
graphql-python/graphene-django | from collections import namedtuple
import pytest
from django.db import models
from django.utils.translation import gettext_lazy as _
from pytest import raises
import graphene
from graphene import NonNull
from graphene.relay import ConnectionField, Node
from graphene.types.datetime import Date, DateTime, Time
from gra... | graphene.ID) | assert_* | complex_expr | graphene_django/tests/test_converter.py | test_should_auto_convert_id | 109 | null | |
graphql-python/graphene-django | import datetime
import re
import pytest
from django.db.models import Count, Prefetch
from graphene import List, NonNull, ObjectType, Schema, String
from ..fields import DjangoListField
from ..types import DjangoObjectType
from .models import (
Article as ArticleModel,
Film as FilmModel,
FilmDetails as Fi... | { "articles": [ { "headline": "Amazing news", "editor": {"firstName": "Debra"}, "reporter": { "firstName": "Tara", "films": [ {"genre": "AC", "details": {"location": "Hollywood"}}, {"genre": "OT", "details": None}, ], }, }, { "headline": "Not so good news", "editor": {"firstName": "Tara"}, "reporter": { "firstName": "D... | assert | collection | graphene_django/tests/test_fields.py | test_select_related_and_prefetch_related_are_respected | TestDjangoListField | 678 | null |
graphql-python/graphene-django | from django import forms
from pytest import raises
import graphene
from graphene_django import DjangoObjectType
from ...tests.models import CHOICES, Film, Reporter
from ..types import DjangoFormInputObjectType
THIS = CHOICES[0][0]
THIS_ON_CLIENT_CONVERTED = "A_1"
DOCUMENTARY = "do"
DOCUMENTARY_ON_CLIENT_CONVERTED =... | graphene.String | assert | complex_expr | graphene_django/forms/tests/test_djangoinputobject.py | test_type_custom_id_field_type | 90 | null | |
graphql-python/graphene-django | import json
from http import HTTPStatus
from unittest.mock import patch
import pytest
from django.db import connection
from .models import Pet
def url_string(string="/graphql", **url_params):
if url_params:
string += "?" + urlencode(url_params)
return string
def batch_url_string(**url_params):
... | [] | assert | collection | graphene_django/tests/test_views.py | test_form_mutation_multiple_creation_invalid_atomic_request | 602 | null | |
graphql-python/graphene-django | import copy
from django.db import models
from pytest import raises
from rest_framework import serializers
import graphene
from ..serializer_converter import convert_serializer_field
from ..types import DictType
def _get_type(
rest_framework_field, is_input=True, convert_choices_to_enum=True, **kwargs
):
# p... | "h" | assert | string_literal | graphene_django/rest_framework/tests/test_field_converter.py | test_should_choice_convert_enum | 74 | null | |
graphql-python/graphene-django | import datetime
from pytest import raises
from rest_framework import serializers
from graphene import Field, ResolveInfo, String
from graphene.types.inputobjecttype import InputObjectType
from ...types import DjangoObjectType
from ..models import (
MyFakeModel,
MyFakeModelWithChoiceField,
MyFakeModelWith... | "New Narf" | assert | string_literal | graphene_django/rest_framework/tests/test_mutation.py | test_model_update_mutate_and_get_payload_success | 244 | null | |
graphql-python/graphene-django | import copy
from django.db import models
from pytest import raises
from rest_framework import serializers
import graphene
from ..serializer_converter import convert_serializer_field
from ..types import DictType
def _get_type(
rest_framework_field, is_input=True, convert_choices_to_enum=True, **kwargs
):
# p... | "World" | assert | string_literal | graphene_django/rest_framework/tests/test_field_converter.py | test_should_choice_convert_enum | 77 | null | |
graphql-python/graphene-django | import json
from http import HTTPStatus
from unittest.mock import patch
import pytest
from django.db import connection
from .models import Pet
def url_string(string="/graphql", **url_params):
if url_params:
string += "?" + urlencode(url_params)
return string
def batch_url_string(**url_params):
... | True) | assert_* | bool_literal | graphene_django/tests/test_views.py | test_query_errors_atomic_request | 820 | null | |
graphql-python/graphene-django | from django import forms
from django.core.exceptions import ValidationError
from pytest import raises
from graphene import Field, ObjectType, Schema, String
from graphene_django import DjangoObjectType
from graphene_django.tests.forms import PetForm
from graphene_django.tests.models import Pet
from graphene_django.tes... | None | assert | none_literal | graphene_django/forms/tests/test_mutation.py | test_form_invalid_form | 101 | null | |
graphql-python/graphene-django | import base64
import datetime
from unittest.mock import ANY, Mock
import pytest
from django.db import models
from django.db.models import Q
from django.utils.functional import SimpleLazyObject
from graphql_relay import to_global_id
from pytest import raises
import graphene
from graphene.relay import Node
from ..comp... | 2 | assert | numeric_literal | graphene_django/tests/test_query.py | test_should_have_next_page | 1,537 | null | |
graphql-python/graphene-django | from pytest import raises
from ..registry import Registry
from ..types import DjangoObjectType
from .models import Reporter
def test_should_map_fields_correctly():
class ReporterType2(DjangoObjectType):
class Meta:
model = Reporter
registry = Registry()
fields = "__all_... | [ "id", "first_name", "last_name", "email", "pets", "a_choice", "typed_choice", "class_choice", "callable_choice", "fans", "reporter_type", ] | assert | collection | graphene_django/tests/test_schema.py | test_should_map_fields_correctly | 36 | null | |
graphql-python/graphene-django | import pytest
from ...compat import ArrayField, MissingType
@pytest.mark.skipif(ArrayField is MissingType, reason="ArrayField should exist")
def test_array_field_exact_match(schema):
"""
Test exact filter on a array field of string.
"""
query = """
query {
events (tags: ["movie", "music"]... | [ {"node": {"name": "Musical"}}, ] | assert | collection | graphene_django/filter/tests/test_array_field_exact_filter.py | test_array_field_exact_match | 47 | null | |
graphql-python/graphene-django | import json
from http import HTTPStatus
from unittest.mock import patch
import pytest
from django.db import connection
from .models import Pet
def url_string(string="/graphql", **url_params):
if url_params:
string += "?" + urlencode(url_params)
return string
def batch_url_string(**url_params):
... | "Enzo" | assert | string_literal | graphene_django/tests/test_views.py | test_form_mutation_multiple_creation_invalid_non_atomic | 715 | null | |
graphql-python/graphene-django | from datetime import datetime
from textwrap import dedent
import pytest
from django.db.models import TextField, Value
from django.db.models.functions import Concat
from graphene import Argument, Boolean, Decimal, Field, ObjectType, Schema, String
from graphene.relay import Node
from graphene_django import DjangoObjec... | "a2" | assert | string_literal | graphene_django/filter/tests/test_fields.py | test_filter_shortcut_filterset_context | 188 | null | |
graphql-python/graphene-django | from django import forms
from pytest import raises
import graphene
from graphene_django import DjangoObjectType
from ...tests.models import CHOICES, Film, Reporter
from ..types import DjangoFormInputObjectType
THIS = CHOICES[0][0]
THIS_ON_CLIENT_CONVERTED = "A_1"
DOCUMENTARY = "do"
DOCUMENTARY_ON_CLIENT_CONVERTED =... | None | assert | none_literal | graphene_django/forms/tests/test_djangoinputobject.py | test_mutation_with_form_djangoforminputtype | 132 | null | |
graphql-python/graphene-django | import base64
import datetime
from unittest.mock import ANY, Mock
import pytest
from django.db import models
from django.db.models import Q
from django.utils.functional import SimpleLazyObject
from graphql_relay import to_global_id
from pytest import raises
import graphene
from graphene.relay import Node
from ..comp... | ANY) | assert_* | variable | graphene_django/tests/test_query.py | test_connection_should_call_resolver_function | 2,038 | null | |
graphql-python/graphene-django | import pytest
from ..data import initialize
from ..schema import schema
pytestmark = pytest.mark.django_db
def test_correctly_fetches_id_name_rebels():
initialize()
query = """
query RebelsQuery {
rebels {
id
name
}
}
"""
expected = {
"rebels": ... | expected | assert | variable | examples/starwars/tests/test_objectidentification.py | test_correctly_fetches_id_name_rebels | 24 | null | |
graphql-python/graphene-django | import pytest
from ...compat import ArrayField, MissingType
@pytest.mark.skipif(ArrayField is MissingType, reason="ArrayField should exist")
def test_array_field_len_filter(schema):
query = """
query {
events (tags_Len: 2) {
edges {
node {
name
... | 'Int cannot represent non-integer value: "2"' | assert | string_literal | graphene_django/filter/tests/test_array_field_custom_filter.py | test_array_field_len_filter | 71 | null | |
graphql-python/graphene-django | import operator
from functools import reduce
import pytest
from django.db.models import Q
from django_filters import FilterSet
import graphene
from graphene.relay import Node
from graphene_django import DjangoObjectType
from graphene_django.tests.models import Article, Reporter
from graphene_django.utils import DJANG... | all_articles_filters | assert | variable | graphene_django/filter/tests/test_typed_filter.py | test_typed_filter_schema | 115 | null | |
graphql-python/graphene-django | from collections import namedtuple
import pytest
from django.db import models
from django.utils.translation import gettext_lazy as _
from pytest import raises
import graphene
from graphene import NonNull
from graphene.relay import ConnectionField, Node
from graphene.types.datetime import Date, DateTime, Time
from gra... | DateTime) | assert_* | variable | graphene_django/tests/test_converter.py | test_should_date_time_convert_string | 61 | null | |
graphql-python/graphene-django | import copy
from django.db import models
from pytest import raises
from rest_framework import serializers
import graphene
from ..serializer_converter import convert_serializer_field
from ..types import DictType
def _get_type(
rest_framework_field, is_input=True, convert_choices_to_enum=True, **kwargs
):
# p... | graphene.String) | assert_* | complex_expr | graphene_django/rest_framework/tests/test_field_converter.py | test_should_char_convert_string | 52 | null | |
graphql-python/graphene-django | import copy
from django.db import models
from pytest import raises
from rest_framework import serializers
import graphene
from ..serializer_converter import convert_serializer_field
from ..types import DictType
def _get_type(
rest_framework_field, is_input=True, convert_choices_to_enum=True, **kwargs
):
# p... | None | assert | none_literal | graphene_django/rest_framework/tests/test_field_converter.py | test_should_list_serializer_convert_to_list | 183 | null | |
graphql-python/graphene-django | from django import VERSION as DJANGO_VERSION, forms
from pytest import raises
from graphene import (
ID,
UUID,
Boolean,
Date,
DateTime,
Decimal,
Float,
Int,
List,
NonNull,
String,
Time,
)
from ..converter import convert_form_field
def assert_conversion(django_field, gr... | ID | assert | variable | graphene_django/forms/tests/test_converter.py | test_should_model_multiple_choice_convert_connectionorlist | 123 | null | |
graphql-python/graphene-django | from django import forms
from django.core.exceptions import ValidationError
from pytest import raises
from graphene import Field, ObjectType, Schema, String
from graphene_django import DjangoObjectType
from graphene_django.tests.forms import PetForm
from graphene_django.tests.models import Pet
from graphene_django.tes... | 0 | assert | numeric_literal | graphene_django/forms/tests/test_mutation.py | test_model_form_mutation_invalid_input | 275 | null | |
graphql-python/graphene-django | import datetime
import re
import pytest
from django.db.models import Count, Prefetch
from graphene import List, NonNull, ObjectType, Schema, String
from ..fields import DjangoListField
from ..types import DjangoObjectType
from .models import (
Article as ArticleModel,
Film as FilmModel,
FilmDetails as Fi... | Reporter | assert | variable | graphene_django/tests/test_fields.py | test_non_null_type | TestDjangoListField | 49 | null |
graphql-python/graphene-django | from django import VERSION as DJANGO_VERSION, forms
from pytest import raises
from graphene import (
ID,
UUID,
Boolean,
Date,
DateTime,
Decimal,
Float,
Int,
List,
NonNull,
String,
Time,
)
from ..converter import convert_form_field
def assert_conversion(django_field, gr... | Time) | assert_* | variable | graphene_django/forms/tests/test_converter.py | test_should_time_convert_time | 46 | null | |
graphql-python/graphene-django | import pytest
import graphene
from graphene.relay import Node
from graphene_django import DjangoConnectionField, DjangoObjectType
from ...tests.models import Reporter
from ..middleware import DjangoDebugMiddleware
from ..types import DjangoDebug
def test_should_query_stack_trace():
class ReporterType(DjangoObjec... | debug_exception["stack"] | assert | complex_expr | graphene_django/debug/tests/test_query.py | test_should_query_stack_trace | 313 | null | |
graphql-python/graphene-django | import datetime
from pytest import raises
from rest_framework import serializers
from graphene import Field, ResolveInfo, String
from graphene.types.inputobjecttype import InputObjectType
from ...types import DjangoObjectType
from ..models import (
MyFakeModel,
MyFakeModelWithChoiceField,
MyFakeModelWith... | "coolName" | assert | string_literal | graphene_django/rest_framework/tests/test_mutation.py | test_mutation_error_camelcased | 338 | null | |
graphql-python/graphene-django | from django import forms
from pytest import raises
import graphene
from graphene_django import DjangoObjectType
from ...tests.models import CHOICES, Film, Reporter
from ..types import DjangoFormInputObjectType
THIS = CHOICES[0][0]
THIS_ON_CLIENT_CONVERTED = "A_1"
DOCUMENTARY = "do"
DOCUMENTARY_ON_CLIENT_CONVERTED =... | THIS_ON_CLIENT_CONVERTED | assert | variable | graphene_django/forms/tests/test_djangoinputobject.py | test_enum_not_converted | 240 | null | |
graphql-python/graphene-django | import base64
import datetime
from unittest.mock import ANY, Mock
import pytest
from django.db import models
from django.db.models import Q
from django.utils.functional import SimpleLazyObject
from graphql_relay import to_global_id
from pytest import raises
import graphene
from graphene.relay import Node
from ..comp... | 1 | assert | numeric_literal | graphene_django/tests/test_query.py | test_should_enforce_first_or_last | 664 | null | |
graphql-python/graphene-django | from datetime import datetime
import pytest
from django_filters import (
FilterSet,
rest_framework as filters,
)
from graphene import ObjectType, Schema
from graphene.relay import Node
from graphene_django import DjangoObjectType
from graphene_django.filter.tests.filters import ArticleFilter
from graphene_dja... | [ {"node": {"email": "john@doe.com"}}, {"node": {"email": "jean@bon.com"}}, {"node": {"email": "jane@doe.com"}}, ] | assert | collection | graphene_django/filter/tests/test_in_filter.py | test_enum_in_filter | 443 | null | |
graphql-python/graphene-django | from collections import namedtuple
import pytest
from django.db import models
from django.utils.translation import gettext_lazy as _
from pytest import raises
import graphene
from graphene import NonNull
from graphene.relay import ConnectionField, Node
from graphene.types.datetime import Date, DateTime, Time
from gra... | A | assert | variable | graphene_django/tests/test_converter.py | test_should_manytomany_convert_connectionorlist_list | 297 | null | |
graphql-python/graphene-django | import warnings
from collections import OrderedDict, defaultdict
from textwrap import dedent
from unittest.mock import patch
import pytest
from django.db import models
from graphene import Connection, Field, Interface, ObjectType, Schema, String
from graphene.relay import Node
from .. import registry
from ..filter i... | [] | assert | collection | graphene_django/tests/test_types.py | test_django_objecttype_fields_empty | 336 | null | |
graphql-python/graphene-django | import json
import pytest
from graphene import ObjectType, Schema
from graphene.relay import Node
from graphene_django import DjangoObjectType
from graphene_django.tests.models import Pet
from graphene_django.utils import DJANGO_FILTER_INSTALLED
pytestmark = []
def test_int_range_filter():
"""
Test range fi... | [ {"node": {"name": "Mimi"}}, {"node": {"name": "Picotin"}}, ] | assert | collection | graphene_django/filter/tests/test_range_filter.py | test_int_range_filter | 62 | null | |
graphql-python/graphene-django | import json
from unittest.mock import patch
import pytest
from django.utils.translation import gettext_lazy
from ..utils import GraphQLTestCase, camelize, get_model_fields, get_reverse_fields
from ..utils.testing import graphql_query
from .models import APNewsReporter, CNNReporter, Film, Reporter
def test_camelize()... | {"valueA": "value_b"} | assert | collection | graphene_django/tests/test_utils.py | test_camelize | 37 | null | |
graphql-python/graphene-django | import pytest
import graphene
from graphene.relay import Node
from graphene_django import DjangoConnectionField, DjangoObjectType
from ...tests.models import Reporter
from ..middleware import DjangoDebugMiddleware
from ..types import DjangoDebug
def test_should_query_stack_trace():
class ReporterType(DjangoObjec... | 1 | assert | numeric_literal | graphene_django/debug/tests/test_query.py | test_should_query_stack_trace | 312 | null | |
graphql-python/graphene-django | from pytest import raises
from ..registry import Registry
from ..types import DjangoObjectType
from .models import Reporter
def test_should_raise_if_no_model():
with raises(Exception) as excinfo:
class Character1(DjangoObjectType):
fields = "__all__"
assert "valid Django Model" in | str(excinfo.value) | assert | func_call | graphene_django/tests/test_schema.py | test_should_raise_if_no_model | 14 | null | |
graphql-python/graphene-django | import json
from unittest.mock import patch
import pytest
from django.utils.translation import gettext_lazy
from ..utils import GraphQLTestCase, camelize, get_model_fields, get_reverse_fields
from ..utils.testing import graphql_query
from .models import APNewsReporter, CNNReporter, Film, Reporter
def test_get_model_... | len(reporter_name_set) | assert | func_call | graphene_django/tests/test_utils.py | test_get_model_fields_no_duplication | 15 | null | |
graphql-python/graphene-django | import warnings
from collections import OrderedDict, defaultdict
from textwrap import dedent
from unittest.mock import patch
import pytest
from django.db import models
from graphene import Connection, Field, Interface, ObjectType, Schema, String
from graphene.relay import Node
from .. import registry
from ..filter i... | Exception) | pytest.raises | variable | graphene_django/tests/test_types.py | test_django_objecttype_only_fields_and_fields | 341 | null | |
graphql-python/graphene-django | from datetime import datetime
from textwrap import dedent
import pytest
from django.db.models import TextField, Value
from django.db.models.functions import Concat
from graphene import Argument, Boolean, Decimal, Field, ObjectType, Schema, String
from graphene.relay import Node
from graphene_django import DjangoObjec... | field) | assert_* | variable | graphene_django/filter/tests/test_fields.py | test_filter_explicit_filterset_orderable | 111 | null | |
graphql-python/graphene-django | import datetime
import re
import pytest
from django.db.models import Count, Prefetch
from graphene import List, NonNull, ObjectType, Schema, String
from ..fields import DjangoListField
from ..types import DjangoObjectType
from .models import (
Article as ArticleModel,
Film as FilmModel,
FilmDetails as Fi... | {"reporters": [{"firstName": "Tara"}]} | assert | collection | graphene_django/tests/test_fields.py | test_override_resolver | TestDjangoListField | 150 | null |
graphql-python/graphene-django | import warnings
from collections import OrderedDict, defaultdict
from textwrap import dedent
from unittest.mock import patch
import pytest
from django.db import models
from graphene import Connection, Field, Interface, ObjectType, Schema, String
from graphene.relay import Node
from .. import registry
from ..filter i... | expected | assert | variable | graphene_django/tests/test_types.py | test_schema_representation | 286 | null | |
graphql-python/graphene-django | import warnings
from collections import OrderedDict, defaultdict
from textwrap import dedent
from unittest.mock import patch
import pytest
from django.db import models
from graphene import Connection, Field, Interface, ObjectType, Schema, String
from graphene.relay import Node
from .. import registry
from ..filter i... | TypeError) | pytest.raises | variable | graphene_django/tests/test_types.py | test_django_objecttype_fields_exclude_type_checking | 409 | null | |
graphql-python/graphene-django | import json
from http import HTTPStatus
from unittest.mock import patch
import pytest
from django.db import connection
from .models import Pet
def url_string(string="/graphql", **url_params):
if url_params:
string += "?" + urlencode(url_params)
return string
def batch_url_string(**url_params):
... | content | assert | variable | graphene_django/tests/test_views.py | test_form_mutation_multiple_creation_invalid_atomic_request | 596 | null | |
graphql-python/graphene-django | from django import forms
from pytest import raises
import graphene
from graphene_django import DjangoObjectType
from ...tests.models import CHOICES, Film, Reporter
from ..types import DjangoFormInputObjectType
THIS = CHOICES[0][0]
THIS_ON_CLIENT_CONVERTED = "A_1"
DOCUMENTARY = "do"
DOCUMENTARY_ON_CLIENT_CONVERTED =... | THIS | assert | variable | graphene_django/forms/tests/test_djangoinputobject.py | test_enum_is_converted_to_original | 254 | null | |
graphql-python/graphene-django | import json
from unittest.mock import patch
import pytest
from django.utils.translation import gettext_lazy
from ..utils import GraphQLTestCase, camelize, get_model_fields, get_reverse_fields
from ..utils.testing import graphql_query
from .models import APNewsReporter, CNNReporter, Film, Reporter
def test_camelize()... | "value_a" | assert | string_literal | graphene_django/tests/test_utils.py | test_camelize | 36 | null | |
graphql-python/graphene-django | import warnings
from collections import OrderedDict, defaultdict
from textwrap import dedent
from unittest.mock import patch
import pytest
from django.db import models
from graphene import Connection, Field, Interface, ObjectType, Schema, String
from graphene.relay import Node
from .. import registry
from ..filter i... | len(ReporterModel._meta.get_fields()) | assert | func_call | graphene_django/tests/test_types.py | test_django_objecttype_all_fields | 358 | null | |
graphql-python/graphene-django | import base64
import datetime
from unittest.mock import ANY, Mock
import pytest
from django.db import models
from django.db.models import Q
from django.utils.functional import SimpleLazyObject
from graphql_relay import to_global_id
from pytest import raises
import graphene
from graphene.relay import Node
from ..comp... | 4 | assert | numeric_literal | graphene_django/tests/test_query.py | test_should_return_max_limit | 1,494 | null | |
graphql-python/graphene-django | import datetime
from pytest import raises
from rest_framework import serializers
from graphene import Field, ResolveInfo, String
from graphene.types.inputobjecttype import InputObjectType
from ...types import DjangoObjectType
from ..models import (
MyFakeModel,
MyFakeModelWithChoiceField,
MyFakeModelWith... | str(exc.value) | assert | func_call | graphene_django/rest_framework/tests/test_mutation.py | test_model_invalid_update_mutate_and_get_payload_success | 267 | null | |
graphql-python/graphene-django | import pytest
import graphene
from graphene.relay import Node
from graphene_django import DjangoConnectionField, DjangoObjectType
from ...tests.models import Reporter
from ..middleware import DjangoDebugMiddleware
from ..types import DjangoDebug
@pytest.mark.parametrize("max_limit", [None, 100])
def test_should_quer... | 2 | assert | numeric_literal | graphene_django/debug/tests/test_query.py | test_should_query_connection | 218 | null | |
graphql-python/graphene-django | from django import VERSION as DJANGO_VERSION, forms
from pytest import raises
from graphene import (
ID,
UUID,
Boolean,
Date,
DateTime,
Decimal,
Float,
Int,
List,
NonNull,
String,
Time,
)
from ..converter import convert_form_field
def assert_conversion(django_field, gr... | Decimal) | assert_* | variable | graphene_django/forms/tests/test_converter.py | test_should_decimal_convert_decimal | 109 | null | |
graphql-python/graphene-django | import pytest
from ...compat import ArrayField, MissingType
@pytest.mark.skipif(ArrayField is MissingType, reason="ArrayField should exist")
def test_array_field_len_filter(schema):
query = """
query {
events (tags_Len: 2) {
edges {
node {
name
... | [] | assert | collection | graphene_django/filter/tests/test_array_field_custom_filter.py | test_array_field_len_filter | 56 | null | |
graphql-python/graphene-django | from io import StringIO
from textwrap import dedent
from unittest.mock import mock_open, patch
from django.core import management
from graphene import ObjectType, Schema, String
def test_generate_graphql_file_on_call_graphql_schema():
class Query(ObjectType):
hi = String()
mock_schema = Schema(query... | dedent( """\ type Query { hi: String }""" ) | assert | func_call | graphene_django/tests/test_command.py | test_generate_graphql_file_on_call_graphql_schema | 52 | null | |
graphql-python/graphene-django | import pytest
from ...compat import ArrayField, MissingType
@pytest.mark.skipif(ArrayField is MissingType, reason="ArrayField should exist")
def test_array_field_contains_empty_list(schema):
"""
Test contains filter on a array field of string.
"""
query = """
query {
events (tags_Contains... | [ {"node": {"name": "Live Show"}}, {"node": {"name": "Musical"}}, {"node": {"name": "Ballet"}}, {"node": {"name": "Speech"}}, ] | assert | collection | graphene_django/filter/tests/test_array_field_contains_filter.py | test_array_field_contains_empty_list | 74 | null | |
graphql-python/graphene-django | import pytest
from ...compat import ArrayField, MissingType
@pytest.mark.skipif(ArrayField is MissingType, reason="ArrayField should exist")
def test_array_field_contains_one(schema):
"""
Test contains filter on a array field of string.
"""
query = """
query {
events (tags_Contains: ["mus... | [ {"node": {"name": "Live Show"}}, {"node": {"name": "Musical"}}, ] | assert | collection | graphene_django/filter/tests/test_array_field_contains_filter.py | test_array_field_contains_one | 49 | null | |
graphql-python/graphene-django | import warnings
from collections import OrderedDict, defaultdict
from textwrap import dedent
from unittest.mock import patch
import pytest
from django.db import models
from graphene import Connection, Field, Interface, ObjectType, Schema, String
from graphene.relay import Node
from .. import registry
from ..filter i... | ["apnewsreporter", "articles", "films"] | assert | collection | graphene_django/tests/test_types.py | test_django_objecttype_map_correct_fields | 86 | null | |
graphql-python/graphene-django | from datetime import datetime
from textwrap import dedent
import pytest
from django.db.models import TextField, Value
from django.db.models.functions import Concat
from graphene import Argument, Boolean, Decimal, Field, ObjectType, Schema, String
from graphene.relay import Node
from graphene_django import DjangoObjec... | 1 | assert | numeric_literal | graphene_django/filter/tests/test_fields.py | test_filter_shortcut_filterset_context | 187 | null | |
graphql-python/graphene-django | from django import VERSION as DJANGO_VERSION, forms
from pytest import raises
from graphene import (
ID,
UUID,
Boolean,
Date,
DateTime,
Decimal,
Float,
Int,
List,
NonNull,
String,
Time,
)
from ..converter import convert_form_field
def assert_conversion(django_field, gr... | "[0-9]+") | assert_* | string_literal | graphene_django/forms/tests/test_converter.py | test_should_regex_convert_string | 83 | null | |
graphql-python/graphene-django | from datetime import datetime
from textwrap import dedent
import pytest
from django.db.models import TextField, Value
from django.db.models.functions import Concat
from graphene import Argument, Boolean, Decimal, Field, ObjectType, Schema, String
from graphene.relay import Node
from graphene_django import DjangoObjec... | expected | assert | variable | graphene_django/filter/tests/test_fields.py | test_should_query_filter_node_limit | 734 | null | |
graphql-python/graphene-django | from io import StringIO
from textwrap import dedent
from unittest.mock import mock_open, patch
from django.core import management
from graphene import ObjectType, Schema, String
@patch("json.dump")
def test_json_files_are_canonical(dump_mock):
open_mock = mock_open()
with patch("graphene_django.management.co... | 0 | assert | numeric_literal | graphene_django/tests/test_command.py | test_json_files_are_canonical | 29 | null | |
graphql-python/graphene-django | from io import StringIO
from textwrap import dedent
from unittest.mock import mock_open, patch
from django.core import management
from graphene import ObjectType, Schema, String
@patch("graphene_django.management.commands.graphql_schema.Command.save_json_file")
def test_generate_json_file_on_call_graphql_schema(save... | out.getvalue() | assert | func_call | graphene_django/tests/test_command.py | test_generate_json_file_on_call_graphql_schema | 14 | null | |
graphql-python/graphene-django | from ..str_converters import to_const
def test_to_const_unicode():
assert to_const("Skoða þetta unicode stöff") == "SK | "SKODA_THETTA_UNICODE_STOFF" | assert | string_literal | graphene_django/utils/tests/test_str_converters.py | test_to_const_unicode | 9 | null | |
graphql-python/graphene-django | import json
import warnings
from django.test import Client, TestCase, TransactionTestCase
from graphene_django.settings import graphene_settings
from graphene_django.utils.utils import _DJANGO_VERSION_AT_LEAST_4_2
DEFAULT_GRAPHQL_URL = "/graphql"
def graphql_query(
query,
operation_name=None,
input_data... | msg or content) | self.assertEqual | complex_expr | graphene_django/utils/testing.py | assertResponseNoErrors | GraphQLTestMixin | 145 | null |
graphql-python/graphene-django | from ..str_converters import to_const
def test_to_const():
assert to_const('snakes $1. on a "#plane') == | "SNAKES_1_ON_A_PLANE" | assert | string_literal | graphene_django/utils/tests/test_str_converters.py | test_to_const | 5 | null | |
graphql-python/graphene-django | import pytest
import graphene
from graphene.relay import Node
from graphene_django import DjangoConnectionField, DjangoObjectType
from graphene_django.tests.models import Article, Reporter
from graphene_django.utils import DJANGO_FILTER_INSTALLED
pytestmark = []
def schema():
class ReporterType(DjangoObjectType)... | schema_str | assert | variable | graphene_django/filter/tests/test_enum_filtering.py | test_filter_enum_field_schema_type | 131 | null | |
graphql-python/graphene-django | import copy
from django.db import models
from pytest import raises
from rest_framework import serializers
import graphene
from ..serializer_converter import convert_serializer_field
from ..types import DictType
def _get_type(
rest_framework_field, is_input=True, convert_choices_to_enum=True, **kwargs
):
# p... | graphene.Enum) | assert_* | complex_expr | graphene_django/rest_framework/tests/test_field_converter.py | test_should_choice_convert_enum | 68 | null | |
graphql-python/graphene-django | from datetime import datetime
import pytest
from django_filters import (
FilterSet,
rest_framework as filters,
)
from graphene import ObjectType, Schema
from graphene.relay import Node
from graphene_django import DjangoObjectType
from graphene_django.filter.tests.filters import ArticleFilter
from graphene_dja... | 0 | assert | numeric_literal | graphene_django/filter/tests/test_in_filter.py | test_in_filter_with_empty_list | 256 | null | |
graphql-python/graphene-django | import warnings
from collections import OrderedDict, defaultdict
from textwrap import dedent
from unittest.mock import patch
import pytest
from django.db import models
from graphene import Connection, Field, Interface, ObjectType, Schema, String
from graphene.relay import Node
from .. import registry
from ..filter i... | schema | assert | variable | graphene_django/tests/test_types.py | test_django_objecttype_name_connection_propagation | 828 | null | |
graphql-python/graphene-django | import json
from unittest.mock import patch
import pytest
from django.utils.translation import gettext_lazy
from ..utils import GraphQLTestCase, camelize, get_model_fields, get_reverse_fields
from ..utils.testing import graphql_query
from .models import APNewsReporter, CNNReporter, Film, Reporter
def test_camelize()... | {} | assert | collection | graphene_django/tests/test_utils.py | test_camelize | 35 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.