コード例 #1
0
    def test_delete_only_inactive(self, add_access, clean_up, detach_disk, destroy):
        self.assertTrue(purge_unused_exports())

        add_access.assert_called_once_with(self.export, self.export.host)
        clean_up.assert_called_once_with(self.export)
        detach_disk.assert_called_once_with(self.export)
        destroy.assert_called_once_with(self.export)
コード例 #2
0
    def test_task_with_error(self, add_access):
        add_access.side_effect = Exception('Fake error')

        task = mommy.make('TaskHistory')
        self.assertIsNone(task.details)
        self.assertFalse(purge_unused_exports(task))
        self.assertIn('Removing: {}'.format(self.export), task.details)
        self.assertIn('Error: Fake error'.format(self.export), task.details)
コード例 #3
0
    def test_task_with_error(self, add_access):
        add_access.side_effect = Exception('Fake error')

        task = TaskHistoryFactory()
        self.assertIsNone(task.details)
        self.assertFalse(purge_unused_exports(task))
        self.assertIn('Removing: {}'.format(self.export), task.details)
        self.assertIn('Error: Fake error'.format(self.export), task.details)
コード例 #4
0
    def test_can_delete_inactive_with_inactive_snapshot(
            self, add_access, clean_up, destroy):
        mommy.make('Snapshot',
                   instance=self.instance,
                   volume=self.export,
                   purge_at=datetime.now())

        self.assertTrue(purge_unused_exports())

        add_access.assert_called_once_with(self.export, self.export.host)
        clean_up.assert_called_once_with(self.export)
        destroy.assert_called_once_with(self.export)
コード例 #5
0
    def test_can_delete_inactive_with_inactive_snapshot(
            self, add_access, clean_up, destroy):
        snapshot = SnapshotFactory(instance=self.instance)
        snapshot.volume = self.export
        snapshot.purge_at = datetime.now()
        snapshot.save()

        self.assertTrue(purge_unused_exports())

        add_access.assert_called_once_with(self.export, self.export.host)
        clean_up.assert_called_once_with(self.export)
        destroy.assert_called_once_with(self.export)
コード例 #6
0
    def test_can_delete_inactive_with_inactive_snapshot(
        self, add_access, clean_up, destroy
    ):
        snapshot = SnapshotFactory(instance=self.instance)
        snapshot.volume = self.export
        snapshot.purge_at = datetime.now()
        snapshot.save()

        self.assertTrue(purge_unused_exports())

        add_access.assert_called_once_with(self.export, self.export.host)
        clean_up.assert_called_once_with(self.export)
        destroy.assert_called_once_with(self.export)
コード例 #7
0
 def test_task_with_success(self):
     task = mommy.make('TaskHistory')
     self.assertIsNone(task.details)
     self.assertTrue(purge_unused_exports(task))
     self.assertIn('Removing: {}'.format(self.export), task.details)
     self.assertIn('Success', task.details)
コード例 #8
0
 def test_task_with_success(self):
     task = TaskHistoryFactory()
     self.assertIsNone(task.details)
     self.assertTrue(purge_unused_exports(task))
     self.assertIn('Removing: {}'.format(self.export), task.details)
     self.assertIn('Success', task.details)
コード例 #9
0
    def test_delete_only_inactive(self, add_access, clean_up, destroy):
        self.assertTrue(purge_unused_exports())

        add_access.assert_called_once_with(self.export, self.export.host)
        clean_up.assert_called_once_with(self.export)
        destroy.assert_called_once_with(self.export)