Codebase list python-graphene-sqlalchemy / 3ad81ec5-463d-4103-b939-6d2686606ab3/main graphene_sqlalchemy / tests / test_registry.py
3ad81ec5-463d-4103-b939-6d2686606ab3/main

Tree @3ad81ec5-463d-4103-b939-6d2686606ab3/main (Download .tar.gz)

test_registry.py @3ad81ec5-463d-4103-b939-6d2686606ab3/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")