File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
2
Integration tests for the model API
3
3
"""
4
+
4
5
from datetime import datetime
6
+
5
7
from pynamodb .models import Model
6
8
from pynamodb .indexes import GlobalSecondaryIndex , AllProjection , LocalSecondaryIndex
7
9
from pynamodb .attributes import (
@@ -102,3 +104,38 @@ class Meta:
102
104
103
105
print (query_obj .update ([TestModel .view .add (1 )], condition = TestModel .forum .exists ()))
104
106
TestModel .delete_table ()
107
+
108
+
109
+
110
+ def test_can_inherit_version_attribute (ddb_url ) -> None :
111
+
112
+ class TestModelA (Model ):
113
+ """
114
+ A model for testing
115
+ """
116
+
117
+ class Meta :
118
+ region = 'us-east-1'
119
+ table_name = 'pynamodb-ci-a'
120
+ host = ddb_url
121
+
122
+ forum = UnicodeAttribute (hash_key = True )
123
+ thread = UnicodeAttribute (range_key = True )
124
+ scores = NumberAttribute ()
125
+ version = VersionAttribute ()
126
+
127
+ class TestModelB (TestModelA ):
128
+ class Meta :
129
+ region = 'us-east-1'
130
+ table_name = 'pynamodb-ci-b'
131
+ host = ddb_url
132
+
133
+ with pytest .raises (ValueError ) as e :
134
+ class TestModelC (TestModelA ):
135
+ class Meta :
136
+ region = 'us-east-1'
137
+ table_name = 'pynamodb-ci-c'
138
+ host = ddb_url
139
+
140
+ version_invalid = VersionAttribute ()
141
+ assert str (e .value ) == 'The model has more than one Version attribute: version, version_invalid'
You can’t perform that action at this time.
0 commit comments