tests: add initial test infrastructure
This commit is contained in:
parent
da9223dc9f
commit
513bc434a2
|
@ -0,0 +1 @@
|
|||
LANGUAGE_CODE = 'en-us'
|
|
@ -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
|
Reference in New Issue