Ejemplo n.º 1
0
 def test_no_name(self):
     msg = 'Statement must have a name. In: foo/bar.sql'
     with pytest.raises(ValueError, match=msg):
         Statement(None, 'foo', '', Raw(), 'foo/bar.sql')
Ejemplo n.º 2
0
 def test_sql_none(self):
     msg = 'Statement must have a SQL string. In: foo/bar.sql'
     with pytest.raises(ValueError, match=msg):
         Statement('foo', None, '', Raw(), 'foo/bar.sql')
Ejemplo n.º 3
0
 def test_sets_module(self):
     m = Mock()
     s = Statement('foo', 'select 1', '', Raw())
     s.set_module(m)
     self.assertEqual(m, s._module)
Ejemplo n.º 4
0
 def test_filename(self):
     s = Statement('foo', 'select 1', '', Raw(), 'path/foobar.sql')
     self.assertEqual('path/foobar.sql', s.filename)
Ejemplo n.º 5
0
 def test_sql_whitespace(self):
     with pytest.raises(ValueError, match='SQL string cannot be empty.'):
         Statement('foo', '   ', '', Raw())
Ejemplo n.º 6
0
 def test_result_none(self):
     with pytest.raises(ValueError,
                        match='Statement must have a result type.'):
         Statement('foo', 'select 1', '', None)
Ejemplo n.º 7
0
 def test_sql_none(self):
     with pytest.raises(ValueError,
                        match='Statement must have a SQL string.'):
         Statement('foo', None, '', Raw())
Ejemplo n.º 8
0
 def test_name_empty(self):
     with pytest.raises(ValueError, match='Statement must have a name.'):
         Statement('', 'foo', '', Raw())
Ejemplo n.º 9
0
 def test_no_module(self):
     with pytest.raises(
             RuntimeError,
             match='This statement is not associated with a module'):
         s = Statement('foo', 'select 1', '', Raw())
         s()
Ejemplo n.º 10
0
 def test_result_none(self):
     msg = 'Statement must have a result type. In: foo/bar.sql'
     with pytest.raises(ValueError, match=msg):
         Statement('foo', 'select 1', '', None, 'foo/bar.sql')
Ejemplo n.º 11
0
 def test_sql_empty(self):
     msg = 'SQL string cannot be empty. In: foo/bar.sql'
     with pytest.raises(ValueError, match=msg):
         Statement('foo', '', '', Raw(), 'foo/bar.sql')