コード例 #1
0
def test_deployment_controller():

    redis = yield txredisapi.Connection(dbid=2)
    yield redis.flushdb()

    eb = flexmock()

    def configure(binder):
        binder.bind(txredisapi.Connection, redis)
        binder.bind(EventBus, eb)

    with inject_services(configure):
        controller = DeploymentController()

        with pytest.raises(DeploymentDoesNotExist):
            yield controller.get('foo')

        eb.should_receive('fire_event').with_args(
            'new-deployment',
            public_app=None,
            apps=[],
            name='foo',
            public_domain='foo.bar').once()
        eb.should_receive('fire_event').with_args(
            'new-deployment',
            public_app=None,
            apps=[],
            name='boo',
            public_domain='other.path').once()

        r = yield controller.create('foo', 'foo.bar')
        assert isinstance(r, Deployment)
        assert r.public_domain == 'foo.bar'
        assert r.name == 'foo'

        r = yield controller.get('foo')
        assert r.public_domain == 'foo.bar'
        assert r.name == 'foo'

        r = yield controller.create('boo', 'other.path')
        assert isinstance(r, Deployment)
        assert r.public_domain == 'other.path'
        assert r.name == 'boo'

        r = yield controller.list()

        assert isinstance(r, list)
        assert len(r) == 2
        for app in r:
            assert isinstance(app, Deployment)

        eb.should_receive('fire_event').with_args('remove-deployment',
                                                  name='foo').once()
        yield controller.remove('foo')

        with pytest.raises(DeploymentDoesNotExist):
            yield controller.get('foo')
コード例 #2
0
ファイル: test_deployment.py プロジェクト: hydface2/mcloud
def test_deployment_controller():

    redis = yield txredisapi.Connection(dbid=2)
    yield redis.flushdb()

    eb = flexmock()

    def configure(binder):
        binder.bind(txredisapi.Connection, redis)
        binder.bind(EventBus, eb)

    with inject_services(configure):
        controller = DeploymentController()

        with pytest.raises(DeploymentDoesNotExist):
            yield controller.get('foo')

        eb.should_receive('fire_event').with_args('new-deployment', public_app=None, apps=[], name='foo', public_domain='foo.bar').once()
        eb.should_receive('fire_event').with_args('new-deployment', public_app=None, apps=[], name='boo', public_domain='other.path').once()

        r = yield controller.create('foo', 'foo.bar')
        assert isinstance(r, Deployment)
        assert r.public_domain == 'foo.bar'
        assert r.name == 'foo'

        r = yield controller.get('foo')
        assert r.public_domain == 'foo.bar'
        assert r.name == 'foo'

        r = yield controller.create('boo', 'other.path')
        assert isinstance(r, Deployment)
        assert r.public_domain == 'other.path'
        assert r.name == 'boo'

        r = yield controller.list()

        assert isinstance(r, list)
        assert len(r) == 2
        for app in r:
            assert isinstance(app, Deployment)

        eb.should_receive('fire_event').with_args('remove-deployment', name='foo').once()
        yield controller.remove('foo')

        with pytest.raises(DeploymentDoesNotExist):
            yield controller.get('foo')