def test_remove_older_1(self): clone = None try: manager = Manager(directory) except ZCMError as e: self.fail('Instantiation should not raise exceptions') try: manager.clone() except ZCMError as e: self.fail('Creation should not raise exceptions') try: manager.activate('00000001') except ZCMError as e: self.fail('Creation should not raise exceptions') try: manager.remove('00000000') except ZCMError as e: self.fail('Creation should not raise exceptions') self.assertEqual(manager.path, Path(directory)) self.assertEqual(manager.zfs, zfs) self.assertEqual(manager.active_clone, manager.clones[0]) self.assertEqual(manager.next_id, '00000002') self.assertEqual(len(manager.older_clones), 0) self.assertEqual(len(manager.newer_clones), 0) filesystem = zfs path = Path(directory, '.clones') self.assertTrue(zfs_is_filesystem(filesystem)) self.assertEqual(zfs_get(filesystem, 'mountpoint'), path) self.assertTrue(zfs_get(filesystem, 'mounted')) self.assertTrue(path.is_dir()) id = '00000000' filesystem = '%s/%s' % (zfs, id) path = Path(directory, '.clones', id) self.assertFalse(zfs_exists(filesystem)) self.assertFalse(path.exists()) id = '00000001' filesystem = '%s/%s' % (zfs, id) path = Path(directory) self.assertEqual(manager.clones[0].id, id) self.assertEqual(manager.clones[0].zfs, filesystem) self.assertIsNone(manager.clones[0].origin) self.assertIsNone(manager.clones[0].origin_id) self.assertEqual(manager.clones[0].mountpoint, path) self.assertIsInstance(manager.clones[0].creation, datetime) self.assertTrue(zfs_is_filesystem(filesystem)) self.assertEqual(zfs_get(filesystem, 'mountpoint'), path) self.assertTrue(zfs_get(filesystem, 'mounted')) self.assertTrue(path.is_dir())
def test_initialize(self): with self.assertRaises(ZCMError): Manager.initialize_manager(zfs, directory) clone = None try: manager = Manager(directory) except ZCMError as e: self.fail('Instantiation should not raise exceptions') self.assertEqual(manager.path, Path(directory)) self.assertEqual(manager.zfs, zfs) self.assertEqual(manager.active_clone, manager.clones[0]) self.assertEqual(manager.next_id, '00000001') self.assertEqual(len(manager.older_clones), 0) self.assertEqual(len(manager.newer_clones), 0) filesystem = zfs path = Path(directory, '.clones') self.assertTrue(zfs_is_filesystem(filesystem)) self.assertEqual(zfs_get(filesystem, 'mountpoint'), path) self.assertTrue(zfs_get(filesystem, 'mounted')) self.assertTrue(path.is_dir()) id = '00000000' filesystem = '%s/%s' % (zfs, id) path = Path(directory) self.assertEqual(manager.clones[0].id, id) self.assertEqual(manager.clones[0].zfs, filesystem) self.assertIsNone(manager.clones[0].origin) self.assertIsNone(manager.clones[0].origin_id) self.assertEqual(manager.clones[0].mountpoint, path) self.assertIsInstance(manager.clones[0].creation, datetime) self.assertTrue(zfs_is_filesystem(filesystem)) self.assertEqual(zfs_get(filesystem, 'mountpoint'), path) self.assertTrue(zfs_get(filesystem, 'mounted')) self.assertTrue(path.is_dir())