~pjdc/mojo/mojo-project-logging-vs-none

« back to all changes in this revision

Viewing changes to mojo/tests/test_juju1.py

  • Committer: Stuart Bishop
  • Author(s): dan.ryan at canonical
  • Date: 2020-02-24 08:41:42 UTC
  • mfrom: (514.3.18 python3-fixes)
  • Revision ID: stuart@stuartbishop.net-20200224084142-bs7azzfes8ktysum
Python3 support

Reviewed-on: https://code.launchpad.net/~techalchemy/mojo/python3-fixes/+merge/379590
Reviewed-by: Stuart Bishop <stuart.bishop@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright 2014 Canonical Ltd.  This software is licensed under the
2
2
# GNU General Public License version 3 (see the file LICENSE).
3
 
import mock
 
3
from __future__ import absolute_import
4
4
from unittest import TestCase
5
5
 
 
6
import six
6
7
import mojo.juju
7
8
from mojo.tests import utils
 
9
from mojo.shutil_which import get_command
 
10
 
 
11
if six.PY2:
 
12
    import mock
 
13
else:
 
14
    from unittest import mock
 
15
 
 
16
 
 
17
JUJU_PATH, _ = get_command('juju')
8
18
 
9
19
 
10
20
NO_ERROR_STATUS = """environment: openstack
209
219
            no_env_status._get_status()
210
220
            mock_check_output.assert_called_with(
211
221
                ['/usr/bin/timeout', '--kill-after', '5', '600',
212
 
                 'juju', 'status', '--format=yaml'])
 
222
                 JUJU_PATH, 'status', '--format=yaml'], universal_newlines=True)
213
223
            # Second test with an environment set
214
224
            env_status = mojo.juju.status.Juju1Status(environment="test-env")
215
225
            env_status._get_status()
216
226
            mock_check_output.assert_called_with(
217
227
                ['/usr/bin/timeout', '--kill-after', '5', '600',
218
 
                 'juju', 'status', '--format=yaml', '-e', 'test-env'])
 
228
                 JUJU_PATH, 'status', '--format=yaml', '-e', 'test-env'], universal_newlines=True)
219
229
 
220
230
        with mock.patch('subprocess.check_output') as mock_check_output:
221
231
            # Check that if we're calling _get_status where _status_output is
228
238
            self.status._get_status(force_update=True)
229
239
            mock_check_output.assert_called_with(
230
240
                ['/usr/bin/timeout', '--kill-after', '5', '600',
231
 
                 'juju', 'status', '--format=yaml'])
 
241
                 JUJU_PATH, 'status', '--format=yaml'], universal_newlines=True)
232
242
 
233
243
    def test_yaml_status(self):
234
244
        """Test the yaml_status function"""