mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-27 02:51:00 +00:00
[tests] Add tests
This commit is contained in:
parent
13834d3a67
commit
3dcdb7aec2
0
tests/api/views/__init__.py
Normal file
0
tests/api/views/__init__.py
Normal file
25
tests/api/views/test_default_repo.py
Normal file
25
tests/api/views/test_default_repo.py
Normal file
@ -0,0 +1,25 @@
|
||||
import json
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from seahub.test_utils import BaseTestCase
|
||||
|
||||
|
||||
class DefaultRepoViewTest(BaseTestCase):
|
||||
def setUp(self, ):
|
||||
self.url = reverse('api2-defaultrepo')
|
||||
self.login_as(self.user)
|
||||
|
||||
def test_get_none_exists(self, ):
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
json_resp = json.loads(resp.content)
|
||||
assert json_resp['exists'] is False
|
||||
|
||||
def test_create(self, ):
|
||||
resp = self.client.post(self.url)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
json_resp = json.loads(resp.content)
|
||||
assert json_resp['exists'] is True
|
||||
assert len(json_resp['repo_id']) == 36
|
21
tests/api/views/test_download_repo.py
Normal file
21
tests/api/views/test_download_repo.py
Normal file
@ -0,0 +1,21 @@
|
||||
import json
|
||||
|
||||
from seahub.test_utils import BaseTestCase
|
||||
|
||||
|
||||
class DownloadRepoViewTest(BaseTestCase):
|
||||
def test_get(self, ):
|
||||
url = '/api2/repos/%s/download-info/' % self.repo.id
|
||||
self.login_as(self.user)
|
||||
|
||||
resp = self.client.get(url)
|
||||
|
||||
info = json.loads(resp.content)
|
||||
self.assertIsNotNone(info['relay_addr'])
|
||||
self.assertIsNotNone(info['token'])
|
||||
self.assertIsNotNone(info['repo_id'])
|
||||
self.assertIsNotNone(info['relay_port'])
|
||||
self.assertIsNotNone(info['encrypted'])
|
||||
self.assertIsNotNone(info['repo_name'])
|
||||
self.assertIsNotNone(info['relay_id'])
|
||||
self.assertIsNotNone(info['email'])
|
Loading…
Reference in New Issue
Block a user