1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import re
1516from datetime import timedelta , datetime
1617from unittest import mock
17- import sure
1818from uuid import uuid4
1919
2020from cassandra .cqlengine import columns
@@ -47,7 +47,11 @@ def test_batch_is_included(self):
4747 with BatchQuery (timestamp = timedelta (seconds = 30 )) as b :
4848 TestTimestampModel .batch (b ).create (count = 1 )
4949
50+ < << << << Updated upstream
5051 "USING TIMESTAMP" .should .be .within (m .call_args [0 ][0 ].query_string )
52+ == == == =
53+ assert re .search ("USING TIMESTAMP" , m .call_args [0 ][0 ].query_string )
54+ >> >> >> > Stashed changes
5155
5256
5357class CreateWithTimestampTest (BaseTimestampTest ):
@@ -58,47 +62,52 @@ def test_batch(self):
5862 TestTimestampModel .timestamp (timedelta (seconds = 10 )).batch (b ).create (count = 1 )
5963
6064 query = m .call_args [0 ][0 ].query_string
61-
62- query .should .match (r"INSERT.*USING TIMESTAMP" )
63- query .should_not .match (r"TIMESTAMP.*INSERT" )
65+ assert re .search (r"INSERT.*USING TIMESTAMP" , query )
66+ assert not re .search (r"TIMESTAMP.*INSERT" , query )
6467
6568 def test_timestamp_not_included_on_normal_create (self ):
6669 with mock .patch .object (self .session , "execute" ) as m :
6770 TestTimestampModel .create (count = 2 )
6871
72+ < << << << Updated upstream
6973 "USING TIMESTAMP" .shouldnt .be .within (m .call_args [0 ][0 ].query_string )
74+ == == == =
75+ assert not re .search ("USING TIMESTAMP" , m .call_args [0 ][0 ].query_string )
76+ >> >> >> > Stashed changes
7077
7178 def test_timestamp_is_set_on_model_queryset (self ):
7279 delta = timedelta (seconds = 30 )
7380 tmp = TestTimestampModel .timestamp (delta )
74- tmp ._timestamp . should . equal ( delta )
81+ assert tmp ._timestamp == delta
7582
7683 def test_non_batch_syntax_integration (self ):
7784 tmp = TestTimestampModel .timestamp (timedelta (seconds = 30 )).create (count = 1 )
78- tmp . should . be . ok
85+ assert tmp
7986
8087 def test_non_batch_syntax_with_tll_integration (self ):
8188 tmp = TestTimestampModel .timestamp (timedelta (seconds = 30 )).ttl (30 ).create (count = 1 )
82- tmp . should . be . ok
89+ assert tmp
8390
8491 def test_non_batch_syntax_unit (self ):
8592
8693 with mock .patch .object (self .session , "execute" ) as m :
8794 TestTimestampModel .timestamp (timedelta (seconds = 30 )).create (count = 1 )
8895
96+ < << << << Updated upstream
8997 query = m .call_args [0 ][0 ].query_string
9098
9199 "USING TIMESTAMP" .should .be .within (query )
100+ == == == =
101+ assert re .search ("USING TIMESTAMP" , m .call_args [0 ][0 ].query_string )
102+ >> >> >> > Stashed changes
92103
93104 def test_non_batch_syntax_with_ttl_unit (self ):
94105
95106 with mock .patch .object (self .session , "execute" ) as m :
96107 TestTimestampModel .timestamp (timedelta (seconds = 30 )).ttl (30 ).create (
97108 count = 1 )
98109
99- query = m .call_args [0 ][0 ].query_string
100-
101- query .should .match (r"USING TTL \d* AND TIMESTAMP" )
110+ assert re .search (r"USING TTL \d* AND TIMESTAMP" , m .call_args [0 ][0 ].query_string )
102111
103112
104113class UpdateWithTimestampTest (BaseTimestampTest ):
@@ -111,16 +120,24 @@ def test_instance_update_includes_timestamp_in_query(self):
111120
112121 with mock .patch .object (self .session , "execute" ) as m :
113122 self .instance .timestamp (timedelta (seconds = 30 )).update (count = 2 )
123+ < << << << Updated upstream
114124
115125 "USING TIMESTAMP" .should .be .within (m .call_args [0 ][0 ].query_string )
126+ == == == =
127+ assert re .search ("USING TIMESTAMP" , m .call_args [0 ][0 ].query_string )
128+ >> >> >> > Stashed changes
116129
117130 def test_instance_update_in_batch (self ):
118131 with mock .patch .object (self .session , "execute" ) as m :
119132 with BatchQuery () as b :
120133 self .instance .batch (b ).timestamp (timedelta (seconds = 30 )).update (count = 2 )
121134
135+ < << << << Updated upstream
122136 query = m .call_args [0 ][0 ].query_string
123137 "USING TIMESTAMP" .should .be .within (query )
138+ == == == =
139+ assert re .search ("USING TIMESTAMP" , m .call_args [0 ][0 ].query_string )
140+ >> >> >> > Stashed changes
124141
125142
126143class DeleteWithTimestampTest (BaseTimestampTest ):
@@ -132,7 +149,7 @@ def test_non_batch(self):
132149 uid = uuid4 ()
133150 tmp = TestTimestampModel .create (id = uid , count = 1 )
134151
135- TestTimestampModel .get (id = uid ). should . be . ok
152+ assert TestTimestampModel .get (id = uid )
136153
137154 tmp .timestamp (timedelta (seconds = 5 )).delete ()
138155
@@ -146,15 +163,15 @@ def test_non_batch(self):
146163
147164 # calling .timestamp sets the TS on the model
148165 tmp .timestamp (timedelta (seconds = 5 ))
149- tmp ._timestamp . should . be . ok
166+ assert tmp ._timestamp
150167
151168 # calling save clears the set timestamp
152169 tmp .save ()
153- tmp ._timestamp . shouldnt . be . ok
170+ assert not tmp ._timestamp
154171
155172 tmp .timestamp (timedelta (seconds = 5 ))
156173 tmp .update ()
157- tmp ._timestamp . shouldnt . be . ok
174+ assert not tmp ._timestamp
158175
159176 def test_blind_delete (self ):
160177 """
@@ -163,7 +180,7 @@ def test_blind_delete(self):
163180 uid = uuid4 ()
164181 tmp = TestTimestampModel .create (id = uid , count = 1 )
165182
166- TestTimestampModel .get (id = uid ). should . be . ok
183+ assert TestTimestampModel .get (id = uid )
167184
168185 TestTimestampModel .objects (id = uid ).timestamp (timedelta (seconds = 5 )).delete ()
169186
@@ -182,7 +199,7 @@ def test_blind_delete_with_datetime(self):
182199 uid = uuid4 ()
183200 tmp = TestTimestampModel .create (id = uid , count = 1 )
184201
185- TestTimestampModel .get (id = uid ). should . be . ok
202+ assert TestTimestampModel .get (id = uid )
186203
187204 plus_five_seconds = datetime .now () + timedelta (seconds = 5 )
188205
@@ -200,11 +217,9 @@ def test_delete_in_the_past(self):
200217 uid = uuid4 ()
201218 tmp = TestTimestampModel .create (id = uid , count = 1 )
202219
203- TestTimestampModel .get (id = uid ). should . be . ok
220+ assert TestTimestampModel .get (id = uid )
204221
205222 # delete the in past, should not affect the object created above
206223 TestTimestampModel .objects (id = uid ).timestamp (timedelta (seconds = - 60 )).delete ()
207224
208225 TestTimestampModel .get (id = uid )
209-
210-
0 commit comments