[879b32]: / qiita_db / handlers / tests / test_studies.py

Download this file

38 lines (28 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
from unittest import main
from json import loads
from qiita_db.handlers.tests.oauthbase import OauthTestingBase
class TestAPIStudiesListing(OauthTestingBase):
def setUp(self):
super(TestAPIStudiesListing, self).setUp()
def test_get_studies_failure(self):
obs = self.get('/qiita_db/studies/not-valid', headers=self.header)
self.assertEqual(obs.code, 403)
self.assertEqual(str(obs.error), 'HTTP 403: You can only request '
'public or private studies')
def test_get_studies_private(self):
obs = self.get('/qiita_db/studies/private', headers=self.header)
exp = {'data': {'1': [4, 5, 6, 7]}}
self.assertEqual(loads(obs.body), exp)
def test_get_studies_public(self):
obs = self.get('/qiita_db/studies/public', headers=self.header)
exp = {'data': {}}
self.assertEqual(loads(obs.body), exp)
if __name__ == '__main__':
main()