def get_host_value():
    stdout_save = sys.stdout
    stream = cStringIO.StringIO()
    sys.stdout = stream
    echo_setting('host')
    sys.stdout = stdout_save
    variable = stream.getvalue()
    return variable[6:].strip('\n')
def get_tower_cli_config(key):
    stdout_save = sys.stdout
    stream = cStringIO.StringIO()
    sys.stdout = stream
    echo_setting(key)
    sys.stdout = stdout_save
    printed_str = stream.getvalue()
    return_str = printed_str.strip('\n')
    return_str = return_str[return_str.index(':')+1:]
    return return_str
Beispiel #3
0
 def test_echo_setting(self):
     """Establish that the `echo_setting` method works in the way
     that we expect.
     """
     with settings.runtime_values(host='20.12.4.21'):
         with mock.patch.object(click, 'secho') as secho:
             echo_setting('host')
             self.assertEqual(secho.mock_calls, [
                 mock.call('host: ', fg='magenta', bold=True, nl=False),
                 mock.call('20.12.4.21', fg='white', bold=True),
             ])
 def test_echo_setting(self):
     """Establish that the `echo_setting` method works in the way
     that we expect.
     """
     with settings.runtime_values(host='20.12.4.21'):
         with mock.patch.object(click, 'secho') as secho:
             echo_setting('host')
             self.assertEqual(secho.mock_calls, [
                 mock.call('host: ', fg='magenta', bold=True, nl=False),
                 mock.call('20.12.4.21', fg='white', bold=True),
             ])