tests: add initial test infrastructure

This commit is contained in:
Frédéric Péters 2015-04-21 15:28:33 +02:00
parent da9223dc9f
commit 513bc434a2
2 changed files with 29 additions and 0 deletions

1
tests/settings.py Normal file
View File

@ -0,0 +1 @@
LANGUAGE_CODE = 'en-us'

28
tests/test_manager.py Normal file
View File

@ -0,0 +1,28 @@
from django.contrib.auth.models import User
from django.core.wsgi import get_wsgi_application
from webtest import TestApp
import pytest
pytestmark = pytest.mark.django_db
@pytest.fixture
def admin_user():
try:
user = User.objects.get(username='admin')
except User.DoesNotExist:
user = User.objects.create_superuser('admin', email=None, password='admin')
return user
def login(app, username='admin', password='admin'):
login_page = app.get('/login/')
login_form = login_page.forms[0]
login_form['username'] = username
login_form['password'] = password
resp = login_form.submit()
assert resp.status_int == 302
return app
def test_access(admin_user):
app = login(TestApp(get_wsgi_application()))
resp = app.get('/manage/', status=200)
assert '/manage/lingo/' in resp.body