def testPathAcceptedFileStorageDisabled(self): acceptance_fn = mock.Mock() init_fn = mock.Mock() self.enableFileStorage(False) file_storage_dir = bootstrap._PrepareFileStorage( self.enabled_disk_templates, self.tmpdir, acceptance_fn=acceptance_fn, init_fn=init_fn) self.assertEqual(self.tmpdir, file_storage_dir) self.assertFalse(init_fn.called) self.assertFalse(acceptance_fn.called)
def testPathAcceptedFileStorageEnabled(self): acceptance_fn = mock.Mock() init_fn = mock.Mock(return_value=self.tmpdir) self.enableFileStorage(True) file_storage_dir = bootstrap._PrepareFileStorage( self.enabled_disk_templates, self.tmpdir, acceptance_fn=acceptance_fn, init_fn=init_fn) self.assertEqual(self.tmpdir, file_storage_dir) acceptance_fn.assert_called_with(self.tmpdir) init_fn.assert_called_with(self.tmpdir)
def testFallBackToDefaultPathAcceptedFileStorageEnabled(self): expected_file_storage_dir = pathutils.DEFAULT_FILE_STORAGE_DIR acceptance_fn = mock.Mock() init_fn = mock.Mock(return_value=expected_file_storage_dir) self.enableFileStorage(True) file_storage_dir = bootstrap._PrepareFileStorage( self.enabled_disk_templates, None, acceptance_fn=acceptance_fn, init_fn=init_fn) self.assertEqual(expected_file_storage_dir, file_storage_dir) acceptance_fn.assert_called_with(expected_file_storage_dir) init_fn.assert_called_with(expected_file_storage_dir)