mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-12 12:22:13 +00:00
[tests] add web api test for miscs
This commit is contained in:
parent
913dcf694a
commit
ba84dc87b3
@ -3,3 +3,7 @@ import os
|
|||||||
BASE_URL = os.getenv('CI_BASE_URL', u'http://127.0.0.1:8000')
|
BASE_URL = os.getenv('CI_BASE_URL', u'http://127.0.0.1:8000')
|
||||||
USERNAME = os.getenv('CI_USERNAME', u'test@test.com')
|
USERNAME = os.getenv('CI_USERNAME', u'test@test.com')
|
||||||
PASSWORD = os.getenv('CI_PASSWORD', u'testtest')
|
PASSWORD = os.getenv('CI_PASSWORD', u'testtest')
|
||||||
|
if os.getenv('CI_IS_PRO', u'') == u'':
|
||||||
|
IS_PRO = False
|
||||||
|
else:
|
||||||
|
IS_PRO = True
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from common.common import BASE_URL, USERNAME, PASSWORD
|
from common.common import BASE_URL, USERNAME, PASSWORD, IS_PRO
|
||||||
import requests, re
|
import requests, re
|
||||||
|
|
||||||
BASE_URL = BASE_URL
|
BASE_URL = BASE_URL
|
||||||
@ -31,6 +31,9 @@ AVATAR_BASE_URL = BASE_URL + u'/api2/avatars/'
|
|||||||
|
|
||||||
STARREDFILES_URL = BASE_URL + u'/api2/starredfiles/'
|
STARREDFILES_URL = BASE_URL + u'/api2/starredfiles/'
|
||||||
|
|
||||||
|
MISC_LIST_GROUP_AND_CONTACTS_URL = BASE_URL + u'/api2/groupandcontacts/'
|
||||||
|
MISC_LIST_EVENTS_URL = BASE_URL + u'/api2/events/'
|
||||||
|
|
||||||
META_AUTH = {'username': USERNAME, 'password': PASSWORD}
|
META_AUTH = {'username': USERNAME, 'password': PASSWORD}
|
||||||
|
|
||||||
def get_auth_token():
|
def get_auth_token():
|
||||||
|
44
tests/integration_api/misc.py
Normal file
44
tests/integration_api/misc.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
from integration_api import MISC_LIST_EVENTS_URL, MISC_LIST_GROUP_AND_CONTACTS_URL
|
||||||
|
from integration_api import get_authed_instance, IS_PRO
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class MiscApiTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.requests = get_authed_instance()
|
||||||
|
self.assertIsNotNone(self.requests)
|
||||||
|
|
||||||
|
def testListGroupAndContactsApi(self):
|
||||||
|
res = self.requests.get(MISC_LIST_GROUP_AND_CONTACTS_URL)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
json = res.json()
|
||||||
|
self.assertIsNotNone(json)
|
||||||
|
self.assertIsNotNone(json['contacts'])
|
||||||
|
self.assertIsNotNone(json['umsgnum'])
|
||||||
|
self.assertIsNotNone(json['replynum'])
|
||||||
|
self.assertIsNotNone(json['groups'])
|
||||||
|
self.assertIsNotNone(json['gmsgnum'])
|
||||||
|
self.assertIsNotNone(json['newreplies'])
|
||||||
|
|
||||||
|
def testListEventsApi(self):
|
||||||
|
# if not pro, skip this
|
||||||
|
if (IS_PRO == False):
|
||||||
|
return
|
||||||
|
res = self.requests.get(MISC_LIST_EVENTS_URL)
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
json = res.json()
|
||||||
|
self.assertIsNotNone(json)
|
||||||
|
self.assertIsNotNone(json['more_offset'])
|
||||||
|
self.assertIsNotNone(json['events'])
|
||||||
|
self.assertIsNotNone(json['more'])
|
||||||
|
for repo in json['events']:
|
||||||
|
self.assertIsNotNone(repo['repo_id'])
|
||||||
|
self.assertIsNotNone(repo['author'])
|
||||||
|
self.assertIsNotNone(repo['nick'])
|
||||||
|
self.assertIsNotNone(repo['time'])
|
||||||
|
self.assertIsNotNone(repo['etype'])
|
||||||
|
self.assertIsNotNone(repo['repo_name'])
|
||||||
|
self.assertIsNotNone(repo['desc'])
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(verbosity=2)
|
@ -17,6 +17,7 @@ def suite():
|
|||||||
from integration_api.avatar import AvatarApiTestCase
|
from integration_api.avatar import AvatarApiTestCase
|
||||||
|
|
||||||
from integration_api.starredfiles import StarredFilesApiTestCase
|
from integration_api.starredfiles import StarredFilesApiTestCase
|
||||||
|
from integration_api.misc import MiscApiTestCase
|
||||||
integration_api_suite = unittest.TestSuite((\
|
integration_api_suite = unittest.TestSuite((\
|
||||||
unittest.makeSuite(PingApiTestCase),
|
unittest.makeSuite(PingApiTestCase),
|
||||||
unittest.makeSuite(AuthPingApiTestCase),
|
unittest.makeSuite(AuthPingApiTestCase),
|
||||||
@ -27,6 +28,7 @@ def suite():
|
|||||||
unittest.makeSuite(GroupMsgsApiTestCase),
|
unittest.makeSuite(GroupMsgsApiTestCase),
|
||||||
unittest.makeSuite(AvatarApiTestCase),
|
unittest.makeSuite(AvatarApiTestCase),
|
||||||
#unittest.makeSuite(StarredFilesApiTestCase),
|
#unittest.makeSuite(StarredFilesApiTestCase),
|
||||||
|
unittest.makeSuite(MiscApiTestCase),
|
||||||
))
|
))
|
||||||
|
|
||||||
return unittest.TestSuite([integration_api_suite, integration_suite])
|
return unittest.TestSuite([integration_api_suite, integration_suite])
|
||||||
|
Loading…
Reference in New Issue
Block a user