mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 19:01:42 +00:00
upload with invalid type
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import json
|
||||
from mock import patch
|
||||
from mock import patch
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from seahub.api2.endpoints.admin import license as license_api
|
||||
@@ -22,8 +22,25 @@ class AdminLicenseTest(BaseTestCase):
|
||||
url = urljoin(BASE_URL, url)
|
||||
with open(
|
||||
os.path.join(os.getcwd(), 'tests/seahub/utils/seafile-license.txt')) as f:
|
||||
json_resp = self.client.post(url, {'license': f})
|
||||
json_resp = json.loads(json_resp.content)
|
||||
resp = self.client.post(url, {'license': f})
|
||||
json_resp = json.loads(resp.content)
|
||||
|
||||
assert json_resp['success'] is True
|
||||
assert os.path.exists(LICENSE_PATH)
|
||||
|
||||
@patch.object(license_api, 'ccnet_api')
|
||||
def test_update_license_with_invalid_type(self, mock_ccnet_api):
|
||||
mock_ccnet_api.return_val = {}
|
||||
|
||||
url = reverse('api-v2.1-admin-license')
|
||||
url = urljoin(BASE_URL, url)
|
||||
with open('temp.notxt', 'w') as f:
|
||||
f.write('1')
|
||||
|
||||
with open(
|
||||
os.path.join(os.getcwd(), 'temp.notxt')) as f:
|
||||
resp = self.client.post(url, {'license': f})
|
||||
json_resp = json.loads(resp.content)
|
||||
assert 400 == resp.status_code
|
||||
assert "Filetype not allowed." == json_resp['error_msg']
|
||||
|
||||
|
Reference in New Issue
Block a user