From fa11d0da51045077b543d42a1ab661c4a20b5127 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 1 Nov 2023 05:38:03 +0100 Subject: Adding upstream version 4.0.1. Signed-off-by: Daniel Baumann --- tests/features/steps/crud_table.py | 83 ++++++++++++++++++++++++++++++++++---- 1 file changed, 75 insertions(+), 8 deletions(-) (limited to 'tests/features/steps/crud_table.py') diff --git a/tests/features/steps/crud_table.py b/tests/features/steps/crud_table.py index 0375883..27d543e 100644 --- a/tests/features/steps/crud_table.py +++ b/tests/features/steps/crud_table.py @@ -9,6 +9,10 @@ from textwrap import dedent import wrappers +INITIAL_DATA = "xxx" +UPDATED_DATA = "yyy" + + @when("we create table") def step_create_table(context): """ @@ -22,7 +26,7 @@ def step_insert_into_table(context): """ Send insert into table. """ - context.cli.sendline("""insert into a(x) values('xxx');""") + context.cli.sendline(f"""insert into a(x) values('{INITIAL_DATA}');""") @when("we update table") @@ -30,7 +34,9 @@ def step_update_table(context): """ Send insert into table. """ - context.cli.sendline("""update a set x = 'yyy' where x = 'xxx';""") + context.cli.sendline( + f"""update a set x = '{UPDATED_DATA}' where x = '{INITIAL_DATA}';""" + ) @when("we select from table") @@ -46,7 +52,7 @@ def step_delete_from_table(context): """ Send deete from table. """ - context.cli.sendline("""delete from a where x = 'yyy';""") + context.cli.sendline(f"""delete from a where x = '{UPDATED_DATA}';""") @when("we drop table") @@ -57,6 +63,30 @@ def step_drop_table(context): context.cli.sendline("drop table a;") +@when("we alter the table") +def step_alter_table(context): + """ + Alter the table by adding a column. + """ + context.cli.sendline("""alter table a add column y varchar;""") + + +@when("we begin transaction") +def step_begin_transaction(context): + """ + Begin transaction + """ + context.cli.sendline("begin;") + + +@when("we rollback transaction") +def step_rollback_transaction(context): + """ + Rollback transaction + """ + context.cli.sendline("rollback;") + + @then("we see table created") def step_see_table_created(context): """ @@ -81,19 +111,20 @@ def step_see_record_updated(context): wrappers.expect_pager(context, "UPDATE 1\r\n", timeout=2) -@then("we see data selected") -def step_see_data_selected(context): +@then("we see data selected: {data}") +def step_see_data_selected(context, data): """ - Wait to see select output. + Wait to see select output with initial or updated data. """ + x = UPDATED_DATA if data == "updated" else INITIAL_DATA wrappers.expect_pager( context, dedent( - """\ + f"""\ +-----+\r | x |\r |-----|\r - | yyy |\r + | {x} |\r +-----+\r SELECT 1\r """ @@ -102,6 +133,26 @@ def step_see_data_selected(context): ) +@then("we see select output without data") +def step_see_no_data_selected(context): + """ + Wait to see select output without data. + """ + wrappers.expect_pager( + context, + dedent( + """\ + +---+\r + | x |\r + |---|\r + +---+\r + SELECT 0\r + """ + ), + timeout=1, + ) + + @then("we see record deleted") def step_see_data_deleted(context): """ @@ -116,3 +167,19 @@ def step_see_table_dropped(context): Wait to see drop output. """ wrappers.expect_pager(context, "DROP TABLE\r\n", timeout=2) + + +@then("we see transaction began") +def step_see_transaction_began(context): + """ + Wait to see transaction began. + """ + wrappers.expect_pager(context, "BEGIN\r\n", timeout=2) + + +@then("we see transaction rolled back") +def step_see_transaction_rolled_back(context): + """ + Wait to see transaction rollback. + """ + wrappers.expect_pager(context, "ROLLBACK\r\n", timeout=2) -- cgit v1.2.3