If no command is specified, print collected data as json
This commit is contained in:
parent
75d178083d
commit
312592d3db
@ -101,6 +101,9 @@ def __main__():
|
||||
logger.info("Executing %s" % CONF.command)
|
||||
subprocess.call(CONF.command, env=env, shell=True)
|
||||
commit_cache('ec2')
|
||||
else:
|
||||
content = {'ec2': ec2_content}
|
||||
print json.dumps(content, indent=1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -18,6 +18,7 @@ import json
|
||||
import os
|
||||
from oslo.config import cfg
|
||||
import testtools
|
||||
from testtools import matchers
|
||||
|
||||
from os_collect_config import collect
|
||||
from os_collect_config.tests import test_ec2
|
||||
@ -70,6 +71,22 @@ class TestCollect(testtools.TestCase):
|
||||
|
||||
self.assertTrue(self.called_fake_call)
|
||||
|
||||
def test_main_no_command(self):
|
||||
fake_args = [
|
||||
'os-collect-config',
|
||||
'--config-file',
|
||||
'/dev/null',
|
||||
]
|
||||
self.useFixture(
|
||||
fixtures.MonkeyPatch('sys.argv', fake_args))
|
||||
output = self.useFixture(fixtures.ByteStream('stdout'))
|
||||
self.useFixture(
|
||||
fixtures.MonkeyPatch('sys.stdout', output.stream))
|
||||
collect.__main__()
|
||||
out_struct = json.loads(output.stream.getvalue())
|
||||
self.assertThat(out_struct, matchers.IsInstance(dict))
|
||||
self.assertIn('ec2', out_struct)
|
||||
|
||||
|
||||
class TestConf(testtools.TestCase):
|
||||
def test_setup_conf(self):
|
||||
|
Loading…
Reference in New Issue
Block a user