35 lines
967 B
Python
35 lines
967 B
Python
import pytest
|
|
|
|
from .utils import login
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
def test_unlogged_access(app):
|
|
# connect while not being logged in
|
|
assert app.get('/manage/', status=302).location.endswith('/login/?next=/manage/')
|
|
|
|
|
|
def test_simple_user_access(app, simple_user):
|
|
# connect while being logged as a simple user
|
|
app = login(app, username='user', password='user')
|
|
assert app.get('/manage/', status=403)
|
|
|
|
|
|
def test_access(app, admin_user):
|
|
app = login(app)
|
|
assert app.get('/manage/', status=200)
|
|
|
|
|
|
def test_menu_json(app, admin_user):
|
|
app.get('/manage/menu.json', status=302) # login
|
|
|
|
app = login(app)
|
|
resp = app.get('/manage/menu.json')
|
|
assert resp.headers['content-type'] == 'application/json'
|
|
assert resp.json[0]['label'] == 'Payments'
|
|
|
|
resp = app.get('/manage/menu.json?callback=fooBar')
|
|
assert resp.headers['content-type'] == 'application/javascript'
|
|
assert resp.text.startswith('fooBar([{"')
|