Fix T104 for scenario test subdirs

This commit fixes the T104 hacking check to handle subdirs in the
scenario tests. Previously the check assumed that all the scenario
tests were in the scenario dir. However, this isn't necessarily the
case. For example, the heat scenario tests are all in the path:
tempest/scenario/orchestration which means they were excluded from
the T104 check. This commit fixes the oversight and adds unit tests
to cover this condition.

Change-Id: I42d7f22f6194f624f8488493de29e60ff19d211a
This commit is contained in:
Matthew Treinish 2014-06-19 10:18:05 -04:00
parent 787852ffca
commit b12ad76433
2 changed files with 7 additions and 1 deletions

View File

@ -50,7 +50,7 @@ def scenario_tests_need_service_tags(physical_line, filename,
T104: Scenario tests require a services decorator
"""
if 'tempest/scenario/test_' in filename:
if 'tempest/scenario/' in filename and '/test_' in filename:
if TEST_DEFINITION.match(physical_line):
if not SCENARIO_DECORATOR.match(previous_logical):
return (physical_line.find('def'),

View File

@ -70,9 +70,15 @@ class HackingTestCase(base.TestCase):
self.assertFalse(checks.scenario_tests_need_service_tags(
'def test_fake_test:', './tempest/api/compute/test_fake.py',
"@test.services('image')"))
self.assertFalse(checks.scenario_tests_need_service_tags(
'def test_fake:', './tempest/scenario/orchestration/test_fake.py',
"@test.services('compute')"))
self.assertTrue(checks.scenario_tests_need_service_tags(
'def test_fake_test:', './tempest/scenario/test_fake.py',
'\n'))
self.assertTrue(checks.scenario_tests_need_service_tags(
'def test_fake:', './tempest/scenario/orchestration/test_fake.py',
"\n"))
def test_no_vi_headers(self):
# NOTE(mtreinish) The lines parameter is used only for finding the