Codebase list python-graphene-sqlalchemy / 982c9c6e-64f9-4046-8bbf-cdcceff51ae7/main graphene_sqlalchemy / tests / test_registry.py
982c9c6e-64f9-4046-8bbf-cdcceff51ae7/main

Tree @982c9c6e-64f9-4046-8bbf-cdcceff51ae7/main (Download .tar.gz)

test_registry.py @982c9c6e-64f9-4046-8bbf-cdcceff51ae7/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")