Ошибка при использовании библиотеки микшеров для тестирования схемы Graphql (AttributeError: объект «str» не имеет атрибута «имя»)
Получение приведенной ниже ошибки при запуске тестового примера. Библиотека микшера не смешивает объект. Любые советы о том, в чем может быть проблема, будут очень полезны.
ERROR: test_fetch_category_response (apps.products.core.tests.schema.CategoryUnitTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/dir/backend/apps/products/core/tests/schema.py", line 63, in setUp
self.category1 = mixer.blend(CategoryType)
File "/Users/dir/lib/python3.9/site-packages/mixer/main.py", line 566, in blend
type_mixer = self.get_typemixer(scheme)
File "/Users/dir/lib/python3.9/site-packages/mixer/main.py", line 583, in get_typemixer
return self.type_mixer_cls(
File "/Users/dir/lib/python3.9/site-packages/mixer/main.py", line 54, in __call__
cls.mixers[key] = super(TypeMixerMeta, cls).__call__(
File "/Users/dir/lib/python3.9/site-packages/mixer/main.py", line 88, in __init__
self.__fields = _.OrderedDict(self.__load_fields())
File "/Users/dir/lib/python3.9/site-packages/mixer/backend/django.py", line 401, in __load_fields
yield field.name, t.Field(field, field.name)
AttributeError: 'str' object has no attribute 'name'
Ниже приведен код для CategoryUnitTestCase, который не работает.
import json
from mixer.backend.django import mixer
from django.test import TestCase
from graphene_django.utils.testing import GraphQLTestCase
from backend.schema import schema
from apps.products.core.schema import CategoryType
FETCH_CATEGORY_QUERY =
query {
categories {
id,
name,
slug,
}
}
class CategoryUnitTestCase(GraphQLTestCase):
GRAPHQL_SCHEMA = schema
databases = '__all__'
def setUp(self):
self.category1 = mixer.blend(CategoryType)
def test_fetch_category_response(self):
response = self.query(
FETCH_CATEGORY_QUERY,
)
content = json.loads(response.content)
self.assertResponseNoErrors(response)