Codebase list python-graphene-sqlalchemy / 5e0bb170-af41-4c0b-91c9-11710c902830/main graphene_sqlalchemy / tests / test_registry.py
5e0bb170-af41-4c0b-91c9-11710c902830/main

Tree @5e0bb170-af41-4c0b-91c9-11710c902830/main (Download .tar.gz)

test_registry.py @5e0bb170-af41-4c0b-91c9-11710c902830/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")