示例#1
0
文件: test_web.py 项目: tv42/cheesy2
def test_preseed_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/preseed/ubuntu-10.10',
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body[:4], 'd-i ')
示例#2
0
文件: test_web.py 项目: tv42/cheesy2
def test_preseed_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/preseed/does-not-exist',
        status=404,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
示例#3
0
文件: test_web.py 项目: tv42/cheesy2
def test_preseed_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/preseed/does-not-exist',
        status=404,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
示例#4
0
文件: test_web.py 项目: tv42/cheesy2
def test_userdata_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: 'xyzzy',
            },
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'xyzzy')
示例#5
0
文件: test_web.py 项目: tv42/cheesy2
def test_userdata_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: 'xyzzy',
        },
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'xyzzy')
示例#6
0
文件: test_web.py 项目: tv42/cheesy2
def test_userdata_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: None,
            },
        status=404,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
示例#7
0
文件: test_web.py 项目: tv42/cheesy2
def test_userdata_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: None,
        },
        status=404,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
示例#8
0
文件: test_web.py 项目: tv42/cheesy2
def test_metadata_specific():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/hostname',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'hostname': 'slartibartfast.example.com',
                },
            },
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'slartibartfast.example.com')
示例#9
0
文件: test_web.py 项目: tv42/cheesy2
def test_metadata_specific():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/hostname',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'hostname': 'slartibartfast.example.com',
            },
        },
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'slartibartfast.example.com')
示例#10
0
文件: test_web.py 项目: tv42/cheesy2
def test_metadata_index():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'foo': 'bar',
                'baz': 'quux',
                },
            },
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'baz\nfoo\n')
示例#11
0
文件: test_web.py 项目: tv42/cheesy2
def test_metadata_index():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'foo': 'bar',
                'baz': 'quux',
            },
        },
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'baz\nfoo\n')
示例#12
0
文件: test_web.py 项目: tv42/cheesy2
def test_metadata_list():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    meta = {
        'cheesy2.metadata': lambda request: {
            'foo':
            'bar',
            'public-keys': [
                web.Named(name='my-public-key',
                          value=
                          {'openssh-key': 'ssh-rsa AAAAfoo my-public-key'}),
            ],
        },
    }

    res = app.get(
        '/latest/meta-data/',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'foo\npublic-keys/\n')

    res = app.get(
        '/latest/meta-data/public-keys/',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '0=my-public-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'openssh-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/openssh-key',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'ssh-rsa AAAAfoo my-public-key')
示例#13
0
文件: test_web.py 项目: tv42/cheesy2
def test_metadata_list():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    meta = {
        'cheesy2.metadata': lambda request: {
            'foo': 'bar',
            'public-keys': [
                web.Named(name='my-public-key', value={'openssh-key': 'ssh-rsa AAAAfoo my-public-key'}),
                ],
            },
        }

    res = app.get(
        '/latest/meta-data/',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'foo\npublic-keys/\n')

    res = app.get(
        '/latest/meta-data/public-keys/',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '0=my-public-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'openssh-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/openssh-key',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'ssh-rsa AAAAfoo my-public-key')
示例#14
0
文件: test_web.py 项目: tv42/cheesy2
def test_preseed_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get('/preseed/ubuntu-10.10', )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body[:4], 'd-i ')