mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 18:03:48 +00:00
license file type invalid && update test
This commit is contained in:
@@ -31,7 +31,7 @@ class AdminLicense(APIView):
|
|||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
file_type, ext = get_file_type_and_ext(license_file.name)
|
file_type, ext = get_file_type_and_ext(license_file.name)
|
||||||
if file_type != 'txt':
|
if ext != 'txt':
|
||||||
error_msg = file_type_error_msg(ext, 'txt')
|
error_msg = file_type_error_msg(ext, 'txt')
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
|
@@ -5,6 +5,9 @@ from tests.common.common import BASE_URL
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
|
from seahub.utils import PREVIEW_FILEEXT
|
||||||
|
from seahub.utils.file_types import IMAGE
|
||||||
|
from seahub.utils.error_msg import file_type_error_msg
|
||||||
from seahub.settings import MEDIA_ROOT, CUSTOM_FAVICON_PATH
|
from seahub.settings import MEDIA_ROOT, CUSTOM_FAVICON_PATH
|
||||||
|
|
||||||
class AdminFaviconTest(BaseTestCase):
|
class AdminFaviconTest(BaseTestCase):
|
||||||
@@ -58,4 +61,4 @@ class AdminFaviconTest(BaseTestCase):
|
|||||||
resp = self.client.post(logo_url, {'favicon': f})
|
resp = self.client.post(logo_url, {'favicon': f})
|
||||||
json_resp = json.loads(resp.content)
|
json_resp = json.loads(resp.content)
|
||||||
assert resp.status_code == 400
|
assert resp.status_code == 400
|
||||||
assert json_resp['error_msg'] == "Filetype not allowed."
|
assert json_resp['error_msg'] == file_type_error_msg('noico', PREVIEW_FILEEXT.get(IMAGE))
|
||||||
|
@@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
|
|||||||
|
|
||||||
from seahub.api2.endpoints.admin import license as license_api
|
from seahub.api2.endpoints.admin import license as license_api
|
||||||
from seahub.settings import LICENSE_PATH
|
from seahub.settings import LICENSE_PATH
|
||||||
|
from seahub.utils.error_msg import file_type_error_msg
|
||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
from tests.common.utils import urljoin
|
from tests.common.utils import urljoin
|
||||||
from tests.common.common import BASE_URL
|
from tests.common.common import BASE_URL
|
||||||
@@ -42,5 +43,5 @@ class AdminLicenseTest(BaseTestCase):
|
|||||||
resp = self.client.post(url, {'license': f})
|
resp = self.client.post(url, {'license': f})
|
||||||
json_resp = json.loads(resp.content)
|
json_resp = json.loads(resp.content)
|
||||||
assert 400 == resp.status_code
|
assert 400 == resp.status_code
|
||||||
assert "Filetype not allowed." == json_resp['error_msg']
|
assert file_type_error_msg('notxt', 'txt') == json_resp['error_msg']
|
||||||
|
|
||||||
|
@@ -6,6 +6,9 @@ from django.core.urlresolvers import reverse
|
|||||||
|
|
||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
from seahub.settings import MEDIA_ROOT, CUSTOM_LOGO_PATH
|
from seahub.settings import MEDIA_ROOT, CUSTOM_LOGO_PATH
|
||||||
|
from seahub.utils.file_types import IMAGE
|
||||||
|
from seahub.utils import PREVIEW_FILEEXT
|
||||||
|
from seahub.utils.error_msg import file_type_error_msg
|
||||||
|
|
||||||
|
|
||||||
class AdminLogoTest(BaseTestCase):
|
class AdminLogoTest(BaseTestCase):
|
||||||
@@ -62,4 +65,4 @@ class AdminLogoTest(BaseTestCase):
|
|||||||
|
|
||||||
os.remove(image_file)
|
os.remove(image_file)
|
||||||
assert 400 == resp.status_code
|
assert 400 == resp.status_code
|
||||||
assert json_resp['error_msg'] == "Filetype not allowed."
|
assert json_resp['error_msg'] == file_type_error_msg("noimage", PREVIEW_FILEEXT.get('Image'))
|
||||||
|
@@ -6,6 +6,9 @@ from django.core.urlresolvers import reverse
|
|||||||
|
|
||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
from seahub.settings import MEDIA_ROOT, CUSTOM_LOGO_PATH
|
from seahub.settings import MEDIA_ROOT, CUSTOM_LOGO_PATH
|
||||||
|
from seahub.utils import PREVIEW_FILEEXT
|
||||||
|
from seahub.utils.file_types import IMAGE
|
||||||
|
from seahub.utils.error_msg import file_type_error_msg
|
||||||
|
|
||||||
|
|
||||||
class AdminLogoTest(BaseTestCase):
|
class AdminLogoTest(BaseTestCase):
|
||||||
@@ -62,4 +65,4 @@ class AdminLogoTest(BaseTestCase):
|
|||||||
|
|
||||||
os.remove(logo_file)
|
os.remove(logo_file)
|
||||||
assert 400 == resp.status_code
|
assert 400 == resp.status_code
|
||||||
assert json_resp['error_msg'] == "Filetype not allowed."
|
assert json_resp['error_msg'] == file_type_error_msg('noimage', PREVIEW_FILEEXT.get(IMAGE))
|
||||||
|
Reference in New Issue
Block a user