コード例 #1
0
ファイル: test_converter.py プロジェクト: fatelei/graphene
def assert_column_conversion(sqlalchemy_type, graphene_field, **kwargs):
    column = Column(sqlalchemy_type, doc='Custom Help Text', **kwargs)
    graphene_type = convert_sqlalchemy_column(column)
    assert isinstance(graphene_type, graphene_field)
    field = graphene_type.as_field()
    assert field.description == 'Custom Help Text'
    return field
コード例 #2
0
def assert_column_conversion(sqlalchemy_type, graphene_field, **kwargs):
    column = Column(sqlalchemy_type, doc='Custom Help Text', **kwargs)
    graphene_type = convert_sqlalchemy_column(column)
    assert isinstance(graphene_type, graphene_field)
    field = graphene_type.as_field()
    assert field.description == 'Custom Help Text'
    return field
コード例 #3
0
ファイル: test_converter.py プロジェクト: jkimbo/graphene
def test_should_choice_convert_enum():
    TYPES = [(u"es", u"Spanish"), (u"en", u"English")]
    column = Column(ChoiceType(TYPES), doc="Language", name="language")
    Base = declarative_base()

    Table("translatedmodel", Base.metadata, column)
    graphene_type = convert_sqlalchemy_column(column)
    assert issubclass(graphene_type, graphene.Enum)
    assert graphene_type._meta.type_name == "TRANSLATEDMODEL_LANGUAGE"
    assert graphene_type._meta.description == "Language"
    assert graphene_type.__enum__.__members__["es"].value == "Spanish"
    assert graphene_type.__enum__.__members__["en"].value == "English"
コード例 #4
0
ファイル: test_converter.py プロジェクト: timmygee/graphene
def test_should_choice_convert_enum():
    TYPES = [(u'es', u'Spanish'), (u'en', u'English')]
    column = Column(ChoiceType(TYPES), doc='Language', name='language')
    Base = declarative_base()

    Table('translatedmodel', Base.metadata, column)
    graphene_type = convert_sqlalchemy_column(column)
    assert issubclass(graphene_type, graphene.Enum)
    assert graphene_type._meta.type_name == 'TRANSLATEDMODEL_LANGUAGE'
    assert graphene_type._meta.description == 'Language'
    assert graphene_type.__enum__.__members__['es'].value == 'Spanish'
    assert graphene_type.__enum__.__members__['en'].value == 'English'
コード例 #5
0
def test_should_choice_convert_enum():
    TYPES = [
        (u'es', u'Spanish'),
        (u'en', u'English')
    ]
    column = Column(ChoiceType(TYPES), doc='Language', name='language')
    Base = declarative_base()

    Table('translatedmodel', Base.metadata, column)
    graphene_type = convert_sqlalchemy_column(column)
    assert issubclass(graphene_type, graphene.Enum)
    assert graphene_type._meta.type_name == 'TRANSLATEDMODEL_LANGUAGE'
    assert graphene_type._meta.description == 'Language'
    assert graphene_type.__enum__.__members__['es'].value == 'Spanish'
    assert graphene_type.__enum__.__members__['en'].value == 'English'
コード例 #6
0
ファイル: test_converter.py プロジェクト: fatelei/graphene
def test_should_unknown_sqlalchemy_field_raise_exception():
    with raises(Exception) as excinfo:
        convert_sqlalchemy_column(None)
    assert 'Don\'t know how to convert the SQLAlchemy field' in str(excinfo.value)
コード例 #7
0
def test_should_unknown_sqlalchemy_field_raise_exception():
    with raises(Exception) as excinfo:
        convert_sqlalchemy_column(None)
    assert 'Don\'t know how to convert the SQLAlchemy field' in str(
        excinfo.value)