Merge "Allow empty directories for tempest init"

This commit is contained in:
Jenkins 2015-11-05 15:03:47 +00:00 committed by Gerrit Code Review
commit 4d91bfe9fc
2 changed files with 5 additions and 3 deletions
tempest

@ -116,9 +116,9 @@ class TempestInit(command.Command):
if not os.path.isdir(local_dir):
LOG.debug('Creating local working dir: %s' % local_dir)
os.mkdir(local_dir)
else:
elif not os.listdir(local_dir) == []:
raise OSError("Directory you are trying to initialize already "
"exists: %s" % local_dir)
"exists and is not empty: %s" % local_dir)
lock_dir = os.path.join(local_dir, 'tempest_lock')
etc_dir = os.path.join(local_dir, 'etc')

@ -58,9 +58,11 @@ class TestTempestInit(base.TestCase):
self.assertTrue(os.path.isfile(local_sample_conf_file))
self.assertGreater(os.path.getsize(local_sample_conf_file), 0)
def test_create_working_dir_with_existing_local_dir(self):
def test_create_working_dir_with_existing_local_dir_non_empty(self):
fake_local_dir = self.useFixture(fixtures.TempDir())
fake_local_conf_dir = self.useFixture(fixtures.TempDir())
open("%s/foo" % fake_local_dir.path, 'w').close()
_init = init.TempestInit(None, None)
self.assertRaises(OSError,
_init.create_working_dir,