tests_multitenant: add test on settings.json reloading (#33563)
This commit is contained in:
parent
570722b01a
commit
5e1b5a1169
|
@ -14,6 +14,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import random
|
import random
|
||||||
|
@ -268,3 +270,36 @@ def test_unique_cookies(tenants, settings):
|
||||||
cookie_names.add(settings.SESSION_COOKIE_NAME)
|
cookie_names.add(settings.SESSION_COOKIE_NAME)
|
||||||
|
|
||||||
assert len(cookie_names) == len(tenants) * 2
|
assert len(cookie_names) == len(tenants) * 2
|
||||||
|
|
||||||
|
|
||||||
|
def test_tenant_json_settings_reload(tenants, settings, freezer):
|
||||||
|
settings.clear_tenants_settings()
|
||||||
|
|
||||||
|
with utilities.patch_default_settings(settings,
|
||||||
|
TENANT_SETTINGS_LOADERS=('hobo.multitenant.settings_loaders.SettingsJSON',)):
|
||||||
|
|
||||||
|
# check EXTEND_ME has its base value
|
||||||
|
assert django.conf.settings.EXTEND_ME == [1]
|
||||||
|
|
||||||
|
# check EXTEND_ME is extended
|
||||||
|
for tenant in tenants:
|
||||||
|
with tenant_context(tenant):
|
||||||
|
assert django.conf.settings.EXTEND_ME == [1, 2]
|
||||||
|
|
||||||
|
# move 1 minute in the future
|
||||||
|
freezer.move_to(datetime.timedelta(seconds=60))
|
||||||
|
|
||||||
|
# update EXTEND_ME tenant value
|
||||||
|
for tenant in tenants:
|
||||||
|
with open(os.path.join(tenant.get_directory(), 'settings.json'), 'w') as fd:
|
||||||
|
json.dump({
|
||||||
|
'EXTEND_ME.extend': [3]
|
||||||
|
}, fd)
|
||||||
|
|
||||||
|
# move 1 minute in the future
|
||||||
|
freezer.move_to(datetime.timedelta(seconds=60))
|
||||||
|
|
||||||
|
# check EXTEND_ME is still extended from base value
|
||||||
|
for tenant in tenants:
|
||||||
|
with tenant_context(tenant):
|
||||||
|
assert django.conf.settings.EXTEND_ME == [1, 3]
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -51,6 +51,7 @@ deps:
|
||||||
http://git.entrouvert.org/debian/django-tenant-schemas.git/snapshot/django-tenant-schemas-master.tar.gz
|
http://git.entrouvert.org/debian/django-tenant-schemas.git/snapshot/django-tenant-schemas-master.tar.gz
|
||||||
httmock
|
httmock
|
||||||
requests
|
requests
|
||||||
|
pytest-freezegun
|
||||||
commands =
|
commands =
|
||||||
./getlasso.sh
|
./getlasso.sh
|
||||||
hobo: py.test {env:COVERAGE:} {env:NOMIGRATIONS:} {posargs:tests/}
|
hobo: py.test {env:COVERAGE:} {env:NOMIGRATIONS:} {posargs:tests/}
|
||||||
|
|
Loading…
Reference in New Issue