Beispiel #1
0
def test_tarball_test_not_found():
    tmp = util.maketemp()
    util.fake_git(tmp)
    util.fast_import(
        repo=tmp,
        commits=[
            dict(
                message='one',
                committer='John Doe <*****@*****.**>',
                commit_time='1216235872 +0300',
                files=[
                    dict(
                        path='tests/fake/fake.py',
                        content='fakecontrol',
                        ),
                    dict(
                        path='tests/fake/extra-stuff',
                        content='EXTRA',
                        mode='100755',
                        ),
                    dict(
                        path='teuthology/library-stuff-here',
                        content='fakelib',
                        ),
                    ],
                ),
            ],
        )
    app = web.app_factory(**{'git-dir': tmp})
    app = webtest.TestApp(app)
    res = app.get('/tarball/master/nonexistent.tar.bz2', status=404)
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'Revision or test not found.\n')
Beispiel #2
0
def test_tarball_test_not_found():
    tmp = util.maketemp()
    util.fake_git(tmp)
    util.fast_import(
        repo=tmp,
        commits=[
            dict(
                message='one',
                committer='John Doe <*****@*****.**>',
                commit_time='1216235872 +0300',
                files=[
                    dict(
                        path='tests/fake/fake.py',
                        content='fakecontrol',
                    ),
                    dict(
                        path='tests/fake/extra-stuff',
                        content='EXTRA',
                        mode='100755',
                    ),
                    dict(
                        path='teuthology/library-stuff-here',
                        content='fakelib',
                    ),
                ],
            ),
        ],
    )
    app = web.app_factory(**{'git-dir': tmp})
    app = webtest.TestApp(app)
    res = app.get('/tarball/master/nonexistent.tar.bz2', status=404)
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'Revision or test not found.\n')
Beispiel #3
0
def test_tarball_simple():
    tmp = util.maketemp()
    util.fake_git(tmp)
    util.fast_import(
        repo=tmp,
        commits=[
            dict(
                message='one',
                committer='John Doe <*****@*****.**>',
                commit_time='1216235872 +0300',
                files=[
                    dict(
                        path='tests/fake/fake.py',
                        content='faketest',
                        ),
                    dict(
                        path='tests/fake/extra-stuff',
                        content='EXTRA',
                        mode='100755',
                        ),
                    dict(
                        path='teuthology/library-stuff-here',
                        content='fakelib',
                        ),
                    ],
                ),
            ],
        )
    app = web.app_factory(**{'git-dir': tmp})
    app = webtest.TestApp(app)
    res = app.get('/tarball/master/fake.tar.bz2')
    eq(res.headers['Content-Type'], 'application/x-bzip')
    f = StringIO(res.body)
    tar = tarfile.open(
        fileobj=f,
        mode='r:bz2',
        )

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'extra-stuff')
    eq(ti.type, tarfile.REGTYPE)
    eq('%o'%ti.mode, '775')
    eq(tar.extractfile(ti).read(), 'EXTRA')

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'fake.py')
    eq(ti.type, tarfile.REGTYPE)
    eq('%o'%ti.mode, '664')
    eq(tar.extractfile(ti).read(), 'faketest')

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'teuthology')
    eq(ti.type, tarfile.DIRTYPE)
    eq('%o'%ti.mode, '775')

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'teuthology/library-stuff-here')
    eq(ti.type, tarfile.REGTYPE)
    eq('%o'%ti.mode, '664')
    eq(tar.extractfile(ti).read(), 'fakelib')

    ti = tar.next()
    assert ti is None
Beispiel #4
0
def test_tarball_simple():
    tmp = util.maketemp()
    util.fake_git(tmp)
    util.fast_import(
        repo=tmp,
        commits=[
            dict(
                message='one',
                committer='John Doe <*****@*****.**>',
                commit_time='1216235872 +0300',
                files=[
                    dict(
                        path='tests/fake/fake.py',
                        content='faketest',
                    ),
                    dict(
                        path='tests/fake/extra-stuff',
                        content='EXTRA',
                        mode='100755',
                    ),
                    dict(
                        path='teuthology/library-stuff-here',
                        content='fakelib',
                    ),
                ],
            ),
        ],
    )
    app = web.app_factory(**{'git-dir': tmp})
    app = webtest.TestApp(app)
    res = app.get('/tarball/master/fake.tar.bz2')
    eq(res.headers['Content-Type'], 'application/x-bzip')
    f = StringIO(res.body)
    tar = tarfile.open(
        fileobj=f,
        mode='r:bz2',
    )

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'extra-stuff')
    eq(ti.type, tarfile.REGTYPE)
    eq('%o' % ti.mode, '775')
    eq(tar.extractfile(ti).read(), 'EXTRA')

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'fake.py')
    eq(ti.type, tarfile.REGTYPE)
    eq('%o' % ti.mode, '664')
    eq(tar.extractfile(ti).read(), 'faketest')

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'teuthology')
    eq(ti.type, tarfile.DIRTYPE)
    eq('%o' % ti.mode, '775')

    ti = tar.next()
    assert ti is not None
    eq(ti.name, 'teuthology/library-stuff-here')
    eq(ti.type, tarfile.REGTYPE)
    eq('%o' % ti.mode, '664')
    eq(tar.extractfile(ti).read(), 'fakelib')

    ti = tar.next()
    assert ti is None