handle mixed-language repos packaged as python

The horizon repo and repos for plugins all have package.json but are
packaged using the python tools not npm tools. Assuming we might have
similar cases for puppet modules, this patch updates both cases to
ignore the other language packaging files when setup.py is present.

Change-Id: I61740a01a2289fed6ad5324c53b225d27fd3d6db
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2017-05-24 13:05:38 -04:00
parent 9feb3f8233
commit a5e6f88e12
4 changed files with 33 additions and 0 deletions

View File

@ -18,6 +18,8 @@ import os.path
def looks_like_a_module(workdir, repo): def looks_like_a_module(workdir, repo):
"Does the directory look like it contains an npm module?" "Does the directory look like it contains an npm module?"
if os.path.exists(os.path.join(workdir, repo, 'setup.py')):
return False
return os.path.exists(os.path.join(workdir, repo, 'package.json')) return os.path.exists(os.path.join(workdir, repo, 'package.json'))

View File

@ -18,6 +18,8 @@ import os.path
def looks_like_a_module(workdir, repo): def looks_like_a_module(workdir, repo):
"Does the directory look like it contains a puppet module?" "Does the directory look like it contains a puppet module?"
if os.path.exists(os.path.join(workdir, repo, 'setup.py')):
return False
if not os.path.exists(os.path.join(workdir, repo, 'metadata.json')): if not os.path.exists(os.path.join(workdir, repo, 'metadata.json')):
return False return False
return any([ return any([

View File

@ -48,6 +48,19 @@ class TestModuleDetection(base.BaseTestCase):
'.', 'openstack/monasca-kibana-plugin') '.', 'openstack/monasca-kibana-plugin')
self.assertTrue(is_mod) self.assertTrue(is_mod)
def test_actually_python(self):
def exists(name):
if name.endswith('package.json'):
return True
if name.endswith('setup.py'):
return True
with mock.patch('os.path.exists', exists):
is_mod = npmutils.looks_like_a_module(
'.', 'openstack/monasca-kibana-plugin')
self.assertFalse(is_mod)
class TestGetMetadata(base.BaseTestCase): class TestGetMetadata(base.BaseTestCase):

View File

@ -77,6 +77,22 @@ class TestModuleDetection(base.BaseTestCase):
'.', 'openstack/puppet-watcher') '.', 'openstack/puppet-watcher')
self.assertTrue(is_mod) self.assertTrue(is_mod)
def test_actually_python(self):
def exists(name):
if name.endswith('setup.py'):
return True
if name.endswith('metadata.json'):
return True
if name.endswith('manifests'):
return True
return False
with mock.patch('os.path.exists', exists):
is_mod = puppetutils.looks_like_a_module(
'.', 'openstack/puppet-watcher')
self.assertFalse(is_mod)
class TestGetMetadata(base.BaseTestCase): class TestGetMetadata(base.BaseTestCase):