Ejemplo n.º 1
0
 def test_function_redefinition(self):
     msg = (
         'Error loading tests/sql/duplicate-name/foo2.sql - a SQL function '
         'named foo was already defined in '
         'tests/sql/duplicate-name/foo.sql.')
     with pytest.raises(ValueError, match=msg):
         compiler.Module('tests/sql/duplicate-name')
Ejemplo n.º 2
0
 def test_multiple_statements_per_file(self):
     m = compiler.Module('tests/sql')
     self.assertEqual(m.basic_statement.name, 'basic_statement')
     self.assertEqual(m.multiline_statement.name, 'multiline_statement')
     self.assertEqual(m.extra_comments.name, 'extra_comments')
     self.assertEqual(m.interstitial_comments.name, 'interstitial_comments')
     self.assertEqual(m.multiline_syntax.name, 'multiline_syntax')
     self.assertIsInstance(m.multiline_syntax.result, statement.Many)
Ejemplo n.º 3
0
 def test_setsattr(self):
     m = compiler.Module('tests/sql')
     self.assertEqual(m.username_for_id.name, 'username_for_id')
Ejemplo n.º 4
0
 def test_add_queries(self):
     m = compiler.Module('tests/sql/mod1')
     m.add_queries('tests/sql/mod2')
     self.assertEqual({'tests/sql/mod1', 'tests/sql/mod2'}, m.sqlpaths)
     self.assertIsInstance(m.scalar, statement.Statement)
     self.assertIsInstance(m.insert, statement.Statement)
Ejemplo n.º 5
0
 def test_dialect_works(self):
     m = compiler.Module('tests/sql')
     m.connect('sqlite:///./tests/data/fixtures.sqlite3')
     self.assertEqual(m._dialect.paramstyle, 'qmark')
Ejemplo n.º 6
0
 def test_dialect_no_connection(self):
     m = compiler.Module('tests/sql')
     with pytest.raises(exceptions.NoConnectionError):
         _ = m._dialect
Ejemplo n.º 7
0
 def test_reserved_function_name(self):
     msg = (
         'Error loading tests/sql/reserved/disconnect.sql - the function '
         'name "disconnect" is reserved. Please choose another name.')
     with pytest.raises(ValueError, match=msg):
         compiler.Module('tests/sql/reserved')
Ejemplo n.º 8
0
 def test_sets_sqlpaths(self):
     m = compiler.Module('tests/sql')
     self.assertEqual({
         'tests/sql',
     }, m.sqlpaths)