Adding testing for graphene_django/elasticsearch/*

This commit is contained in:
Alejandro Nunez Capote 2019-05-31 22:16:36 -04:00
parent 4796d024d4
commit fc186ea23d
5 changed files with 37 additions and 1 deletions

View 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')

View 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")

View File

@ -13,7 +13,7 @@ except ImportError:
try:
import django_elasticsearch_dsl # noqa
import elasticsearch_dsl # noqa
DJANGO_ELASTICSEARCH_DSL_INSTALLED = True
except ImportError:

View File

@ -22,6 +22,7 @@ tests_require = [
"django-filter<2;python_version<'3'",
"django-filter>=2;python_version>='3'",
"pytest-django>=3.3.2",
"elasticsearch-dsl<7.0",
] + rest_framework_require