def test_deployment_controller_new_app(): redis = yield txredisapi.Connection(dbid=2) yield redis.flushdb() eb = flexmock() ac = flexmock() def configure(binder): binder.bind(txredisapi.Connection, redis) binder.bind(EventBus, eb) binder.bind(ApplicationController, ac) with inject_services(configure): controller = DeploymentController() eb.should_receive('fire_event').once() yield controller.create('foo', 'foo.bar') r = yield controller.get('foo') assert r.apps == [] ac.should_receive('create').with_args('bar.foo', {'path': 'some/path'}, skip_validation=True).once() yield controller.new_app('foo', 'bar', {'path': 'some/path'}, skip_validation=True, skip_events=True) r = yield controller.get('foo') assert r.apps == ['bar.foo'] yield controller.remove_app('foo', 'bar') r = yield controller.get('foo') assert r.apps == []
def test_deployment_controller_new_app(): redis = yield txredisapi.Connection(dbid=2) yield redis.flushdb() eb = flexmock() ac = flexmock() def configure(binder): binder.bind(txredisapi.Connection, redis) binder.bind(EventBus, eb) binder.bind(ApplicationController, ac) with inject_services(configure): controller = DeploymentController() eb.should_receive('fire_event').once() yield controller.create('foo', 'foo.bar') r = yield controller.get('foo') assert r.apps == [] ac.should_receive('create').with_args('bar.foo', { 'path': 'some/path' }, skip_validation=True).once() yield controller.new_app('foo', 'bar', {'path': 'some/path'}, skip_validation=True, skip_events=True) r = yield controller.get('foo') assert r.apps == ['bar.foo'] yield controller.remove_app('foo', 'bar') r = yield controller.get('foo') assert r.apps == []