From e089ac7ac4dc1509b9abb4197d2d1adcfeb3fb47 Mon Sep 17 00:00:00 2001 From: amochin Date: Tue, 24 Oct 2023 09:06:13 +0200 Subject: [PATCH] Multiple connections - first tests --- .../multi_db_different.robot | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/tests/custom_db_tests/multiple_connections/multi_db_different.robot diff --git a/test/tests/custom_db_tests/multiple_connections/multi_db_different.robot b/test/tests/custom_db_tests/multiple_connections/multi_db_different.robot new file mode 100644 index 0000000..e956e92 --- /dev/null +++ b/test/tests/custom_db_tests/multiple_connections/multi_db_different.robot @@ -0,0 +1,50 @@ +*** Settings *** +Documentation Connections to two different databases can be handled separately + +Library DatabaseLibrary AS 1_PostgreSQL +Library DatabaseLibrary AS 2_MySQL + +Suite Setup Connect To All Databases +Suite Teardown Disconnect From All Database +Test Setup Create Tables +Test Teardown Drop Tables + + +*** Variables *** +${Table_1} Table_1 +${Table_2} Table_2 + + +*** Test Cases *** +First Table Was Created In First Database Only + 1_PostgreSQL.Table Must Exist ${Table_1} + Run Keyword And Expect Error Table '${Table_2}' does not exist in the db + ... 1_PostgreSQL.Table Must Exist ${Table_2} + +Second Table Was Created In Second Database Only + 2_MySQL.Table Must Exist ${Table_2} + Run Keyword And Expect Error Table '${Table_1}' does not exist in the db + ... 2_MySQL.Table Must Exist ${Table_1} + +*** Keywords *** +Connect To All Databases + 1_PostgreSQL.Connect To Database psycopg2 db db_user pass 127.0.0.1 5432 + 2_MySQL.Connect To Database pymysql db db_user pass 127.0.0.1 3306 + +Disconnect From All Database + 1_PostgreSQL.Disconnect From Database + 2_MySQL.Disconnect From Database + +Create Tables + ${sql_1}= Catenate + ... CREATE TABLE ${Table_1} + ... (id integer not null unique, FIRST_NAME varchar(20), LAST_NAME varchar(20)) + ${sql_2}= Catenate + ... CREATE TABLE ${Table_2} + ... (id integer not null unique, FIRST_NAME varchar(20), LAST_NAME varchar(20)) + 1_PostgreSQL.Execute Sql String ${sql_1} + 2_MySQL.Execute Sql String ${sql_2} + +Drop Tables + 1_PostgreSQL.Execute Sql String DROP TABLE ${Table_1} + 2_MySQL.Execute Sql String DROP TABLE ${Table_2}