OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_exceptions Namespace Reference


def test_failed_init
 Check init with wrong parameter. More...
def test_success_init
 Check init with right parameters. More...
def test_success_DDL
 Check DDL statement. More...
def test_failed_DDL
 Check creating a duplicate table. More...
def test_success_DML
 Check right DML statement. More...
def test_failed_DML
 Check wrong DML statement. More...
def test_zero_division
 Check zero division exception. More...
def test_double_init
 Check double init exception. More...


string data_path = "dbe_test_data"
 engine = None

Function Documentation

def test_exceptions.test_double_init ( )

Check double init exception.

Definition at line 70 of file

71 def test_double_init():
72  with pytest.raises(RuntimeError) as excinfo:
73  engine = dbe.PyDbEngine()
74  assert "already initialized" in str(excinfo.value)
def test_double_init
Check double init exception.
def test_exceptions.test_failed_DDL ( )

Check creating a duplicate table.

Definition at line 42 of file

43 def test_failed_DDL():
44  with pytest.raises(RuntimeError) as excinfo:
45  engine.executeDDL("create table test (x int not null, w tinyint, y int, z text)")
46  assert "already exists" in str(excinfo.value)
def test_failed_DDL
Check creating a duplicate table.
def test_exceptions.test_failed_DML ( )

Check wrong DML statement.

Definition at line 58 of file

59 def test_failed_DML():
60  with pytest.raises(RuntimeError) as excinfo:
61  cursor = engine.executeDML("selectTT * from test")
62  assert "SQL Error" in str(excinfo.value)
def test_failed_DML
Check wrong DML statement.
def test_exceptions.test_failed_init ( )

Check init with wrong parameter.

Definition at line 16 of file

17 def test_failed_init():
18  global engine
19  try:
20  shutil.rmtree(data_path)
21  except FileNotFoundError:
22  pass
24  with pytest.raises(RuntimeError) as excinfo:
25  engine = dbe.PyDbEngine(data='/' + data_path, calcite_port=9091)
26  assert "Permission denied" in str(excinfo.value)
def test_failed_init
Check init with wrong parameter.
def test_exceptions.test_success_DDL ( )

Check DDL statement.

Definition at line 36 of file

37 def test_success_DDL():
38  engine.executeDDL("drop table if exists test")
39  engine.executeDDL("create table test (x int not null, w tinyint, y int, z text)")
40  assert engine.get_tables() == ['test']
def test_success_DDL
Check DDL statement.
def test_exceptions.test_success_DML ( )

Check right DML statement.

Definition at line 48 of file

49 def test_success_DML():
50  engine.executeDML("insert into test values(55,5,3,'la-la-la')")
51  engine.executeDML("insert into test values(66,6,1, 'aa')")
52  engine.executeDML("insert into test values(77,7,0,'bb')")
53  dframe = engine.select_df("select * from test")
54  dforig = pandas.DataFrame({'x': [55,66,77], 'w': [5,6,7], 'y': [3,1,0], 'z': ['la-la-la', 'aa', 'bb']})
55  dforig = dforig.astype(dtype= {"x":"int32", "w":"int8","y":"int32", "z":"category"})
56  assert dframe.equals(dforig)
def test_success_DML
Check right DML statement.
def test_exceptions.test_success_init ( )

Check init with right parameters.

Definition at line 28 of file

29 def test_success_init():
30  global engine
31  engine = dbe.PyDbEngine(data=data_path, calcite_port=9091)
32  assert bool(engine.closed) == False
def test_success_init
Check init with right parameters.
def test_exceptions.test_zero_division ( )

Check zero division exception.

Definition at line 64 of file

65 def test_zero_division():
66  with pytest.raises(RuntimeError) as excinfo:
67  cursor = engine.executeDML("SELECT x / (x - x) FROM test")
68  assert "Division by zero" in str(excinfo.value)
def test_zero_division
Check zero division exception.

Variable Documentation

string test_exceptions.data_path = "dbe_test_data"

Definition at line 13 of file

Referenced by DBHandler.initialize(), main(), and CommandLineOptions.validate().

test_exceptions.engine = None

Definition at line 33 of file

Referenced by EmbeddedDatabase::DBEngine.create(), EmbeddedDatabase::DBEngine.executeDDL(), EmbeddedDatabase::DBEngine.executeDML(), EmbeddedDatabase::DBEngine.executeRA(), EmbeddedDatabase::DBEngine.getTableDetails(), EmbeddedDatabase::DBEngine.getTables(), EmbeddedDatabase::DBEngine.importArrowTable(), EmbeddedDatabase::DBEngine.login(), and EmbeddedDatabase::DBEngine.setDatabase().