mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-13 17:52:19 +03:00
Adding testing for graphene_django/elasticsearch/*
This commit is contained in:
parent
4796d024d4
commit
fc186ea23d
0
graphene_django/elasticsearch/tests/__init__.py
Normal file
0
graphene_django/elasticsearch/tests/__init__.py
Normal file
8
graphene_django/elasticsearch/tests/filters.py
Normal file
8
graphene_django/elasticsearch/tests/filters.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
from graphene_django.elasticsearch.filter import filters
|
||||||
|
from graphene_django.elasticsearch.filter.filterset import FilterSetES
|
||||||
|
|
||||||
|
|
||||||
|
class ArticleFilterES(FilterSetES):
|
||||||
|
|
||||||
|
headline = filters.StringFilterES(attr='headline')
|
27
graphene_django/elasticsearch/tests/test_fields.py
Normal file
27
graphene_django/elasticsearch/tests/test_fields.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from graphene_django.filter.tests.test_fields import assert_arguments, ArticleNode
|
||||||
|
|
||||||
|
from graphene_django.elasticsearch.tests.filters import ArticleFilterES
|
||||||
|
from graphene_django.utils import DJANGO_FILTER_INSTALLED, DJANGO_ELASTICSEARCH_DSL_INSTALLED
|
||||||
|
|
||||||
|
|
||||||
|
pytestmark = []
|
||||||
|
|
||||||
|
if DJANGO_FILTER_INSTALLED and DJANGO_ELASTICSEARCH_DSL_INSTALLED:
|
||||||
|
from graphene_django.filter import (
|
||||||
|
DjangoFilterConnectionField,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
pytestmark.append(
|
||||||
|
pytest.mark.skipif(
|
||||||
|
True, reason="django_filters not installed or not compatible"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
pytestmark.append(pytest.mark.django_db)
|
||||||
|
|
||||||
|
|
||||||
|
def test_filter_string_fields():
|
||||||
|
field = DjangoFilterConnectionField(ArticleNode, filterset_class=ArticleFilterES)
|
||||||
|
assert_arguments(field, "headline", "headline_term")
|
|
@ -13,7 +13,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import django_elasticsearch_dsl # noqa
|
import elasticsearch_dsl # noqa
|
||||||
|
|
||||||
DJANGO_ELASTICSEARCH_DSL_INSTALLED = True
|
DJANGO_ELASTICSEARCH_DSL_INSTALLED = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -22,6 +22,7 @@ tests_require = [
|
||||||
"django-filter<2;python_version<'3'",
|
"django-filter<2;python_version<'3'",
|
||||||
"django-filter>=2;python_version>='3'",
|
"django-filter>=2;python_version>='3'",
|
||||||
"pytest-django>=3.3.2",
|
"pytest-django>=3.3.2",
|
||||||
|
"elasticsearch-dsl<7.0",
|
||||||
] + rest_framework_require
|
] + rest_framework_require
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user