Exemplo n.º 1
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
Exemplo n.º 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
Exemplo n.º 3
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"
Exemplo n.º 4
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'
Exemplo n.º 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'
Exemplo n.º 6
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)
Exemplo n.º 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)