summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-03-18 14:55:33 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-17 13:21:27 +0200
commit8905293c2197dadc0bc23684546e2ff604707b68 (patch)
treece5a30cf06d8128d9178b61e6d43fd06669667bb
parent13e9facb3b34b82c38ebf2615c34b1c6e151b365 (diff)
downloadIshtar-8905293c2197dadc0bc23684546e2ff604707b68.tar.bz2
Ishtar-8905293c2197dadc0bc23684546e2ff604707b68.zip
Option to disable TASK TIMEOUT (and disable it for tests)
-rw-r--r--archaeological_files/tests.py7
-rw-r--r--example_project/local_settings.py.gitlab-ci1
-rw-r--r--example_project/settings.py1
-rw-r--r--ishtar_common/utils.py6
4 files changed, 11 insertions, 4 deletions
diff --git a/archaeological_files/tests.py b/archaeological_files/tests.py
index b8755ecbd..0b72d505a 100644
--- a/archaeological_files/tests.py
+++ b/archaeological_files/tests.py
@@ -56,13 +56,14 @@ class FileTest(TestCase, FileInit):
IshtarSiteProfile.objects.create()
self.create_file()
- def testExternalID(self):
+ def test_external_id(self):
self.assertEqual(
self.item.external_id,
u"{}-{}".format(self.item.year,
self.item.numeric_reference))
- def testCachedLabel(self):
+ def test_cached_label(self):
+ self.item = models.File.objects.get(pk=self.item.pk)
# localisation fix
lbls = []
for town_lbl in (u'No town', u'Pas de commune'):
@@ -74,7 +75,9 @@ class FileTest(TestCase, FileInit):
self.item.towns.add(default_town)
# manually done inside wizards
self.item._cached_label_checked = False
+ self.item._test = True
self.item.save()
+ self.item = models.File.objects.get(pk=self.item.pk)
lbl = lbls[0].replace('No town', 'Paris')
self.assertEqual(self.item.cached_label, lbl)
diff --git a/example_project/local_settings.py.gitlab-ci b/example_project/local_settings.py.gitlab-ci
index b4f94f6a1..b8f40b8bb 100644
--- a/example_project/local_settings.py.gitlab-ci
+++ b/example_project/local_settings.py.gitlab-ci
@@ -14,3 +14,4 @@ LOGFILE = '/tmp/ishtar.log'
PROJECT_SLUG = "CI-instance"
SECRET_KEY = "not-so-secret-key"
+DISABLE_TASK_TIMEOUT = True
diff --git a/example_project/settings.py b/example_project/settings.py
index f53176622..3ffea90b9 100644
--- a/example_project/settings.py
+++ b/example_project/settings.py
@@ -19,6 +19,7 @@ if "test" in sys.argv:
IMAGE_MAX_SIZE = (1280, 960) # put None if no resizing
THUMB_MAX_SIZE = (600, 600)
+DISABLE_TASK_TIMEOUT = False
CACHE_TASK_TIMEOUT = 4
CACHE_SMALLTIMEOUT = 60
CACHE_TIMEOUT = 3600
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 4e5259001..9bd81383f 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -376,7 +376,8 @@ def cached_label_changed(sender, **kwargs):
cache_key, value = get_cache(
sender, ["cached_label_changed", kwargs['instance'].pk]
)
- if value: # multiple request too quick
+ if value and not settings.DISABLE_TASK_TIMEOUT:
+ # multiple request too quick
return
cache.set(cache_key, True, settings.CACHE_TASK_TIMEOUT)
@@ -590,7 +591,8 @@ def post_save_geo(sender, **kwargs):
return
cache_key, value = get_cache(
sender, ["post_save_geo", kwargs['instance'].pk])
- if value: # multiple request too quick
+ if value and not settings.DISABLE_TASK_TIMEOUT:
+ # multiple request too quick
return
cache.set(cache_key, True, settings.CACHE_TASK_TIMEOUT)