def test2(self): """ An exception must be thrown when a stored routine with designation type row1 returns 0 rows. @expectedException Exception """ with self.assertRaises(DataError): DataLayer.tst_test_row1a(0)
def test3(self): """ An exception must be thrown when a stored routine with designation type singleton1 returns more than 1 values. @expectedException Exception """ with self.assertRaises(DataError): DataLayer.tst_test_singleton1a(2)
def test1(self): """ Stored routine with designation type row1 must return 1 row and 1 row only. """ # ??? ret = DataLayer.tst_test_row1a(1) ret = DataLayer.tst_test_row1a(1) self.assertIsInstance(ret, dict)
def setUp(self): DataLayer.config['host'] = 'localhost' DataLayer.config['user'] = '******' DataLayer.config['password'] = '******' DataLayer.config['database'] = 'test' DataLayer.connect() self.held, sys.stdout = sys.stdout, StringIO()
def test2(self): """ Stored routine with designation type rows_with_index must return empty array when no rwos are selected. """ rows = DataLayer.tst_test_rows_with_index1(0) self.assertIsInstance(rows, dict) self.assertEqual(0, len(rows))
def test1(self): """ Stored routine with designation type rows must return an empty array when no rows are selected. """ ret = DataLayer.tst_test_rows1(0) self.assertIsInstance(ret, list) self.assertEqual(0, len(ret))
def test2(self): """ Stored routine with designation type rows_with_key must return empty array when no rows are selected. """ rows = DataLayer.tst_test_rows_with_key1(0) self.assertIsInstance(rows, dict) self.assertEqual(0, len(rows))
def test2(self): """ Stored routine with designation type rows must return an array with 1 row when only 1 row is selected. """ ret = DataLayer.tst_test_rows1(1) self.assertIsInstance(ret, list) self.assertEqual(1, len(ret))
def test3(self): """ Stored routine with designation type rows must return an array with 3 rows when 3 rows are selected. """ ret = DataLayer.tst_test_rows1(3) self.assertIsInstance(ret, list) self.assertEqual(3, len(ret))
def _test1(self): """ Stored routine with designation type table must show table. @todo implement designation type table """ template_table = """ +---------+---------+---------+---------+---------------------+------+------+ | tst_c00 | tst_c01 | tst_c02 | tst_c03 | tst_c04 | t | s | +---------+---------+---------+---------+---------------------+------+------+ | Hello | 1 | 0.543 | 1.23450 | 2014-03-27 00:00:00 | 4444 | 1 | | World | 3 | 0.00003 | 0.00000 | 2014-03-28 00:00:00 | | 1 | +---------+---------+---------+---------+---------------------+------+------+ """ DataLayer.tst_test_table() table = sys.stdout self.assertEqual(table, template_table)
def test4(self): """ Test constant __DIR__. Must return name of the folder where the source file of routine the is located. """ dir_cur_file = os.path.dirname(os.path.abspath(__file__)) dir_name = os.path.realpath(dir_cur_file + '/psql') ret = DataLayer.tst_magic_constant04() self.assertEqual(dir_name, ret)
def test3(self): """ Test constant __FILE__. Must return the filename of the source of the routine. """ dir_cur_file = os.path.dirname(os.path.abspath(__file__)) path = os.path.realpath(dir_cur_file + "/psql/tst_magic_constant03.psql") filename = os.path.realpath(path) ret = DataLayer.tst_magic_constant03() self.assertEqual(filename, ret)
def test1(self): """ Stored routine with designation type rows_with_index must return multi dimensional array. """ rows = DataLayer.tst_test_rows_with_index1(100) self.assertIsInstance(rows, dict) self.assertIn('a', rows) self.assertIn('b', rows['a']) self.assertIsInstance(rows['a']['b'], list) self.assertEqual(3, len(rows['a']['b']))
def test1(self): """ Stored routine with designation type none must return the number of rows affected. """ n = DataLayer.tst_test_log() self.assertEqual(2, n) self.assertRegex(sys.stdout.getvalue(), '^(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\sHello, world\n){2}$')
def test1(self): """ Stored routine with designation type none must return the number of rows affected. """ n = DataLayer.tst_test_log() self.assertEqual(2, n) self.assertRegex( sys.stdout.getvalue(), '^(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\sHello, world\n){2}$')
def test1(self): """ Stored routine with designation type rows_with_key must return multi dimensional array. """ rows = DataLayer.tst_test_rows_with_key1(100) self.assertIsInstance(rows, dict) self.assertEqual(1, len(rows)) self.assertTrue('a' in rows) self.assertTrue('b' in rows['a']) self.assertNotEqual(0, len(rows['a']['b'])) self.assertTrue('c1' in rows['a']['b']) self.assertNotEqual(0, len(rows['a']['b']['c1']))
def test1(self): """ Stored routine with designation type none must return the number of rows affected. """ ret = DataLayer.tst_test_none(0) self.assertEqual(0, ret)
def tearDown(self): sys.stdout = self.held DataLayer.disconnect()
def test2(self): """ Test constant __LINE__. Must return line number in the source code. """ ret = DataLayer.tst_magic_constant02() self.assertEqual(8, int(ret))
def test1(self): """ Stored routine with designation type singleton1 must return 1 value and 1 value only. """ ret = DataLayer.tst_test_singleton1a(1) self.assertEqual(1, ret)
def test2(self): """ Stored routine with designation type row0 must return 1 row. """ ret = DataLayer.tst_test_row0a(1) self.assertIsInstance(ret, dict)
def test1(self): """ Stored routine with designation type function executes a stored function and return result. """ ret = DataLayer.tst_test_function(2, 3) self.assertEqual(5, ret)
def test1(self): """ Test constant __ROUTINE__. Must return name of routine. """ ret = DataLayer.tst_magic_constant01() self.assertEqual('tst_magic_constant01', ret)
def test1(self): """ Stored routine with designation type row0 must return null. """ ret = DataLayer.tst_test_row0a(0) self.assertIsNone(ret)
def test2(self): """ Stored routine with designation type singleton0 must return 1 value. """ ret = DataLayer.tst_test_singleton0a(1) self.assertIsInstance(ret, (str, int, float))