Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antikus committed Oct 18, 2023
1 parent 9538e4c commit 7c85644
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions test/test_integration_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
}



suffix = uuid.uuid4()
engine = f"sf-python-sdk-{suffix}"
dbname = f"sf-python-sdk-{suffix}"
Expand All @@ -28,15 +27,21 @@
class TestDatabase(unittest.TestCase):
def setUp(self):
self.session = Session.builder.configs(connection_parameters).create()
# api.delete_database(session, dbname)

def test_create_delete_database_api(self):
create_database_res = api.create_database(self.session, dbname)
self.assertTrue(create_database_res)

delete_database_res = api.delete_database(self.session, dbname)
self.assertTrue(delete_database_res)


def test_create_database(self):
create_database_res = api.create_database(self.session, dbname)
self.assertTrue(create_database_res)

with self.assertRaises(Exception):
api.create_database(self.session, dbname)

def test_list_databases(self):
df_list_dbs = api.list_databases(self.session)
list_dbs_res = df_list_dbs.collect()
Expand All @@ -51,7 +56,32 @@ def test_list_databases(self):
self.assertTrue(hasattr(fist_el, 'NAME'))
self.assertTrue(hasattr(fist_el, 'REGION'))
self.assertTrue(hasattr(fist_el, 'STATE'))


def test_get_database(self):
api.create_database(self.session, dbname)

df_get_db = api.get_database(self.session, dbname)
get_db_res = df_get_db.collect()

self.assertTrue(len(get_db_res) == 1)

fist_el = get_db_res[0]

self.assertTrue(hasattr(fist_el, 'ID'))
self.assertTrue(hasattr(fist_el, 'ACCOUNT_NAME'))
self.assertTrue(hasattr(fist_el, 'CREATED_BY'))
self.assertTrue(hasattr(fist_el, 'NAME'))
self.assertTrue(hasattr(fist_el, 'REGION'))
self.assertTrue(hasattr(fist_el, 'STATE'))

def test_use_database(self):
api.create_database(self.session, dbname)

self.assertIsNone(api.use_database(self.session, dbname))

with self.assertRaises(Exception):
api.use_database(self.session, 'some-random-db-that-doesnt-exist')

def tearDown(self):
api.delete_database(self.session, dbname)

Expand Down

0 comments on commit 7c85644

Please sign in to comment.