Skip to content

Commit 06d25f3

Browse files
committed
Tests: Improve stability by using "REFRESH TABLE" appropriately
1 parent c6710c2 commit 06d25f3

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

Diff for: src/crate/client/sqlalchemy/doctests/itests.txt

+19-7
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ Insert a new location::
4949
>>> session.add(location)
5050
>>> session.flush()
5151

52-
Currently refresh option is missing, therefore sleep for now::
52+
Refresh "locations" table:
5353

54-
>>> from time import sleep
55-
>>> sleep(1)
54+
>>> _ = connection.execute("REFRESH TABLE locations")
5655

5756
Inserted location is available::
5857

@@ -106,7 +105,10 @@ The datetime and date can be set using a update statement::
106105
>>> location.nullable_date = datetime.today()
107106
>>> location.nullable_datetime = datetime.utcnow()
108107
>>> session.flush()
109-
>>> sleep(1.1) # wait for index refresh
108+
109+
Refresh "locations" table:
110+
111+
>>> _ = connection.execute("REFRESH TABLE locations")
110112

111113
Boolean values get set natively::
112114

@@ -140,7 +142,11 @@ Update multiple Locations::
140142
... session.add(loc)
141143
... session.flush()
142144

143-
>>> sleep(2) # give crate some time to settle
145+
Refresh "locations" table:
146+
147+
>>> _ = connection.execute("REFRESH TABLE locations")
148+
149+
Query database:
144150

145151
>>> result = connection.execute("update locations set flag=true where kind='Update'")
146152
>>> result.rowcount
@@ -154,7 +160,10 @@ documents in the table::
154160
True
155161

156162
>>> session.commit()
157-
>>> sleep(2) # give crate some time to settle
163+
164+
Refresh "locations" table:
165+
166+
>>> _ = connection.execute("REFRESH TABLE locations")
158167

159168
Test that objects can be used as list too::
160169

@@ -202,7 +211,10 @@ test updated nested dict::
202211
>>> char.details['name']['first'] = 'Trillian'
203212
>>> char.details['size'] = 45
204213
>>> session.commit()
205-
>>> sleep(1.1) # wait for index refresh
214+
215+
Refresh "characters" table:
216+
217+
>>> _ = connection.execute("REFRESH TABLE characters")
206218

207219
>>> session.refresh(char)
208220
>>> import pprint

0 commit comments

Comments
 (0)