37
38
self.assertEqual(state, {"blog-title": "Hello Tribune?"})
41
def test_set_with_config_file(self):
42
finished = self.setup_cli_reactor()
45
config_file = self.makeFile(dump(dict(
46
wordpress={"blog-title": "Hello World"})))
48
main(["set", "wordpress",
49
"--config=%s" % config_file])
52
# Verify the state is accessible
53
state = yield self.service_state.get_config()
54
self.assertEqual(state, {"blog-title": "Hello World"})
57
def test_set_with_invalid_file(self):
58
finished = self.setup_cli_reactor()
61
# missing the service_name dict (will do nothing to values)
62
config_file = self.makeFile(dump({"blog-title": "Hello World"}))
64
main(["set", "wordpress",
65
"--config=%s" % config_file])
68
state = yield self.service_state.get_config()
69
self.assertEqual(state, {})
72
def test_set_with_garbage_file(self):
73
finished = self.setup_cli_reactor()
77
# file exists but is not valid YAML
78
config_file = self.makeFile("blah")
80
main(["-v", "set", "wordpress",
81
"--config=%s" % config_file])
84
self.assertIn("Config file %r invalid" % config_file, self.stderr.getvalue())
85
state = yield self.service_state.get_config()
86
self.assertEqual(state, {})
89
def test_config_and_cli_options_errors(self):
90
"""Verify --config and cli kvpairs can't be used together"""
91
finished = self.setup_cli_reactor()
95
# valid file, but incorrect cli usage
96
config_file = self.makeFile(dump(dict(
97
wordpress={"blog-title": "Hello World"})))
99
main(["-v", "set", "wordpress",
101
"--config=%s" % config_file])
104
self.assertIn("--config and command line options", self.stderr.getvalue())
40
107
def test_set_invalid_option(self):
41
108
finished = self.setup_cli_reactor()
42
109
self.setup_exit(0)