~axino/mojo/devel

« back to all changes in this revision

Viewing changes to mojo/tests/test_juju2.py

  • Committer: mergebot at canonical
  • Author(s): "Tom Haddon"
  • Date: 2021-04-15 12:46:23 UTC
  • mfrom: (585.1.3 error-on-deploy)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20210415124623-vkut2l891llb0wbd
Correctly deal with output from juju status, fixes lp#1902546

Reviewed-on: https://code.launchpad.net/~mthaddon/mojo/error-on-deploy/+merge/401190
Reviewed-by: Benjamin Allot <benjamin.allot@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
            # First check with no environment set
232
232
            no_env_status = mojo.juju.status.Juju2Status(command_timeout=None)
233
233
            no_env_status.status()
234
 
            mock_check_output.assert_called_with([JUJU_PATH, "status", "--format=yaml"], universal_newlines=True)
 
234
            mock_check_output.assert_called_with([JUJU_PATH, "status", "--format=yaml"])
235
235
            # Second test with an environment set
236
236
            env_status = mojo.juju.status.Juju2Status(environment="test-env")
237
237
            env_status.status()
246
246
                    "--format=yaml",
247
247
                    "-m",
248
248
                    "test-env",
249
 
                ],
250
 
                universal_newlines=True,
 
249
                ]
251
250
            )
252
251
 
253
252
        with mock.patch("subprocess.check_output") as mock_check_output:
262
261
            self.status._cached_status = "Something"
263
262
            self.status.status(force_update=True)
264
263
            mock_check_output.assert_called_with(
265
 
                ["/usr/bin/timeout", "--kill-after", "5", "600", JUJU_PATH, "status", "--format=yaml"],
266
 
                universal_newlines=True,
 
264
                ["/usr/bin/timeout", "--kill-after", "5", "600", JUJU_PATH, "status", "--format=yaml"]
267
265
            )
268
266
            self.assertFalse(self.status._cached_status)
269
267
 
425
423
        """command succeeds within timeout -> returns output, no exception"""
426
424
 
427
425
        command = ["/bin/echo", "blorp"]
428
 
        check_output_mock.return_value = "blorp"
 
426
        check_output_mock.return_value = b"blorp"
429
427
 
430
428
        self.assertEqual(
431
429
            mojo.juju.status.check_output_with_timeout(