Exemplo n.º 1
0
 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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
    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()
Exemplo n.º 6
0
    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()
Exemplo n.º 7
0
 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))
Exemplo n.º 8
0
 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))
Exemplo n.º 9
0
 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))
Exemplo n.º 10
0
 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))
Exemplo n.º 11
0
 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))
Exemplo n.º 12
0
    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)
Exemplo n.º 13
0
    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)
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
 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)
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 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']))
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
    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}$')
Exemplo n.º 20
0
 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']))
Exemplo n.º 21
0
    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}$')
Exemplo n.º 22
0
 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']))
Exemplo n.º 23
0
 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']))
Exemplo n.º 24
0
 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)
Exemplo n.º 25
0
 def tearDown(self):
     sys.stdout = self.held
     DataLayer.disconnect()
Exemplo n.º 26
0
 def test2(self):
     """
     Test constant __LINE__. Must return line number in the source code.
     """
     ret = DataLayer.tst_magic_constant02()
     self.assertEqual(8, int(ret))
Exemplo n.º 27
0
 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)
Exemplo n.º 28
0
 def tearDown(self):
     sys.stdout = self.held
     DataLayer.disconnect()
Exemplo n.º 29
0
 def test2(self):
     """
     Stored routine with designation type row0 must return 1 row.
     """
     ret = DataLayer.tst_test_row0a(1)
     self.assertIsInstance(ret, dict)
Exemplo n.º 30
0
 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)
Exemplo n.º 31
0
 def test1(self):
     """
     Test constant __ROUTINE__. Must return name of routine.
     """
     ret = DataLayer.tst_magic_constant01()
     self.assertEqual('tst_magic_constant01', ret)
Exemplo n.º 32
0
 def test1(self):
     """
     Stored routine with designation type row0 must return null.
     """
     ret = DataLayer.tst_test_row0a(0)
     self.assertIsNone(ret)
Exemplo n.º 33
0
 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)
Exemplo n.º 34
0
 def test1(self):
     """
     Test constant __ROUTINE__. Must return name of routine.
     """
     ret = DataLayer.tst_magic_constant01()
     self.assertEqual('tst_magic_constant01', ret)
Exemplo n.º 35
0
 def test2(self):
     """
     Stored routine with designation type row0 must return 1 row.
     """
     ret = DataLayer.tst_test_row0a(1)
     self.assertIsInstance(ret, dict)
Exemplo n.º 36
0
 def test2(self):
     """
     Test constant __LINE__. Must return line number in the source code.
     """
     ret = DataLayer.tst_magic_constant02()
     self.assertEqual(8, int(ret))
Exemplo n.º 37
0
 def test1(self):
     """
     Stored routine with designation type row0 must return null.
     """
     ret = DataLayer.tst_test_row0a(0)
     self.assertIsNone(ret)
Exemplo n.º 38
0
 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)
Exemplo n.º 39
0
 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))