def test_5_drop_table(self): table1 = self.Donkey["moo01%s" % self.randish] assert_raises(custom_exceptions.DependencyError, self.Donkey.drop_table, table1) table2 = self.Donkey["moo02%s" % self.randish] self.Donkey.drop_table(table2) result = validate_database(self.Donkey) assert not any([result[num] for num in range(0,4)]) table4 = self.Donkey["moo04%s" % self.randish] self.Donkey.drop_table(table4) result = validate_database(self.Donkey) assert not any([result[num] for num in range(0,4)]) table1 = self.Donkey["moo01%s" % self.randish] self.Donkey.drop_table(table1) result = validate_database(self.Donkey) assert not any([result[num] for num in range(0,4)])
def test_zz_drop_table(self): self.Donkey.drop_table("moo%s" % self.p) assert "moo%s" % self.p not in self.Donkey.tables assert "_log_moo%s" % self.p not in self.Donkey.tables assert validate_database(self.Donkey)[0] == [] assert validate_database(self.Donkey)[1] == [] assert validate_database(self.Donkey)[2] == []
def test_3_rename_table(self): table1 = tables.Table("to_rename%s" % self.randish, Text("moo")) table2 = tables.Table("to_join%s" % self.randish, Text("moo")) start = datetime.datetime.now() self.Donkey.add_table(table1) self.Donkey.add_table(table2) self.Donkey.persist() table2 = self.Donkey["to_join%s" % self.randish] table2.add_relation(ManyToOne("to_rename%s" % self.randish, "to_rename%s" % self.randish)) self.Donkey.rename_table("to_rename%s" % self.randish, "renamed%s" % self.randish) result = validate_database(self.Donkey) assert not any([result[num] for num in range(0,4)])
def test_z_add_drop_existing_table(self): print self.Donkey.tables.keys() self.Donkey.add_table(tables.Table("moo%s" % self.p, Text("moo%s" % self.p)), drop = True) self.Donkey.persist() print validate_database(self.Donkey) diff = schemadiff.getDiffOfModelAgainstDatabase(self.Donkey.metadata, self.Donkey.engine) print diff assert validate_database(self.Donkey)[0] == [] assert validate_database(self.Donkey)[1] == [] assert validate_database(self.Donkey)[2] == []
def test_7_add_remove_index(self): table1 = self.Donkey["renamed%s" % self.randish] table1.add_index(Index("moooed", "moo")) result = validate_database(self.Donkey) assert not any([result[num] for num in range(0,4)]) table1 = self.Donkey["renamed%s" % self.randish] table1.delete_index("moooed") assert not any([result[num] for num in range(0,4)])
def test_1_add_table(self): self.Donkey.add_table(tables.Table("moo01%s" % self.randish, Text("moo"))) self.Donkey.add_table(tables.Table("moo02%s" % self.randish, Text("moo"))) self.Donkey.add_table(tables.Table("moo03%s" % self.randish, Text("moo"))) self.Donkey.add_table(tables.Table("moo04%s" % self.randish, Text("moo"))) self.Donkey.persist() self.Donkey.load_from_persist(True) result = validate_database(self.Donkey) print result assert not any([result[num] for num in range(0,4)])
table1 = tables.Table("rename_field", Text("man"), Text("moo"), Integer("man2"), Text("man3"), Text("man4")) self.Donkey.add_table(table1) self.Donkey.persist() if self.Donkey.engine.name == "sqlite": assert_raises(Exception, table1.rename_field, "moo", "mooed") return print [a.name for a in table1.ordered_user_fields] assert [a.name for a in table1.ordered_user_fields] == ["man", "moo", "man2", "man3", "man4"] table1.rename_field("moo", "mooed") result = validate_database(self.Donkey) assert not any([result[num] for num in range(0,4)]) table1.drop_field("man") result = validate_database(self.Donkey) assert not any([result[num] for num in range(0,4)]) table1 = self.Donkey["rename_field"] table1.alter_field("man2", type = "Text", nullable = False, default = "wee", validation = "Email") table1 = self.Donkey["rename_field"]