def test_check_characters(self): """Test character check.""" c1 = EqualsCondition("c", "d", "e", rdflib.XSD.string) c2 = EqualsCondition("c;", "d", "e", rdflib.XSD.string) c3 = EqualsCondition("c", "d;", "e", rdflib.XSD.string) c4 = JoinCondition("g", "h", "i", "j") c5 = JoinCondition("g;", "h", "i", "j") c6 = JoinCondition("g", "h;", "i", "j") c7 = JoinCondition("g", "h", "i;", "j") c8 = JoinCondition("g", "h", "i", "j;") x = {"key": ["a", ("b", AndCondition(c1, c4))]} x1 = {"key;": ["a", ("b", AndCondition(c1, c4))]} x2 = {"key": ["a;", ("b", AndCondition(c1, c4))]} x3 = {"key": ["a", ("b;", AndCondition(c1, c4))]} x4 = {"key": ["a", ("b", AndCondition(c2, c4))]} x5 = {"key": ["a", ("b", AndCondition(c3, c4))]} x6 = {"key": ["a", ("b", AndCondition(c1, c5))]} x7 = {"key": ["a", ("b", AndCondition(c1, c6))]} x8 = {"key": ["a", ("b", AndCondition(c1, c7))]} x9 = {"key": ["a", ("b", AndCondition(c1, c8))]} check_characters(x) self.assertRaises(ValueError, check_characters, x1) self.assertRaises(ValueError, check_characters, x2) self.assertRaises(ValueError, check_characters, x3) self.assertRaises(ValueError, check_characters, x4) self.assertRaises(ValueError, check_characters, x5) self.assertRaises(ValueError, check_characters, x6) self.assertRaises(ValueError, check_characters, x7) self.assertRaises(ValueError, check_characters, x8) self.assertRaises(ValueError, check_characters, x9)
def _do_db_create(self, table_name, columns, datatypes, primary_key, generate_pk, foreign_key, indexes): """Call db_create but expand the vectors first.""" columns, datatypes = expand_vector_cols(columns, datatypes) check_characters(table_name, columns, datatypes, primary_key, foreign_key, indexes) self._db_create(table_name, columns, datatypes, primary_key, generate_pk, foreign_key, indexes)
def _do_db_insert(self, table_name, columns, values, datatypes): """Call db_insert but expand vectors.""" columns, datatypes, values = expand_vector_cols( columns, datatypes, values) values = [ convert_from(v, datatypes.get(c)) for c, v in zip(columns, values) ] check_characters(table_name, columns, datatypes) return self._db_insert(table_name, columns, values, datatypes)
def _do_db_update(self, table_name, columns, values, condition, datatypes): """Call db_update but expand vectors.""" columns, datatypes, values = expand_vector_cols( columns, datatypes, values) condition = expand_vector_condition(condition) values = [ convert_from(v, datatypes.get(c)) for c, v in zip(columns, values) ] check_characters(table_name, columns, condition, datatypes) self._db_update(table_name, columns, values, condition, datatypes)
def _do_db_delete(self, table_name, condition): """Call _db_delete but expand vectors.""" check_characters(table_name, condition) condition = expand_vector_condition(condition) self._db_delete(table_name, condition)
def _do_db_drop(self, table_name): """Call _db_drop but check the characters first.""" check_characters(table_name) self._db_drop(table_name, )