Exemplo n.º 1
0
 def test_function_redefinition(self):
     msg = (
         'Error loading tests/sql/duplicate-name/foo.sql - a SQL function '
         'named foo was already defined in '
         'tests/sql/duplicate-name/foo2.sql.')
     with pytest.raises(ValueError, match=msg):
         compiler._module('tests/sql/duplicate-name')
Exemplo 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)
Exemplo n.º 3
0
 def test_setsattr(self):
     m = compiler._module('tests/sql')
     self.assertEqual(m.username_for_id.name, 'username_for_id')
Exemplo n.º 4
0
 def test_dialect_works(self):
     m = compiler._module('tests/sql')
     m.connect('sqlite:///./tests/data/fixtures.sqlite3')
     self.assertEqual(m._dialect.paramstyle, 'qmark')
Exemplo n.º 5
0
 def test_dialect_no_connection(self):
     m = compiler._module('tests/sql')
     with pytest.raises(exceptions.NoConnectionError):
         _ = m._dialect
Exemplo n.º 6
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')
Exemplo n.º 7
0
 def test_caches_modules(self):
     self.assertEqual(compiler._module('tests/sql'),
                      compiler._module('tests/sql'))
Exemplo n.º 8
0
 def test_sets_sqlpath(self):
     m = compiler._module('tests/sql')
     self.assertEqual('tests/sql', m.sqlpath)