示例#1
0
文件: test_api.py 项目: smn/formhub
 def _org_create(self):
     view = OrgProfileViewSet.as_view({'get': 'list', 'post': 'create'})
     request = self.factory.get('/', **self.extra)
     response = view(request)
     self.assertEqual(response.status_code, 200)
     data = {
         'org': u'denoinc',
         'name': u'Dennis',
         # 'email': u'*****@*****.**',
         'city': u'Denoville',
         'country': u'US',
         #'organization': u'Dono Inc.',
         'home_page': u'deno.com',
         'twitter': u'denoinc',
         'description': u'',
         'address': u'',
         'phonenumber': u'',
         'require_auth': False,
         # 'password': '******',
     }
     # response = self.client.post(
     request = self.factory.post('/',
                                 data=json.dumps(data),
                                 content_type="application/json",
                                 **self.extra)
     response = view(request)
     self.assertEqual(response.status_code, 201)
     data['url'] = 'http://testserver/api/v1/orgs/denoinc'
     data['user'] = '******'
     data['creator'] = 'http://testserver/api/v1/users/bob'
     self.assertEqual(response.data, data)
     self.company_data = response.data
     self.organization = OrganizationProfile.objects.get(
         user__username=data['org'])
示例#2
0
 def test_orgs_get(self):
     self._org_create()
     view = OrgProfileViewSet.as_view({'get': 'retrieve'})
     request = self.factory.get('/', **self.extra)
     response = view(request)
     self.assertEqual(response.status_code, 400)
     self.assertEqual(response.data,
                      {'detail': 'Expected URL keyword argument `user`.'})
     request = self.factory.get('/', **self.extra)
     response = view(request, user='******')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data, self.company_data)
示例#3
0
 def test_orgs_get(self):
     self._org_create()
     view = OrgProfileViewSet.as_view({
         'get': 'retrieve'
     })
     request = self.factory.get('/', **self.extra)
     response = view(request)
     self.assertEqual(response.status_code, 400)
     self.assertEqual(
         response.data, {'detail': 'Expected URL keyword argument `user`.'})
     request = self.factory.get('/', **self.extra)
     response = view(request, user='******')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data, self.company_data)
示例#4
0
 def _org_create(self):
     view = OrgProfileViewSet.as_view({
         'get': 'list',
         'post': 'create'
     })
     request = self.factory.get('/', **self.extra)
     response = view(request)
     self.assertEqual(response.status_code, 200)
     data = {
         'org': u'denoinc',
         'name': u'Dennis',
         # 'email': u'*****@*****.**',
         'city': u'Denoville',
         'country': u'US',
         #'organization': u'Dono Inc.',
         'home_page': u'deno.com',
         'twitter': u'denoinc',
         'description': u'',
         'address': u'',
         'phonenumber': u'',
         'require_auth': False,
         # 'password': '******',
     }
     # response = self.client.post(
     request = self.factory.post(
         '/', data=json.dumps(data),
         content_type="application/json", **self.extra)
     response = view(request)
     self.assertEqual(response.status_code, 201)
     data['url'] = 'http://testserver/api/v1/orgs/denoinc'
     data['user'] = '******'
     data['creator'] = 'http://testserver/api/v1/users/bob'
     self.assertDictContainsSubset(data, response.data)
     self.company_data = response.data
     self.organization = OrganizationProfile.objects.get(
         user__username=data['org'])
示例#5
0
 def setUp(self):
     super(TestOrgsAPI, self).setUp()
     self.view = OrgProfileViewSet.as_view({
         'get': 'list',
         'post': 'create'
     })
示例#6
0
 def setUp(self):
     super(TestOrgsAPI, self).setUp()
     self.view = OrgProfileViewSet.as_view({
         'get': 'list',
         'post': 'create'
     })