Codebase list python-graphene-sqlalchemy / 677cd2f4-93d2-4f9d-90e9-e2c9808d6e1c/main graphene_sqlalchemy / tests / test_registry.py
677cd2f4-93d2-4f9d-90e9-e2c9808d6e1c/main

Tree @677cd2f4-93d2-4f9d-90e9-e2c9808d6e1c/main (Download .tar.gz)

test_registry.py @677cd2f4-93d2-4f9d-90e9-e2c9808d6e1c/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")