Skip to content

Commit 1cbb517

Browse files
committed
Added tests for new timestamp functions.
1 parent 6362b10 commit 1cbb517

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

spanner/cloud-client/snippets_test.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,90 @@ def _():
180180
out, _ = capsys.readouterr()
181181

182182
assert 'Forever Hold Your Peace' in out
183+
184+
185+
def test_create_table_with_timestamp(temporary_database, capsys):
186+
snippets.create_table_with_timestamp(
187+
SPANNER_INSTANCE,
188+
temporary_database.database_id)
189+
190+
out, _ = capsys.readouterr()
191+
192+
assert 'Performances' in out
193+
194+
195+
def test_insert_data_with_timestamp(temporary_database, capsys):
196+
snippets.create_table_with_timestamp(
197+
SPANNER_INSTANCE,
198+
temporary_database.database_id)
199+
snippets.insert_data_with_timestamp(
200+
SPANNER_INSTANCE,
201+
temporary_database.database_id)
202+
203+
out, _ = capsys.readouterr()
204+
205+
assert 'Inserted data.' in out
206+
207+
208+
@pytest.fixture(scope='module')
209+
def temporary_database_with_timestamps(temporary_database):
210+
snippets.create_table_with_timestamp(
211+
SPANNER_INSTANCE,
212+
temporary_database.database_id)
213+
snippets.insert_data_with_timestamp(
214+
SPANNER_INSTANCE,
215+
temporary_database.database_id)
216+
217+
yield temporary_database
218+
219+
220+
def test_add_timestamp_column(temporary_database, capsys):
221+
snippets.add_timestamp_column(
222+
SPANNER_INSTANCE,
223+
temporary_database_with_timestamps.database_id)
224+
225+
out, _ = capsys.readouterr()
226+
227+
assert 'Albums' in out
228+
229+
230+
@pytest.fixture(scope='module')
231+
def temporary_database_with_timestamps_column(temporary_database_with_timestamps):
232+
snippets.add_timestamp_column(
233+
SPANNER_INSTANCE,
234+
temporary_database_with_timestamps.database_id)
235+
236+
yield temporary_database
237+
238+
239+
def test_update_data_with_timestamp(temporary_database_with_timestamps, capsys):
240+
snippets.update_data_with_timestamp(
241+
SPANNER_INSTANCE,
242+
temporary_database_with_timestamps_column.database_id)
243+
244+
out, _ = capsys.readouterr()
245+
246+
assert 'Updated data.' in out
247+
248+
249+
@pytest.fixture(scope='module')
250+
def temporary_database_with_timestamps_data(temporary_database_with_timestamps):
251+
snippets.add_timestamp_column(
252+
SPANNER_INSTANCE,
253+
temporary_database_with_timestamps.database_id)
254+
255+
yield temporary_database
256+
257+
258+
@pytest.mark.slow
259+
def test_query_data_with_timestamp(temporary_database_with_timestamps_data, capsys):
260+
@eventually_consistent.call
261+
def _():
262+
snippets.query_data_with_timestamp(
263+
SPANNER_INSTANCE,
264+
temporary_database_with_timestamps_data.database_id)
265+
266+
out, _ = capsys.readouterr()
267+
268+
assert 'Updated data.' in out
269+

0 commit comments

Comments
 (0)