def test_help(self):
     fake_stdout = StringIO.StringIO()
     with parse_error(self) as fake_stderr:
         with patch("sys.stdout", fake_stdout):
             parse_args(["--help"])
     self.assertEqual("", fake_stderr.getvalue())
     self.assertNotIn("TODO", fake_stdout.getvalue())
 def test_common_args(self):
     args = parse_args(["an-env", "/bin/juju", "/tmp/logs", "an-env-mod"])
     self.assertEqual("an-env", args.env)
     self.assertEqual("/bin/juju", args.juju_bin)
     self.assertEqual("/tmp/logs", args.logs)
     self.assertEqual("an-env-mod", args.temp_env_name)
     self.assertEqual(False, args.debug)
 def test_main(self):
     argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod", "--verbose"]
     args = parse_args(argv)
     with patch("assess_add_credentials.configure_logging",
                autospec=True) as mock_cl:
         with patch("assess_add_credentials.assess_add_credentials",
                    autospec=True) as mock_assess:
             main(argv)
     mock_cl.assert_called_once_with(logging.DEBUG)
     mock_assess.assert_called_once_with(args)
 def test_verify_bootstrap(self):
     argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod", "--verbose"]
     client = Mock(spec=["is_jes_enabled"])
     args = parse_args(argv)
     with patch.dict(os.environ, {'JUJU_DATA': '/', 'HOME': '/'}):
         with patch('shutil.copy', autospec=True, return_value=None):
             with patch(
                     "assess_destroy_model.BootstrapManager.booted_context",
                     autospec=True) as mock_bc:
                 with patch('deploy_stack.client_from_config',
                            return_value=client) as mock_cfc:
                     verify_bootstrap(args)
     mock_cfc.assert_called_once_with('an-env',
                                      "/bin/juju",
                                      debug=False,
                                      soft_deadline=None)
     self.assertEqual(mock_bc.call_count, 1)
 def test_verify_add_credentials(self):
     argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod", "--verbose"]
     args = parse_args(argv)
     cred = dummy_loaded['credentials']['aws']
     with patch('pexpect.spawn', autospec=True) as mock_assess:
         with patch('assess_add_credentials.end_session',
                    return_value=None):
             verify_add_credentials(args, 'aws', cred)
     self.assertEqual([
         call('juju add-credential aws'),
         call().__enter__(),
         call().__enter__().expect('Enter credential name:'),
         call().__enter__().sendline('aws'),
         call().__enter__().expect('Enter access-key:'),
         call().__enter__().sendline('foo'),
         call().__enter__().expect('Enter secret-key:'),
         call().__enter__().sendline('verysecret-key'),
         call().__exit__(None, None, None)
     ], mock_assess.mock_calls)