Skip to content

Commit

Permalink
Multiple connections - first tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amochin committed Oct 24, 2023
1 parent 123bc4c commit e089ac7
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit e089ac7

Please sign in to comment.