mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-01 23:38:37 +00:00
merge seahub-extra & repair test
This commit is contained in:
parent
e805feca95
commit
3b154c76c1
@ -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.http import HttpResponseRedirect
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.conf import settings as django_settings
|
from django.conf import settings as django_settings
|
||||||
from django.contrib.auth.models import AnonymousUser
|
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 django.shortcuts import resolve_url
|
||||||
|
|
||||||
from seahub.auth import REDIRECT_FIELD_NAME, SESSION_KEY, BACKEND_SESSION_KEY, load_backend
|
from seahub.auth import REDIRECT_FIELD_NAME, SESSION_KEY, BACKEND_SESSION_KEY, load_backend
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from django.utils.six.moves import urllib_parse
|
from six.moves import urllib_parse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% load seahub_tags avatar_tags i18n staticfiles %}
|
{% load seahub_tags avatar_tags i18n static %}
|
||||||
|
|
||||||
|
|
||||||
{% block extra_style %}
|
{% block extra_style %}
|
||||||
|
@ -196,7 +196,6 @@ urlpatterns = [
|
|||||||
url(r'^thirdparty-editor/', include('seahub.thirdparty_editor.urls')),
|
url(r'^thirdparty-editor/', include('seahub.thirdparty_editor.urls')),
|
||||||
|
|
||||||
url(r'^$', react_fake_view, name='libraries'),
|
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')),
|
url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
|
||||||
|
|
||||||
# revert repo
|
# revert repo
|
||||||
|
@ -31,10 +31,8 @@ class FileCommentsTest(BaseTestCase):
|
|||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
|
|
||||||
json_resp = json.loads(resp.content)
|
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'
|
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 len(json_resp['comments']) == 5
|
||||||
assert json_resp['comments'][0]['comment'] == 'test comment5'
|
assert json_resp['comments'][0]['comment'] == 'test comment5'
|
||||||
assert json_resp['comments'][0]['user_email'] == self.tmp_user.email
|
assert json_resp['comments'][0]['user_email'] == self.tmp_user.email
|
||||||
|
@ -56,10 +56,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
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))
|
self.assertIsNotNone(FileShare.objects.get(token=token))
|
||||||
|
|
||||||
def test_can_create_file_download_link_with_exipre(self):
|
def test_can_create_file_download_link_with_exipre(self):
|
||||||
@ -72,10 +72,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
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)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
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)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
|
|
||||||
@ -106,10 +106,10 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
self.assertRegex(resp._headers['location'][1],
|
self.assertRegex(resp.headers['location'],
|
||||||
r'http(.*)/f/(\w{10,100})/')
|
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)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
@ -124,11 +124,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
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,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
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))
|
self.assertIsNotNone(FileShare.objects.get(token=token))
|
||||||
|
|
||||||
def test_can_create_dir_download_link_with_exipre(self):
|
def test_can_create_dir_download_link_with_exipre(self):
|
||||||
@ -141,11 +141,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
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,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
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)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
|
|
||||||
@ -159,11 +159,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
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,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
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)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
|
|
||||||
@ -177,11 +177,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
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,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/d/(\w{10,100})/')
|
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)
|
fileshare = FileShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(fileshare.expire_date)
|
self.assertIsNotNone(fileshare.expire_date)
|
||||||
self.assertIsNotNone(fileshare.password)
|
self.assertIsNotNone(fileshare.password)
|
||||||
@ -196,11 +196,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
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,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/u/d/(\w{10,100})/')
|
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))
|
self.assertIsNotNone(UploadLinkShare.objects.get(token=token))
|
||||||
|
|
||||||
def test_can_create_dir_upload_link_with_password(self):
|
def test_can_create_dir_upload_link_with_password(self):
|
||||||
@ -213,11 +213,11 @@ class FileSharedLinkApiTest(BaseTestCase):
|
|||||||
'application/x-www-form-urlencoded',
|
'application/x-www-form-urlencoded',
|
||||||
)
|
)
|
||||||
self.assertEqual(201, resp.status_code)
|
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,
|
self.assertRegex(self.dir_link_location,
|
||||||
r'http(.*)/u/d/(\w{10,100})/')
|
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)
|
uls = UploadLinkShare.objects.get(token=token)
|
||||||
self.assertIsNotNone(uls.password)
|
self.assertIsNotNone(uls.password)
|
||||||
|
|
||||||
|
@ -10,4 +10,4 @@ class RepoDownloadDirTest(BaseTestCase):
|
|||||||
resp = self.client.get(reverse('repo_download_dir', args=[self.repo.id]) + '?p=' + self.folder)
|
resp = self.client.get(reverse('repo_download_dir', args=[self.repo.id]) + '?p=' + self.folder)
|
||||||
|
|
||||||
self.assertEqual(302, resp.status_code)
|
self.assertEqual(302, resp.status_code)
|
||||||
assert '8082' in resp._headers['location'][1]
|
assert '8082' in resp.headers['location']
|
||||||
|
@ -65,7 +65,6 @@ class UserRemoveTest(BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(302, resp.status_code)
|
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
|
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):
|
def test_can_export_excel(self):
|
||||||
resp = self.client.get(reverse('sys_group_admin_export_excel'))
|
resp = self.client.get(reverse('sys_group_admin_export_excel'))
|
||||||
self.assertEqual(200, resp.status_code)
|
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):
|
class SysUserAdminExportExcelTest(BaseTestCase):
|
||||||
@ -111,7 +110,7 @@ class SysUserAdminExportExcelTest(BaseTestCase):
|
|||||||
def test_can_export_excel(self):
|
def test_can_export_excel(self):
|
||||||
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
||||||
self.assertEqual(200, resp.status_code)
|
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):
|
def write_xls(self, sheet_name, head, data_list):
|
||||||
assert 'Role' in head
|
assert 'Role' in head
|
||||||
@ -126,7 +125,7 @@ class SysUserAdminExportExcelTest(BaseTestCase):
|
|||||||
# mock_write_xls.assert_called_once()
|
# mock_write_xls.assert_called_once()
|
||||||
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
resp = self.client.get(reverse('sys_useradmin_export_excel'))
|
||||||
self.assertEqual(200, resp.status_code)
|
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):
|
class BatchAddUserHelpTest(BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -32,7 +32,6 @@ class UserResetTest(BaseTestCase):
|
|||||||
reverse('user_reset', args=[self.user.email])
|
reverse('user_reset', args=[self.user.email])
|
||||||
)
|
)
|
||||||
self.assertEqual(302, resp.status_code)
|
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)
|
self.assertEqual(len(mail.outbox), 1)
|
||||||
assert mail.outbox[0].to[0] != self.user.username
|
assert mail.outbox[0].to[0] != self.user.username
|
||||||
|
Loading…
Reference in New Issue
Block a user