Fix "-" and "_" samples check

Use old approach instead of I74b37043389927eea95cb1129adf811b62645f70
to check whatever _ are presented in file names.

Current approach doesn't work because it checks full paths instead of
only filenames which may actually include the _ and which is actually
perfectly ok

Change-Id: If2c9aa1698a11f39fc02661de81513e01f7beb6d
This commit is contained in:
Boris Pavlovic 2017-09-07 16:30:40 -07:00
parent 92765e9cd0
commit 62341e1f1c
1 changed files with 10 additions and 8 deletions

View File

@ -150,15 +150,17 @@ class TaskSampleTestCase(test.TestCase):
def test_no_underscores_in_filename(self):
bad_filenames = []
for dirname, dirnames, filenames in os.walk(self.samples_path):
for filename in filenames:
if "_" in filename and (filename.endswith(".yaml") or
filename.endswith(".json")):
full_path = os.path.join(dirname, filename)
bad_filenames.append(full_path)
for path in self.iterate_samples(merge_pairs=False):
if "_" in path:
bad_filenames.append(path)
if bad_filenames:
self.fail("Following sample task filename(s) contain underscores "
"(_) but must use dashes (-) instead: %s" %
bad_filenames)
self.assertEqual([], bad_filenames,
"Following sample task filenames contain "
"underscores (_) but must use dashes (-) instead: "
"{}".format(bad_filenames))
def test_context_samples_found(self):
all_plugins = context.Context.get_all()