ants_hub: fix use of uwsgidecorators.spool (#78242) #96
|
@ -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 sys
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
@ -236,6 +238,12 @@ class Synchronize(TemplateView):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def synchronize(cls):
|
def synchronize(cls):
|
||||||
from chrono.utils.spooler import ants_hub_city_push
|
if 'uwsgi' in sys.modules:
|
||||||
|
from django.db import connection
|
||||||
|
|
||||||
ants_hub_city_push.spool()
|
from chrono.utils.spooler import ants_hub_city_push
|
||||||
|
|
||||||
|
tenant = getattr(connection, 'tenant', None)
|
||||||
|
ants_hub_city_push.spool(domain=getattr(tenant, 'domain_url', None))
|
||||||
|
else:
|
||||||
|
models.City.push()
|
||||||
|
|
|
@ -182,11 +182,14 @@ def test_delete_agenda(hub, app, admin_user, city, place, agenda, place_agenda):
|
||||||
|
|
||||||
|
|
||||||
def test_synchronize(hub, app, admin_user, city, place, agenda, place_agenda, freezer):
|
def test_synchronize(hub, app, admin_user, city, place, agenda, place_agenda, freezer):
|
||||||
|
hub.add(
|
||||||
|
responses.POST,
|
||||||
|
'https://toto:@ants-hub.example.com/api/chrono/rendez-vous-disponibles/',
|
||||||
|
json={'err': 0},
|
||||||
|
)
|
||||||
freezer.move_to('2023-06-01T17:12:00+02:00')
|
freezer.move_to('2023-06-01T17:12:00+02:00')
|
||||||
login(app)
|
login(app)
|
||||||
resp = app.get('/manage/', status=200)
|
resp = app.get('/manage/', status=200)
|
||||||
resp = resp.click('ANTS')
|
resp = resp.click('ANTS')
|
||||||
resp = resp.click('Synchronize')
|
resp = resp.click('Synchronize')
|
||||||
with mock.patch('chrono.apps.ants_hub.views.Synchronize.synchronize') as method:
|
resp = resp.form.submit().follow()
|
||||||
resp = resp.form.submit().follow()
|
|
||||||
assert method.called
|
|
||||||
|
|
Loading…
Reference in New Issue