Codebase list python-graphene-sqlalchemy / de8dcc09-fa25-41bd-9018-fb796b42f99b/main graphene_sqlalchemy / tests / test_registry.py
de8dcc09-fa25-41bd-9018-fb796b42f99b/main

Tree @de8dcc09-fa25-41bd-9018-fb796b42f99b/main (Download .tar.gz)

test_registry.py @de8dcc09-fa25-41bd-9018-fb796b42f99b/mainraw · history · blame

import pytest

from ..registry import Registry
from ..types import SQLAlchemyObjectType
from .models import Pet


def test_register_incorrect_objecttype():
    reg = Registry()

    class Spam:
        pass

    with pytest.raises(AssertionError) as excinfo:
        reg.register(Spam)

    assert "Only classes of type SQLAlchemyObjectType can be registered" in str(
        excinfo.value
    )


def test_register_objecttype():
    reg = Registry()

    class PetType(SQLAlchemyObjectType):
        class Meta:
            model = Pet
            registry = reg

    try:
        reg.register(PetType)
    except AssertionError:
        pytest.fail("expected no AssertionError")