def testRemoveItems(self): archives = rotatelib.list_archives(s3bucket=TEST_BUCKET_NAME) rotatelib.remove_items(items=archives, s3bucket=TEST_BUCKET_NAME) archives = rotatelib.list_archives(s3bucket=TEST_BUCKET_NAME) self.assertEqual(len(archives), 0) archives = rotatelib.list_archives(s3bucket=TEST_BUCKET_NAME, has_date=False) self.assertEqual(len(archives), 1)
def testRemoveTablesWithPatternCriteria(self): tables = ['tableA', 'tableB', 'tableA20090922T162037', 'steveA20090922T162037', 'table%s' % datetime.date.today().strftime("%Y%m%d")] db = sqlite3.connect(':memory:') self.create_tables(db, tables) tables = rotatelib.list_backup_tables(db, before=datetime.timedelta(1), pattern='steve.*') self.assertEqual(len(tables), 1) rotatelib.remove_items(db=db, items=tables) tables = rotatelib.list_backup_tables(db, before=datetime.timedelta(1)) self.assertEqual(len(tables), 1) cur = db.cursor() cur.execute("SELECT * FROM sqlite_master WHERE type='table'") tables = cur.fetchall() self.assertEqual(len(tables), 4)
def testRemoveTablesWithCriteria(self): tables = [ 'tableA', 'tableB', 'tableA20090922T162037', 'table%s' % datetime.date.today().strftime("%Y%m%d") ] db = sqlite3.connect(':memory:') self.create_tables(db, tables) tables = rotatelib.list_backup_tables(db, before=datetime.timedelta(1)) self.assertEqual(len(tables), 1) rotatelib.remove_items(db=db, items=tables) tables = rotatelib.list_backup_tables(db, before=datetime.timedelta(1)) self.assertEqual(len(tables), 0) cur = db.cursor() cur.execute("SELECT * FROM sqlite_master WHERE type='table'") tables = cur.fetchall() self.assertEqual(len(tables), 3)
def testRemoveItems(self): archives = rotatelib.list_archives(ec2snapshots=True, startswith="rotatelib") self.assertEqual(len(archives), 1) rotatelib.remove_items(items=archives, ec2snapshots=True) archives = rotatelib.list_archives(ec2snapshots=True, startswith="rotatelib") self.assertEqual(len(archives), 0)