Ejemplo n.º 1
0
 def test_null_foreign_keys(self):
     src = Db(self.source_sqla, dummy_args)
     dest = Db(self.dest_sqla, dummy_args)
     src.assign_target(dest)
     src.create_subset_in(dest)
     zeppelins = self.dest_db.execute("SELECT * FROM zeppelins").fetchall()
     self.assertEqual(len(zeppelins), 1)
Ejemplo n.º 2
0
 def test_full_tables(self):
     args_with_full = DummyArgs()
     args_with_full.full_tables = ['city',]
     src = Db(self.source_sqla, args_with_full)
     dest = Db(self.dest_sqla, args_with_full)
     src.assign_target(dest)
     src.create_subset_in(dest)
     cities = self.dest_db.execute("SELECT * FROM city").fetchall()
     self.assertEqual(len(cities), 4)
Ejemplo n.º 3
0
 def test_exclude_tables(self):
     args_with_exclude = DummyArgs()
     args_with_exclude.exclude_tables = ['zeppelins',]
     src = Db(self.source_sqla, args_with_exclude)
     dest = Db(self.dest_sqla, args_with_exclude)
     src.assign_target(dest)
     src.create_subset_in(dest)
     zeppelins = self.dest_db.execute("SELECT * FROM zeppelins").fetchall()
     self.assertEqual(len(zeppelins), 0)
Ejemplo n.º 4
0
 def test_parents_kept(self):
     src = Db(self.source_sqla, dummy_args)
     dest = Db(self.dest_sqla, dummy_args)
     src.assign_target(dest)
     src.create_subset_in(dest)
     cities = self.dest_db.execute("SELECT * FROM city").fetchall()
     self.assertEqual(len(cities), 1)
     joined = self.dest_db.execute("""SELECT c.name, s.name
                                      FROM city c JOIN state s
                                                  ON (c.state_abbrev = s.abbrev)""")
     joined = joined.fetchall()
     self.assertEqual(len(joined), 1)
Ejemplo n.º 5
0
 def test_tables_and_exclude_tables(self):
     args_with_tables_and_exclude_tables = DummyArgs()
     args_with_tables_and_exclude_tables.tables = ['state', 'city']
     args_with_tables_and_exclude_tables.exclude_tables = ['city']
     src = Db(self.source_sqla, args_with_tables_and_exclude_tables)
     dest = Db(self.dest_sqla, args_with_tables_and_exclude_tables)
     src.assign_target(dest)
     src.create_subset_in(dest)
     states = self.dest_db.execute("SELECT * FROM state").fetchall()
     self.assertEqual(len(states), 1)
     excluded_tables = ('city', 'landmark', 'languages_better_than_python', 'zeppos', 'zeppelins')
     for table in excluded_tables:
         rows = self.dest_db.execute("SELECT * FROM {}".format(table)).fetchall()
         self.assertEqual(len(rows), 0)