File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def __init__(self):
8
8
def register (self , cls ):
9
9
from .types import SQLAlchemyObjectType
10
10
assert issubclass (cls , SQLAlchemyObjectType ), (
11
- 'Only classes of type SQLAlchemyObjectType can be registered, ' ,
11
+ 'Only classes of type SQLAlchemyObjectType can be registered, '
12
12
'received "{}"'
13
13
).format (cls .__name__ )
14
14
assert cls ._meta .registry == self , 'Registry for a Model have to match.'
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from .models import Pet
4
+ from ..registry import Registry
5
+ from ..types import SQLAlchemyObjectType
6
+
7
+
8
+ def test_register_incorrect_objecttype ():
9
+ reg = Registry ()
10
+
11
+ class Spam :
12
+ pass
13
+
14
+ with pytest .raises (AssertionError ) as excinfo :
15
+ reg .register (Spam )
16
+
17
+ assert 'Only classes of type SQLAlchemyObjectType can be registered' in str (excinfo .value )
18
+
19
+
20
+ def test_register_objecttype ():
21
+ reg = Registry ()
22
+
23
+ class PetType (SQLAlchemyObjectType ):
24
+ class Meta :
25
+ model = Pet
26
+ registry = reg
27
+
28
+ try :
29
+ reg .register (PetType )
30
+ except AssertionError :
31
+ pytest .fail ("expected no AssertionError" )
You can’t perform that action at this time.
0 commit comments