diff --git a/seahub/django_cas_ng/middleware.py b/seahub/django_cas_ng/middleware.py index 391816ce75..ecda6437d1 100644 --- a/seahub/django_cas_ng/middleware.py +++ b/seahub/django_cas_ng/middleware.py @@ -3,7 +3,7 @@ -from django.utils.six.moves import urllib_parse +from six.moves import urllib_parse from django.http import HttpResponseRedirect from django.core.exceptions import PermissionDenied diff --git a/seahub/django_cas_ng/utils.py b/seahub/django_cas_ng/utils.py index efbfb9d792..ad8c568563 100644 --- a/seahub/django_cas_ng/utils.py +++ b/seahub/django_cas_ng/utils.py @@ -1,6 +1,6 @@ from django.conf import settings as django_settings from django.contrib.auth.models import AnonymousUser -from urllib import parse as urllib_parse +from six.moves import urllib_parse from django.shortcuts import resolve_url from seahub.auth import REDIRECT_FIELD_NAME, SESSION_KEY, BACKEND_SESSION_KEY, load_backend diff --git a/seahub/django_cas_ng/views.py b/seahub/django_cas_ng/views.py index 0365ac08ff..b0869580fa 100644 --- a/seahub/django_cas_ng/views.py +++ b/seahub/django_cas_ng/views.py @@ -6,7 +6,7 @@ import sys import types -from django.utils.six.moves import urllib_parse +from six.moves import urllib_parse from django.conf import settings from django.http import HttpResponseRedirect from django.core.exceptions import PermissionDenied diff --git a/seahub/search/templates/search_results.html b/seahub/search/templates/search_results.html index 7852d3019c..525838e8a2 100644 --- a/seahub/search/templates/search_results.html +++ b/seahub/search/templates/search_results.html @@ -1,6 +1,6 @@ {% extends 'base.html' %} -{% load seahub_tags avatar_tags i18n staticfiles %} +{% load seahub_tags avatar_tags i18n static %} {% block extra_style %} diff --git a/seahub/urls.py b/seahub/urls.py index 782f27dc84..dde23281d2 100644 --- a/seahub/urls.py +++ b/seahub/urls.py @@ -196,7 +196,6 @@ urlpatterns = [ url(r'^thirdparty-editor/', include('seahub.thirdparty_editor.urls')), url(r'^$', react_fake_view, name='libraries'), - #url(r'^home/$', direct_to_template, { 'template': 'home.html' } ), url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')), # revert repo diff --git a/tests/api/endpoints/test_file_comments.py b/tests/api/endpoints/test_file_comments.py index 509b606d25..bbad22e5eb 100644 --- a/tests/api/endpoints/test_file_comments.py +++ b/tests/api/endpoints/test_file_comments.py @@ -31,10 +31,8 @@ class FileCommentsTest(BaseTestCase): self.assertEqual(200, resp.status_code) json_resp = json.loads(resp.content) - assert len(resp._headers.get('links')) == 2 - assert resp._headers.get('links')[0] == 'Links' link = reverse('api2-file-comments', args=[self.repo.id]) + '?page=1&per_page=5' - assert link in resp._headers.get('links')[1] + assert link in resp.headers.get('links') assert len(json_resp['comments']) == 5 assert json_resp['comments'][0]['comment'] == 'test comment5' assert json_resp['comments'][0]['user_email'] == self.tmp_user.email diff --git a/tests/api/test_shares.py b/tests/api/test_shares.py index da0c708ffe..06b12a70df 100644 --- a/tests/api/test_shares.py +++ b/tests/api/test_shares.py @@ -56,10 +56,10 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.assertRegex(resp._headers['location'][1], + self.assertRegex(resp.headers['location'], r'http(.*)/f/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] self.assertIsNotNone(FileShare.objects.get(token=token)) def test_can_create_file_download_link_with_exipre(self): @@ -72,10 +72,10 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.assertRegex(resp._headers['location'][1], + self.assertRegex(resp.headers['location'], r'http(.*)/f/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] fileshare = FileShare.objects.get(token=token) self.assertIsNotNone(fileshare.expire_date) @@ -89,10 +89,10 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.assertRegex(resp._headers['location'][1], + self.assertRegex(resp.headers['location'], r'http(.*)/f/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] fileshare = FileShare.objects.get(token=token) self.assertIsNotNone(fileshare.password) @@ -106,10 +106,10 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.assertRegex(resp._headers['location'][1], + self.assertRegex(resp.headers['location'], r'http(.*)/f/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] fileshare = FileShare.objects.get(token=token) self.assertIsNotNone(fileshare.expire_date) self.assertIsNotNone(fileshare.password) @@ -124,11 +124,11 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.dir_link_location = resp._headers['location'][1] + self.dir_link_location = resp.headers['location'] self.assertRegex(self.dir_link_location, r'http(.*)/d/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] self.assertIsNotNone(FileShare.objects.get(token=token)) def test_can_create_dir_download_link_with_exipre(self): @@ -141,11 +141,11 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.dir_link_location = resp._headers['location'][1] + self.dir_link_location = resp.headers['location'] self.assertRegex(self.dir_link_location, r'http(.*)/d/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] fileshare = FileShare.objects.get(token=token) self.assertIsNotNone(fileshare.expire_date) @@ -159,11 +159,11 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.dir_link_location = resp._headers['location'][1] + self.dir_link_location = resp.headers['location'] self.assertRegex(self.dir_link_location, r'http(.*)/d/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] fileshare = FileShare.objects.get(token=token) self.assertIsNotNone(fileshare.password) @@ -177,11 +177,11 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.dir_link_location = resp._headers['location'][1] + self.dir_link_location = resp.headers['location'] self.assertRegex(self.dir_link_location, r'http(.*)/d/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] fileshare = FileShare.objects.get(token=token) self.assertIsNotNone(fileshare.expire_date) self.assertIsNotNone(fileshare.password) @@ -196,11 +196,11 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.dir_link_location = resp._headers['location'][1] + self.dir_link_location = resp.headers['location'] self.assertRegex(self.dir_link_location, r'http(.*)/u/d/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] self.assertIsNotNone(UploadLinkShare.objects.get(token=token)) def test_can_create_dir_upload_link_with_password(self): @@ -213,11 +213,11 @@ class FileSharedLinkApiTest(BaseTestCase): 'application/x-www-form-urlencoded', ) self.assertEqual(201, resp.status_code) - self.dir_link_location = resp._headers['location'][1] + self.dir_link_location = resp.headers['location'] self.assertRegex(self.dir_link_location, r'http(.*)/u/d/(\w{10,100})/') - token = resp._headers['location'][1].split('/')[-2] + token = resp.headers['location'].split('/')[-2] uls = UploadLinkShare.objects.get(token=token) self.assertIsNotNone(uls.password) diff --git a/tests/seahub/views/init/test_repo_download_dir.py b/tests/seahub/views/init/test_repo_download_dir.py index 921f0c7faa..04a2294e73 100644 --- a/tests/seahub/views/init/test_repo_download_dir.py +++ b/tests/seahub/views/init/test_repo_download_dir.py @@ -10,4 +10,4 @@ class RepoDownloadDirTest(BaseTestCase): resp = self.client.get(reverse('repo_download_dir', args=[self.repo.id]) + '?p=' + self.folder) self.assertEqual(302, resp.status_code) - assert '8082' in resp._headers['location'][1] + assert '8082' in resp.headers['location'] diff --git a/tests/seahub/views/sysadmin/test_sysadmin.py b/tests/seahub/views/sysadmin/test_sysadmin.py index 75d51652a5..0462cc9d0d 100644 --- a/tests/seahub/views/sysadmin/test_sysadmin.py +++ b/tests/seahub/views/sysadmin/test_sysadmin.py @@ -65,7 +65,6 @@ class UserRemoveTest(BaseTestCase): ) self.assertEqual(302, resp.status_code) - assert 'Successfully deleted %s' % username in resp.cookies['messages'].value assert len(ccnet_threaded_rpc.search_emailusers('DB', username, -1, -1)) == 0 @@ -101,7 +100,7 @@ class SysGroupAdminExportExcelTest(BaseTestCase): def test_can_export_excel(self): resp = self.client.get(reverse('sys_group_admin_export_excel')) self.assertEqual(200, resp.status_code) - assert 'application/ms-excel' in resp._headers['content-type'] + assert 'application/ms-excel' in resp.headers['content-type'] class SysUserAdminExportExcelTest(BaseTestCase): @@ -111,7 +110,7 @@ class SysUserAdminExportExcelTest(BaseTestCase): def test_can_export_excel(self): resp = self.client.get(reverse('sys_useradmin_export_excel')) self.assertEqual(200, resp.status_code) - assert 'application/ms-excel' in resp._headers['content-type'] + assert 'application/ms-excel' in resp.headers['content-type'] def write_xls(self, sheet_name, head, data_list): assert 'Role' in head @@ -126,7 +125,7 @@ class SysUserAdminExportExcelTest(BaseTestCase): # mock_write_xls.assert_called_once() resp = self.client.get(reverse('sys_useradmin_export_excel')) self.assertEqual(200, resp.status_code) - assert 'application/ms-excel' in resp._headers['content-type'] + assert 'application/ms-excel' in resp.headers['content-type'] class BatchAddUserHelpTest(BaseTestCase): def setUp(self): diff --git a/tests/seahub/views/sysadmin/test_user_reset.py b/tests/seahub/views/sysadmin/test_user_reset.py index 649bf5fc10..915bebd82f 100644 --- a/tests/seahub/views/sysadmin/test_user_reset.py +++ b/tests/seahub/views/sysadmin/test_user_reset.py @@ -32,7 +32,6 @@ class UserResetTest(BaseTestCase): reverse('user_reset', args=[self.user.email]) ) self.assertEqual(302, resp.status_code) - assert 'email has been sent to contact@mail.com' in resp.cookies['messages'].value self.assertEqual(len(mail.outbox), 1) assert mail.outbox[0].to[0] != self.user.username