Compare commits
3 Commits
feature-lo
...
test-cover
Author | SHA1 | Date | |
---|---|---|---|
3deaa39256 | |||
c20b302458 | |||
6f186c3a3f |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ __pycache__/
|
||||
/calsocial/translations/*/LC_MESSAGES/*.mo
|
||||
/.pytest_cache/
|
||||
/.env
|
||||
/.coverage
|
||||
/htmlcov/
|
||||
|
@@ -17,6 +17,8 @@
|
||||
"""Helper functions and fixtures for testing
|
||||
"""
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
import pytest
|
||||
|
||||
import calsocial
|
||||
@@ -70,3 +72,22 @@ def database():
|
||||
yield db
|
||||
|
||||
db.drop_all()
|
||||
|
||||
|
||||
@contextmanager
|
||||
def alter_config(app, **kwargs):
|
||||
saved = {}
|
||||
|
||||
for key, value in kwargs.items():
|
||||
if key in app.config:
|
||||
saved[key] = app.config[key]
|
||||
|
||||
app.config[key] = value
|
||||
|
||||
yield
|
||||
|
||||
for key, value in kwargs.items():
|
||||
if key in saved:
|
||||
app.config[key] = saved[key]
|
||||
else:
|
||||
del app.config[key]
|
||||
|
@@ -20,7 +20,7 @@
|
||||
import calsocial
|
||||
from calsocial.models import db, User
|
||||
|
||||
from helpers import client
|
||||
from helpers import alter_config, client
|
||||
|
||||
|
||||
def test_register_page(client):
|
||||
@@ -113,3 +113,9 @@ def test_register_existing_email(client):
|
||||
'password_retype': 'password',
|
||||
})
|
||||
assert b'This email address can not be used' in page.data
|
||||
|
||||
|
||||
def test_registration_disabled(client):
|
||||
with alter_config(calsocial.app, REGISTRATION_ENABLED=False):
|
||||
page = client.get('/accounts/register')
|
||||
assert b'Registration is disabled' in page.data
|
||||
|
Reference in New Issue
Block a user