diff --git a/geotrek/common/forms.py b/geotrek/common/forms.py index 8721b8a1eb..84e1dd9fd7 100644 --- a/geotrek/common/forms.py +++ b/geotrek/common/forms.py @@ -374,7 +374,6 @@ class SyncRandoForm(forms.Form): def helper(self): helper = FormHelper() helper.form_id = 'form-sync' - helper.form_action = reverse('common:sync_randos') helper.form_class = 'search' # submit button with boostrap attributes, disabled by default helper.add_input(Button('sync-web', _("Launch Sync"), diff --git a/geotrek/common/tests/test_views.py b/geotrek/common/tests/test_views.py index 29b43247b5..3f049a346e 100644 --- a/geotrek/common/tests/test_views.py +++ b/geotrek/common/tests/test_views.py @@ -99,25 +99,29 @@ def test_trek_document_wrong_portal(self, mock_request_get): class ViewsTest(TestCase): @classmethod def setUpTestData(cls): - cls.user = UserFactory.create(username='homer', password='dooh') - - def setUp(self): - self.client.force_login(user=self.user) + cls.user = UserFactory() + cls.super_user = SuperUserFactory() def test_settings_json(self): + self.client.force_login(self.user) url = reverse('common:settings_json') response = self.client.get(url) self.assertEqual(response.status_code, 200) def test_admin_check_extents(self): + """ Admin can access to extents view""" url = reverse('common:check_extents') - response = self.client.get(url) - self.assertEqual(response.status_code, 302) - self.user.is_superuser = True - self.user.save() + self.client.force_login(self.super_user) response = self.client.get(url) self.assertEqual(response.status_code, 200) + def test_simple_user_check_extents(self): + """ Simple user can't access to extents view""" + url = reverse('common:check_extents') + self.client.force_login(self.user) + response = self.client.get(url) + self.assertEqual(response.status_code, 302) + @override_settings(COLUMNS_LISTS={}) @mock.patch('geotrek.common.mixins.views.logger') def test_custom_columns_mixin_error_log(self, mock_logger): @@ -134,7 +138,8 @@ class MissingColumns(CustomColumnsMixin, MapEntityList): class ViewsImportTest(TestCase): @classmethod def setUpTestData(cls): - cls.user = UserFactory.create(username='homer', password='dooh') + cls.user = UserFactory() + cls.super_user = SuperUserFactory() def setUp(self): self.client.force_login(user=self.user) @@ -157,8 +162,7 @@ def test_import_update_access(self): self.assertEqual(response.status_code, 200) def test_import_from_file_good_zip_file(self): - self.user.is_superuser = True - self.user.save() + self.client.force_login(user=self.super_user) with open('geotrek/common/tests/data/test.zip', 'rb') as real_archive: url = reverse('common:import_dataset') @@ -177,8 +181,7 @@ def test_import_from_file_good_zip_file(self): @mock.patch('geotrek.common.tasks.current_task') @mock.patch('geotrek.common.tasks.import_datas.delay') def test_import_from_file_good_geojson_file(self, mocked, mocked_current_task): - self.user.is_superuser = True - self.user.save() + self.client.force_login(user=self.user) FileType.objects.create(type="Photographie") mocked.side_effect = import_datas mocked_current_task.request.id = '1' @@ -200,8 +203,7 @@ def test_import_from_file_good_geojson_file(self, mocked, mocked_current_task): @mock.patch('geotrek.common.tasks.import_datas.delay') def test_import_from_file_bad_file(self, mocked): - self.user.is_superuser = True - self.user.save() + self.client.force_login(user=self.user) Parser.label = "Test" @@ -223,8 +225,7 @@ def test_import_from_file_bad_file(self, mocked): Parser.label = None def test_import_form_no_parser_no_superuser(self): - self.user.is_superuser = False - self.user.save() + self.client.force_login(user=self.user) real_archive = open('geotrek/common/tests/data/test.zip', 'rb+') url = reverse('common:import_dataset') @@ -241,8 +242,7 @@ def test_import_form_no_parser_no_superuser(self): self.assertNotContains(response_real, '