def test_status_messages_are_displayed(self):
     # While running, the script tells the user what is happening.
     printed = []
     main(options=_options(), print=printed.append, juju=noop,
          wait_for_service=noop, wait_for_machine=noop)
     self.assertSequenceEqual(
         printed,
         ['Bootstrapping...',
          'Deploying service...',
          'Setting origin for charm to deploy None',
          'Waiting for service to start...',
          'Exposing the service...'])
 def test_status_messages_are_displayed(self):
     # While running, the script tells the user what is happening.
     printed = []
     main(options=_options(),
          print=printed.append,
          juju=noop,
          wait_for_service=noop,
          wait_for_machine=noop)
     self.assertSequenceEqual(printed, [
         'Bootstrapping...', 'Deploying service...',
         'Setting origin for charm to deploy None',
         'Waiting for service to start...', 'Exposing the service...'
     ])
    def test_providing_a_branch(self):
        # If the user provides a branch name on the command line, it will be
        # passed to the charm.
        printed = []

        main(options=_options(origin='lp:foo'), print=printed.append,
             juju=noop, wait_for_service=noop, make_config_file=MakeConfigFile,
             wait_for_machine=noop, make_environments_yaml=noop)
        options = MakeConfigFile.options
        self.assertSequenceEqual(
            printed,
            ['Bootstrapping...',
             'Deploying service...',
             'Setting origin for charm to deploy lp:foo',
             'Waiting for service to start...',
             'Exposing the service...'])
        self.assertIn('juju-gui-source', options)
        self.assertEqual('lp:foo', options['juju-gui-source'])
    def test_config_file(self):
        # A charm config file is correctly created.
        juju_commands = []

        def juju(s):
            juju_commands.append(s)

        main(options=_options(origin='lp:foo'), print=noop, juju=juju,
             wait_for_service=noop, make_config_file=MakeConfigFile,
             wait_for_machine=noop, make_environments_yaml=noop)
        options = MakeConfigFile.options
        deploy_command = juju_commands[1]
        self.assertIn('--config my-config-file.yaml', deploy_command)
        self.assertDictEqual(
            {'serve-tests': True,
             'staging': True,
             'juju-gui-source': 'lp:foo',
             'secure': False},
            options)
    def test_providing_a_branch(self):
        # If the user provides a branch name on the command line, it will be
        # passed to the charm.
        printed = []

        main(options=_options(origin='lp:foo'),
             print=printed.append,
             juju=noop,
             wait_for_service=noop,
             make_config_file=MakeConfigFile,
             wait_for_machine=noop,
             make_environments_yaml=noop)
        options = MakeConfigFile.options
        self.assertSequenceEqual(printed, [
            'Bootstrapping...', 'Deploying service...',
            'Setting origin for charm to deploy lp:foo',
            'Waiting for service to start...', 'Exposing the service...'
        ])
        self.assertIn('juju-gui-source', options)
        self.assertEqual('lp:foo', options['juju-gui-source'])
    def test_config_file(self):
        # A charm config file is correctly created.
        juju_commands = []

        def juju(s):
            juju_commands.append(s)

        main(options=_options(origin='lp:foo'),
             print=noop,
             juju=juju,
             wait_for_service=noop,
             make_config_file=MakeConfigFile,
             wait_for_machine=noop,
             make_environments_yaml=noop)
        options = MakeConfigFile.options
        deploy_command = juju_commands[1]
        self.assertIn('--config my-config-file.yaml', deploy_command)
        self.assertDictEqual(
            {
                'serve-tests': True,
                'staging': True,
                'juju-gui-source': 'lp:foo',
                'secure': False
            }, options)