Esempio n. 1
0
 def test_and_or(self):
     s = SQLValidator("height IS NOT NULL and height > 20")
     self.assertTrue(s.valid)
     s = SQLValidator("height IS NOT NULL or height > 20")
     self.assertTrue(s.valid)
     s = SQLValidator("height IS NOT NULL or height > 20 and height < 30")
     self.assertTrue(s.valid)
Esempio n. 2
0
 def test_invalid_sql(self):
     s = SQLValidator("drop table planet_osm_polygon")
     self.assertFalse(s.valid)
     self.assertEqual(s.errors,['SQL could not be parsed.'])
     s = SQLValidator("(drop table planet_osm_polygon)")
     self.assertFalse(s.valid)
     self.assertEqual(s.errors,['SQL could not be parsed.'])
     s = SQLValidator ("")
     self.assertFalse(s.valid)
     self.assertEqual(s.errors,['SQL could not be parsed.'])
     s = SQLValidator("name = 'a name'; blah")
     self.assertFalse(s.valid)
     self.assertEqual(s.errors,['SQL could not be parsed.'])
Esempio n. 3
0
 def test_identifier_list(self):
     s = SQLValidator("natural in ('water','cliff')")
     self.assertTrue(s.valid)
Esempio n. 4
0
 def test_column_names(self):
     s = SQLValidator("(admin IS NOT NULL and level > 4) AND height is not null")
     self.assertTrue(s.valid)
     self.assertEqual(s.column_names,['admin','level','height'])
Esempio n. 5
0
 def test_basic(self):
     s = SQLValidator("name = 'a name'")
     self.assertTrue(s.valid)
Esempio n. 6
0
 def test_colons_etc(self):
     s = SQLValidator("addr:housenumber IS NOT NULL")
     self.assertTrue(s.valid)
     s = SQLValidator("admin_level IS NOT NULL")
     self.assertTrue(s.valid)
Esempio n. 7
0
 def test_parens(self):
     s = SQLValidator("(admin IS NOT NULL and level > 4)")
     self.assertTrue(s.valid)
     s = SQLValidator("(admin IS NOT NULL and level > 4) AND height is not null")
     self.assertTrue(s.valid)
Esempio n. 8
0
 def test_not_null(self):
     s = SQLValidator("height IS NOT NULL")
     self.assertTrue(s.valid)
Esempio n. 9
0
 def test_float_value(self):
     s = SQLValidator("height > 20")
     self.assertTrue(s.valid)