1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 18:30:53 +00:00

[api] admin library history limit

This commit is contained in:
zming
2017-08-01 10:13:13 +08:00
parent 534a56ce15
commit 466ef48116
3 changed files with 127 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import json
from django.core.urlresolvers import reverse
from seahub.test_utils import BaseTestCase
class LibraryHistory(BaseTestCase):
def setUp(self):
self.login_as(self.admin)
self.repo_id = self.repo.id
self.url = reverse('api-v2.1-admin-library-history-limit', kwargs=dict(repo_id=self.repo_id))
def test_can_get(self):
resp = self.client.get(self.url)
self.assertEqual(200, resp.status_code)
def test_can_put(self):
data = "keep_days=-1"
resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded')
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
self.assertEqual(-1, json_resp['keep_days'])
data = "keep_days=0"
resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded')
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
self.assertEqual(0, json_resp['keep_days'])
data = "keep_days=8"
resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded')
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
self.assertEqual(8, json_resp['keep_days'])
data = "keep_days=q"
resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded')
self.assertEqual(400, resp.status_code)