add some tests for the WSGI app

This commit is contained in:
Ralf Schmitt 2011-08-30 03:38:59 +02:00
parent 9e4b3ec32f
commit baa2936217
3 changed files with 52 additions and 0 deletions

View File

@ -10,5 +10,6 @@ include pypiserver/bottle.py
include pypiserver/core.py
include setup.cfg
include setup.py
include tests/test_app.py
include tests/test_main.py
include tox.ini

50
tests/test_app.py Executable file
View File

@ -0,0 +1,50 @@
#! /usr/bin/env py.test
import os
import twill
from twill.commands import go, code, follow, show, find, reload, showlinks
from pypiserver import core
import bottle
bottle.debug(True)
def pytest_funcarg__root(request):
tmpdir = request.getfuncargvalue("tmpdir")
monkeypatch = request.getfuncargvalue("monkeypatch")
monkeypatch.setattr(core, "packages", core.pkgset(tmpdir.strpath))
monkeypatch.setattr(core, "config", core.configuration())
twill.add_wsgi_intercept("localhost", 8080, bottle.default_app)
twill.add_wsgi_intercept("systemexit.de", 80, bottle.default_app)
go("http://localhost:8080/")
return tmpdir
def test_root_count(root):
go("/")
show()
code(200)
find("PyPI compatible package index serving 0 packages")
showlinks()
root.join("Twisted-11.0.0.tar.bz2").write("")
reload()
show()
find("PyPI compatible package index serving 1 packages")
def test_root_hostname(root):
go("http://systemexit.de/")
find("easy_install -i http://systemexit.de/simple PACKAGE")
def test_packages_empty(root):
go("/packages")
show()
code(200)
assert list(showlinks()) == []

View File

@ -2,5 +2,6 @@
envlist = py25,py26,py27
[testenv]
deps=pytest
twill
commands=py.test
sitepackages=False