add unit tests for new converters #172

This commit is contained in:
evalette 2016-06-21 13:34:27 +02:00
parent e3704577b3
commit 73bd8782b5
2 changed files with 28 additions and 1 deletions

View File

@ -80,7 +80,8 @@ def convert_column_to_enum(type, column):
@convert_sqlalchemy_type.register(postgresql.ARRAY)
def convert_postgres_array_to_list(type, column):
return List(description=column.doc)
graphene_type = convert_sqlalchemy_type(column.type.item_type, column)
return List(graphene_type, description=column.doc)
@convert_sqlalchemy_type.register(postgresql.HSTORE)

View File

@ -2,8 +2,10 @@ from py.test import raises
from sqlalchemy import Column, Table, types
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_utils.types.choice import ChoiceType
from sqlalchemy.dialects import postgresql
import graphene
from graphene.core.types.custom_scalars import JSONString
from graphene.contrib.sqlalchemy.converter import (convert_sqlalchemy_column,
convert_sqlalchemy_relationship)
from graphene.contrib.sqlalchemy.fields import (ConnectionOrListField,
@ -122,3 +124,27 @@ def test_should_onetomany_convert_model():
assert isinstance(graphene_type, ConnectionOrListField)
assert isinstance(graphene_type.type, SQLAlchemyModelField)
assert graphene_type.type.model == Article
def test_should_postgresql_uuid_convert():
assert_column_conversion(postgresql.UUID(), graphene.String)
def test_should_postgresql_enum_convert():
assert_column_conversion(postgresql.ENUM(), graphene.String)
def test_should_postgresql_array_convert():
assert_column_conversion(postgresql.ARRAY(types.Integer), graphene.List)
def test_should_postgresql_json_convert():
assert_column_conversion(postgresql.JSON(), JSONString)
def test_should_postgresql_jsonb_convert():
assert_column_conversion(postgresql.JSONB(), JSONString)
def test_should_postgresql_hstore_convert():
assert_column_conversion(postgresql.HSTORE(), JSONString)