Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(642)

Side by Side Diff: juju/control/tests/test_control.py

Issue 5845061: juju/control should be aware of subordinates
Patch Set: juju/control should be aware of subordinates Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « juju/control/tests/test_constraints_set.py ('k') | juju/control/tests/test_debug_hooks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import logging 1 import logging
2 import time 2 import time
3 import os 3 import os
4 4
5 from StringIO import StringIO 5 from StringIO import StringIO
6 from argparse import Namespace 6 from argparse import Namespace
7 from yaml import dump
8 7
9 from twisted.internet.defer import inlineCallbacks 8 from twisted.internet.defer import inlineCallbacks
10 9
11 from juju.environment.errors import EnvironmentsConfigError 10 from juju.environment.errors import EnvironmentsConfigError
12 from juju.control import setup_logging, main, setup_parser 11 from juju.control import setup_logging, main, setup_parser
13 from juju.control.options import ensure_abs_path 12 from juju.control.options import ensure_abs_path
14 from juju.control.command import Commander 13 from juju.control.command import Commander
14 from juju.state.tests.common import StateTestBase
15 15
16 from juju.lib.testing import TestCase 16 from juju.lib.testing import TestCase
17 17
18 from .common import ControlToolTest 18 from .common import ControlToolTest
19 19
20 20
21 class ControlInitiailizationTest(ControlToolTest): 21 class ControlInitiailizationTest(ControlToolTest):
22 22
23 # The EnvironmentTestBase will replace our $HOME, so that tests will 23 # The EnvironmentTestBase will replace our $HOME, so that tests will
24 # write properly to a temporary directory. 24 # write properly to a temporary directory.
25 def test_write_sample_config(self): 25 def test_write_sample_config(self):
26 """ 26 """
27 When juju-control is called without a valid environment 27 When juju-control is called without a valid environment
28 configuration, it should write one down and raise an error to 28 configuration, it should write one down and raise an error to
29 let the user know it should be edited. 29 let the user know it should be edited.
30 """ 30 """
31 try: 31 try:
32 main([]) 32 main(["bootstrap"])
33 except EnvironmentsConfigError, error: 33 except EnvironmentsConfigError, error:
34 self.assertTrue(error.sample_written) 34 self.assertTrue(error.sample_written)
35 else: 35 else:
36 self.fail("EnvironmentsConfigError not raised") 36 self.fail("EnvironmentsConfigError not raised")
37 37
38 38
39 class ControlOutputTest(ControlToolTest): 39 class ControlOutputTest(ControlToolTest, StateTestBase):
40 40
41 @inlineCallbacks
41 def setUp(self): 42 def setUp(self):
42 super(ControlOutputTest, self).setUp() 43 yield super(ControlOutputTest, self).setUp()
43 config = { 44 yield self.push_default_config()
44 "environments": {
45 "firstenv": {
46 "type": "dummy", "admin-secret": "homer"},
47 "secondenv": {
48 "type": "dummy", "admin-secret": "marge"}}}
49 self.write_config(dump(config))
50 45
51 def test_sans_args_produces_help(self): 46 def test_sans_args_produces_help(self):
52 """ 47 """
53 When juju-control is called without arguments, it 48 When juju-control is called without arguments, it
54 produces a standard help message. 49 produces a standard help message.
55 """ 50 """
56 stderr = self.capture_stream("stderr") 51 stderr = self.capture_stream("stderr")
57 self.mocker.replay() 52 self.mocker.replay()
58 try: 53 try:
59 main([]) 54 main([])
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 self.setup_exit(1) 298 self.setup_exit(1)
304 299
305 com = Commander(self.deferred_callback_with_exception) 300 com = Commander(self.deferred_callback_with_exception)
306 ns = self.get_sample_namespace() 301 ns = self.get_sample_namespace()
307 ns.verbose = True 302 ns.verbose = True
308 303
309 self.mocker.replay() 304 self.mocker.replay()
310 com(ns) 305 com(ns)
311 306
312 self.assertIn("traceback", err.getvalue()) 307 self.assertIn("traceback", err.getvalue())
OLDNEW
« no previous file with comments | « juju/control/tests/test_constraints_set.py ('k') | juju/control/tests/test_debug_hooks.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b