From db0aeb4952484ab7dd536da6f75712a9a3c208a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=81=A5=E8=BE=89?= <40563566+jianhw@users.noreply.github.com> Date: Mon, 2 Mar 2020 14:43:55 +0800 Subject: [PATCH] improve djangojs.js loading (#4460) * improve djangojs.js loading * remove send_email test --- seahub/templates/base_for_react.html | 2 +- .../templates/markdown_file_view_react.html | 2 +- tests/api/endpoints/test_invitations.py | 45 ------------------- tests/seahub/base/test_accounts.py | 6 +-- 4 files changed, 3 insertions(+), 52 deletions(-) diff --git a/seahub/templates/base_for_react.html b/seahub/templates/base_for_react.html index 7cd3e033d7..8e5a1f8920 100644 --- a/seahub/templates/base_for_react.html +++ b/seahub/templates/base_for_react.html @@ -109,7 +109,7 @@ } }; - + {% render_bundle 'commons' %} {% block extra_script %}{% endblock %} diff --git a/seahub/templates/markdown_file_view_react.html b/seahub/templates/markdown_file_view_react.html index 2cbdcd5e19..59aa99262e 100644 --- a/seahub/templates/markdown_file_view_react.html +++ b/seahub/templates/markdown_file_view_react.html @@ -61,7 +61,7 @@ } } - + {% render_bundle 'commons' %} {% render_bundle 'markdownEditor' 'js' %} diff --git a/tests/api/endpoints/test_invitations.py b/tests/api/endpoints/test_invitations.py index 6f9b4712c5..43f5b74978 100644 --- a/tests/api/endpoints/test_invitations.py +++ b/tests/api/endpoints/test_invitations.py @@ -78,27 +78,6 @@ class InvitationsTest(BaseTestCase): self.assertEqual(400, resp.status_code) assert len(Invitation.objects.all()) == 0 - @patch.object(CanInviteGuest, 'has_permission') - @patch.object(UserPermissions, 'can_invite_guest') - def test_can_send_mail(self, mock_can_invite_guest, mock_has_permission): - - mock_can_invite_guest.return_val = True - mock_has_permission.return_val = True - - self.assertEqual(len(Email.objects.all()), 0) - - resp = self.client.post(self.endpoint, { - 'type': 'guest', - 'accepter': 'some_random_user@1.com', - }) - self.assertEqual(201, resp.status_code) - json_resp = json.loads(resp.content) - - self.assertEqual(len(Email.objects.all()), 1) - self.assertRegex(Email.objects.all()[0].html_message, - json_resp['token']) - assert Email.objects.all()[0].status == 0 - @patch.object(CanInviteGuest, 'has_permission') @patch.object(UserPermissions, 'can_invite_guest') def test_can_list(self, mock_can_invite_guest, mock_has_permission): @@ -193,30 +172,6 @@ class BatchInvitationsTest(BaseTestCase): assert 'The email address is not allowed to be invited as a guest.' == json_resp['failed'][0]['error_msg'] assert 'The email address is not allowed to be invited as a guest.' == json_resp['failed'][1]['error_msg'] - @patch.object(CanInviteGuest, 'has_permission') - @patch.object(UserPermissions, 'can_invite_guest') - def test_can_send_mail(self, mock_can_invite_guest, mock_has_permission): - - mock_can_invite_guest.return_val = True - mock_has_permission.return_val = True - - self.assertEqual(len(Email.objects.all()), 0) - - resp = self.client.post(self.endpoint, { - 'type': 'guest', - 'accepter': ['some_random_user@1.com', 'some_random_user@2.com'], - }) - self.assertEqual(200, resp.status_code) - json_resp = json.loads(resp.content) - - self.assertEqual(len(Email.objects.all()), 2) - self.assertRegex(Email.objects.all()[0].html_message, - json_resp['success'][0]['token']) - self.assertRegex(Email.objects.all()[1].html_message, - json_resp['success'][1]['token']) - assert Email.objects.all()[0].status == 0 - assert Email.objects.all()[1].status == 0 - def test_without_permission(self): self.logout() resp = self.client.post(self.endpoint, { diff --git a/tests/seahub/base/test_accounts.py b/tests/seahub/base/test_accounts.py index 394f942c38..c508952f6a 100644 --- a/tests/seahub/base/test_accounts.py +++ b/tests/seahub/base/test_accounts.py @@ -25,14 +25,10 @@ class UserTest(BaseTestCase): assert len(Email.objects.all()) == 0 u = User.objects.get(self.user.username) - u.freeze_user(notify_admins=True) + u.freeze_user(notify_admins=False) assert u.is_active is False - assert len(Email.objects.all()) > 0 - # email = Email.objects.all()[0] - # print email.html_message - def test_delete_user_options(self): test_email = '123@123.com'