Skip to content

Commit

Permalink
Tests: Improve stability by using "REFRESH TABLE" appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Mar 26, 2021
1 parent c6710c2 commit 06d25f3
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/crate/client/sqlalchemy/doctests/itests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ Insert a new location::
>>> session.add(location)
>>> session.flush()

Currently refresh option is missing, therefore sleep for now::
Refresh "locations" table:

>>> from time import sleep
>>> sleep(1)
>>> _ = connection.execute("REFRESH TABLE locations")

Inserted location is available::

Expand Down Expand Up @@ -106,7 +105,10 @@ The datetime and date can be set using a update statement::
>>> location.nullable_date = datetime.today()
>>> location.nullable_datetime = datetime.utcnow()
>>> session.flush()
>>> sleep(1.1) # wait for index refresh

Refresh "locations" table:

>>> _ = connection.execute("REFRESH TABLE locations")

Boolean values get set natively::

Expand Down Expand Up @@ -140,7 +142,11 @@ Update multiple Locations::
... session.add(loc)
... session.flush()

>>> sleep(2) # give crate some time to settle
Refresh "locations" table:

>>> _ = connection.execute("REFRESH TABLE locations")

Query database:

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

>>> session.commit()
>>> sleep(2) # give crate some time to settle

Refresh "locations" table:

>>> _ = connection.execute("REFRESH TABLE locations")

Test that objects can be used as list too::

Expand Down Expand Up @@ -202,7 +211,10 @@ test updated nested dict::
>>> char.details['name']['first'] = 'Trillian'
>>> char.details['size'] = 45
>>> session.commit()
>>> sleep(1.1) # wait for index refresh

Refresh "characters" table:

>>> _ = connection.execute("REFRESH TABLE characters")

>>> session.refresh(char)
>>> import pprint
Expand Down

0 comments on commit 06d25f3

Please sign in to comment.