mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +00:00
[tests] add web api test for avatar service
This commit is contained in:
@@ -27,6 +27,7 @@ GROUP_URL = BASE_URL + u'/api2/group/'
|
||||
GROUPS_URL = BASE_URL + u'/api2/groups/'
|
||||
GROUPMSGS_URL = BASE_URL + u'/api2/group/msgs/'
|
||||
GROUPMSGS_NREPLY_URL = BASE_URL + u'/api2/new_replies/'
|
||||
AVATAR_BASE_URL = BASE_URL + u'/api2/avatars/'
|
||||
|
||||
STARREDFILES_URL = BASE_URL + u'/api2/starredfiles/'
|
||||
|
||||
|
35
tests/integration_api/avatar.py
Normal file
35
tests/integration_api/avatar.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from integration_api import AVATAR_BASE_URL, get_authed_instance
|
||||
from integration_api import GROUPS_URL, USERNAME
|
||||
from common.utils import randomword
|
||||
import unittest
|
||||
|
||||
class AvatarApiTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.requests = get_authed_instance()
|
||||
self.assertIsNotNone(self.requests)
|
||||
|
||||
def testUserAvatarApi(self):
|
||||
res = self.requests.get(AVATAR_BASE_URL + u'user/' + USERNAME + u'/resized/80/')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
json = res.json()
|
||||
self.assertIsNotNone(json)
|
||||
self.assertIsNotNone(json['url'])
|
||||
self.assertIsNotNone(json['is_default'])
|
||||
self.assertIsNotNone(json['mtime'])
|
||||
|
||||
def testGroupAvatarApi(self):
|
||||
gname = randomword(16)
|
||||
data = { 'group_name': gname }
|
||||
res = self.requests.put(GROUPS_URL, data=data)
|
||||
gid = res.json()['group_id']
|
||||
res = self.requests.get(AVATAR_BASE_URL + u'group/' + str(gid) + u'/resized/80/')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
json = res.json()
|
||||
self.assertIsNotNone(json)
|
||||
self.assertIsNotNone(json['url'])
|
||||
self.assertIsNotNone(json['is_default'])
|
||||
self.assertIsNotNone(json['mtime'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
@@ -14,6 +14,7 @@ def suite():
|
||||
from integration_api.groups import GroupsApiTestCase
|
||||
from integration_api.gmembers import GroupMemeberApiTestCase
|
||||
from integration_api.groupmsgs import GroupMsgsApiTestCase
|
||||
from integration_api.avatar import AvatarApiTestCase
|
||||
|
||||
from integration_api.starredfiles import StarredFilesApiTestCase
|
||||
integration_api_suite = unittest.TestSuite((\
|
||||
@@ -24,6 +25,7 @@ def suite():
|
||||
unittest.makeSuite(GroupsApiTestCase),
|
||||
unittest.makeSuite(GroupMemeberApiTestCase),
|
||||
unittest.makeSuite(GroupMsgsApiTestCase),
|
||||
unittest.makeSuite(AvatarApiTestCase),
|
||||
#unittest.makeSuite(StarredFilesApiTestCase),
|
||||
))
|
||||
|
||||
|
Reference in New Issue
Block a user