tests: add tests for regie management interface
This commit is contained in:
parent
43a4022946
commit
425ed51436
|
@ -3,6 +3,8 @@ from django.core.wsgi import get_wsgi_application
|
|||
from webtest import TestApp
|
||||
import pytest
|
||||
|
||||
from lingo.models import Regie
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -26,3 +28,41 @@ def test_access(admin_user):
|
|||
app = login(TestApp(get_wsgi_application()))
|
||||
resp = app.get('/manage/', status=200)
|
||||
assert '/manage/lingo/' in resp.body
|
||||
|
||||
def test_add_regie(admin_user):
|
||||
Regie.objects.all().delete()
|
||||
app = login(TestApp(get_wsgi_application()))
|
||||
resp = app.get('/manage/lingo/', status=200)
|
||||
resp = resp.click('New')
|
||||
resp.forms[0]['label'] = 'Test'
|
||||
resp.forms[0]['slug'] = 'test'
|
||||
resp.forms[0]['description'] = 'description'
|
||||
resp.forms[0]['service'] = 'dummy'
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.location == 'http://localhost:80/manage/lingo/'
|
||||
assert Regie.objects.count() == 1
|
||||
regie = Regie.objects.all()[0]
|
||||
assert regie.label == 'Test'
|
||||
|
||||
def test_edit_regie(admin_user):
|
||||
test_add_regie(admin_user)
|
||||
app = login(TestApp(get_wsgi_application()))
|
||||
resp = app.get('/manage/lingo/', status=200)
|
||||
resp = resp.click('Test')
|
||||
resp.forms[0]['description'] = 'other description'
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.location == 'http://localhost:80/manage/lingo/'
|
||||
assert Regie.objects.count() == 1
|
||||
regie = Regie.objects.all()[0]
|
||||
assert regie.description == 'other description'
|
||||
|
||||
def test_delete_regie(admin_user):
|
||||
test_add_regie(admin_user)
|
||||
app = login(TestApp(get_wsgi_application()))
|
||||
resp = app.get('/manage/lingo/', status=200)
|
||||
resp = resp.click('Test')
|
||||
resp = resp.click('Delete')
|
||||
assert 'Are you sure you want to delete this?' in resp.body
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.location == 'http://localhost:80/manage/lingo/'
|
||||
assert Regie.objects.count() == 0
|
||||
|
|
Reference in New Issue