Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
Add a test with schema support
Browse files Browse the repository at this point in the history
See #3
  • Loading branch information
lalinsky committed Sep 4, 2017
1 parent b0be054 commit 424a375
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions phoenixdb/tests/test_db.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import phoenixdb
import phoenixdb.cursor
from phoenixdb.errors import InternalError
from phoenixdb.tests import TEST_DB_URL


Expand Down Expand Up @@ -63,3 +64,21 @@ def test_dict_cursor(self):

with db.cursor(cursor_factory=phoenixdb.cursor.DictCursor) as cursor:
self._check_dict_cursor(cursor)

def test_schema(self):
db = phoenixdb.connect(TEST_DB_URL, autocommit=True)
self.addCleanup(db.close)

with db.cursor() as cursor:
try:
cursor.execute("CREATE SCHEMA IF NOT EXISTS test_schema")
except InternalError as e:
if "phoenix.schema.isNamespaceMappingEnabled" in e.message:
self.skipTest(e.message)
raise

cursor.execute("DROP TABLE IF EXISTS test_schema.test")
cursor.execute("CREATE TABLE test_schema.test (id INTEGER PRIMARY KEY, text VARCHAR)")
cursor.execute("UPSERT INTO test_schema.test VALUES (?, ?)", [1, 'text 1'])
cursor.execute("SELECT * FROM test_schema.test ORDER BY id")
self.assertEqual(cursor.fetchall(), [[1, 'text 1']])

0 comments on commit 424a375

Please sign in to comment.