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

Functions

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...
 

Variables

string data_path = "test_dbe_data"
 
 engine = None
 

Function Documentation

def test_exceptions.test_double_init ( )

Check double init exception.

Definition at line 69 of file test_exceptions.py.

69 
70 def test_double_init():
71  with pytest.raises(RuntimeError) as excinfo:
72  engine = dbe.PyDbEngine()
73  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 41 of file test_exceptions.py.

41 
42 def test_failed_DDL():
43  with pytest.raises(RuntimeError) as excinfo:
44  engine.executeDDL("create table test (x int not null, w tinyint, y int, z text)")
45  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 57 of file test_exceptions.py.

57 
58 def test_failed_DML():
59  with pytest.raises(RuntimeError) as excinfo:
60  cursor = engine.executeDML("selectTT * from test")
61  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 15 of file test_exceptions.py.

15 
16 def test_failed_init():
17  global engine
18  try:
19  shutil.rmtree(data_path)
20  except FileNotFoundError:
21  pass
22 
23  with pytest.raises(RuntimeError) as excinfo:
24  engine = dbe.PyDbEngine(data='/'+data_path, calcite_port=9091)
25  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 35 of file test_exceptions.py.

35 
36 def test_success_DDL():
37  engine.executeDDL("drop table if exists test")
38  engine.executeDDL("create table test (x int not null, w tinyint, y int, z text)")
39  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 47 of file test_exceptions.py.

47 
48 def test_success_DML():
49  engine.executeDML("insert into test values(55,5,3,'la-la-la')")
50  engine.executeDML("insert into test values(66,6,1, 'aa')")
51  engine.executeDML("insert into test values(77,7,0,'bb')")
52  dframe = engine.select_df("select * from test")
53  dforig = pandas.DataFrame({'x': [55,66,77], 'w': [5,6,7], 'y': [3,1,0], 'z': ['la-la-la', 'aa', 'bb']})
54  dforig = dforig.astype(dtype= {"x":"int32", "w":"int8","y":"int32", "z":"category"})
55  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 27 of file test_exceptions.py.

27 
28 def test_success_init():
29  global engine
30  engine = dbe.PyDbEngine(data=data_path, calcite_port=9091)
31  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 63 of file test_exceptions.py.

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

Variable Documentation

string test_exceptions.data_path = "test_dbe_data"

Definition at line 13 of file test_exceptions.py.

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

test_exceptions.engine = None

Definition at line 32 of file test_exceptions.py.

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().