~fwereade/pyjuju/rearrange-settings-nodes

« back to all changes in this revision

Viewing changes to juju/state/tests/test_environment.py

  • Committer: William Reade
  • Date: 2011-09-21 10:24:06 UTC
  • Revision ID: fwereade@gmail.com-20110921102406-47371sz4jejosh1o
global settings now live as value nodes under /settings, instead of using /global_settings as a dict node

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
            callbacks[len(results) - 1].callback(content)
168
168
 
169
169
        yield self.manager.set_debug_log(True)
170
 
        yield self.manager.watch_settings_changes(watch)
 
170
        yield self.manager.watch_debug_log(watch)
171
171
        self.assertTrue(results)
172
172
 
173
173
        yield self.manager.set_debug_log(False)
200
200
            results.append(content)
201
201
            callbacks[len(results) - 1].callback(content)
202
202
 
203
 
        watcher = yield self.manager.watch_settings_changes(watch)
204
 
        yield self.client.create(GLOBAL_SETTINGS, "x")
 
203
        path = "%s/%s" % (GLOBAL_SETTINGS, "debug_log")
 
204
 
 
205
        watcher = yield self.manager.watch_debug_log(watch)
 
206
        yield self.client.create(GLOBAL_SETTINGS)
 
207
        yield self.client.create(path, "x")
205
208
        value = yield callbacks[0]
206
209
        self.assertEqual(value.type_name, "created")
207
210
 
208
211
        data = dict(x=1, y=2, z=3, moose=u"moon")
209
 
        yield self.client.set(
210
 
            GLOBAL_SETTINGS, yaml.safe_dump(data))
 
212
        yield self.client.set(path, yaml.safe_dump(data))
211
213
        value = yield callbacks[1]
212
214
        self.assertEqual(value.type_name, "changed")
213
215
 
214
216
        watcher.stop()
215
217
 
216
 
        yield self.client.set(GLOBAL_SETTINGS, "z")
 
218
        yield self.client.set(path, "z")
217
219
        # Give a chance for things to go bad.
218
 
        yield self.sleep(0.1)
 
220
        yield self.poke_zk()
219
221
        self.assertFalse(callbacks[2].called)
220
222
 
221
223
    @inlineCallbacks
232
234
        def on_error(error):
233
235
            results.append(True)
234
236
 
235
 
        yield self.client.create(GLOBAL_SETTINGS, "z")
236
 
        watcher = yield self.manager.watch_settings_changes(
237
 
            watch, on_error)
 
237
        path = "%s/%s" % (GLOBAL_SETTINGS, "debug_log")
 
238
 
 
239
        yield self.client.create(GLOBAL_SETTINGS)
 
240
        yield self.client.create(path, "z")
 
241
        watcher = yield self.manager.watch_debug_log(watch, on_error)
238
242
        yield callbacks[0]
239
243
 
240
244
        # The callback error should have disconnected the system.
241
 
        yield self.client.set(GLOBAL_SETTINGS, "x")
 
245
        yield self.client.set(path, "x")
242
246
 
243
247
        # Give a chance for things to go bad.
244
 
        yield self.sleep(0.1)
 
248
        yield self.poke_zk()
245
249
 
246
250
        # Verify nothing did go bad.
247
251
        self.assertFalse(watcher.is_running)