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')
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')
def test_sets_module(self): m = Mock() s = Statement('foo', 'select 1', '', Raw()) s.set_module(m) self.assertEqual(m, s._module)
def test_filename(self): s = Statement('foo', 'select 1', '', Raw(), 'path/foobar.sql') self.assertEqual('path/foobar.sql', s.filename)
def test_sql_whitespace(self): with pytest.raises(ValueError, match='SQL string cannot be empty.'): Statement('foo', ' ', '', Raw())
def test_result_none(self): with pytest.raises(ValueError, match='Statement must have a result type.'): Statement('foo', 'select 1', '', None)
def test_sql_none(self): with pytest.raises(ValueError, match='Statement must have a SQL string.'): Statement('foo', None, '', Raw())
def test_name_empty(self): with pytest.raises(ValueError, match='Statement must have a name.'): Statement('', 'foo', '', Raw())
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()
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')
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')