예제 #1
0
파일: tests.py 프로젝트: cy0713/controller
    def test_update_tenant_group_ok(self):
        gtenant_id = '1'
        tenant_group_data = {
            'name':
            'group1',
            'attached_projects':
            json.dumps(['0123456789abcdef', 'abcdef0123456789', '3333333333'])
        }
        request = self.factory.put('/projects/groups/' + gtenant_id,
                                   tenant_group_data,
                                   format='json')
        response = projects_group_detail(request, gtenant_id)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Check the object type was updated properly
        request = self.factory.get('/projects/groups')
        response = add_projects_group(request)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        tenants_groups = json.loads(response.content)
        self.assertEqual(len(tenants_groups), 1)  # 1 group
        self.assertEqual(len(tenants_groups[0]['attached_projects']),
                         3)  # 3 tenants in the group
        self.assertTrue(
            '0123456789abcdef' in tenants_groups[0]['attached_projects'])
        self.assertTrue(
            'abcdef0123456789' in tenants_groups[0]['attached_projects'])
        self.assertTrue('3333333333' in tenants_groups[0]['attached_projects'])
예제 #2
0
파일: tests.py 프로젝트: cy0713/controller
 def test_tenant_group_detail_ok(self):
     gtenant_id = '1'
     request = self.factory.get('/projects/groups/' + gtenant_id)
     response = projects_group_detail(request, gtenant_id)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     response = json.loads(response.content)
     self.assertEqual(response['name'], 'group1')
     tenant_list = response['attached_projects']
     self.assertEqual(len(tenant_list), 2)
     self.assertTrue('0123456789abcdef' in tenant_list)
     self.assertTrue('abcdef0123456789' in tenant_list)
예제 #3
0
파일: tests.py 프로젝트: cy0713/controller
    def test_delete_tenant_group_ok(self):
        gtenant_id = '1'
        request = self.factory.delete('/projects/groups/' + gtenant_id)
        response = projects_group_detail(request, gtenant_id)
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

        request = self.factory.get('/projects/groups')
        response = add_projects_group(request)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.content, "[]")
        tenants_groups = json.loads(response.content)
        self.assertEqual(len(tenants_groups), 0)
예제 #4
0
파일: tests.py 프로젝트: cy0713/controller
 def test_update_tenant_group_with_non_existent_id(self):
     gtenant_id = '2'
     tenant_group_data = {
         'name':
         'group1',
         'attached_projects':
         json.dumps(['0123456789abcdef', 'abcdef0123456789', '3333333333'])
     }
     request = self.factory.put('/projects/groups/' + gtenant_id,
                                tenant_group_data,
                                format='json')
     response = projects_group_detail(request, gtenant_id)
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
예제 #5
0
파일: tests.py 프로젝트: cy0713/controller
 def test_tenants_group_detail_with_method_not_allowed(self):
     gtenant_id = 1
     tenant_group_data = {
         'name':
         'group1',
         'attached_projects':
         json.dumps(['0123456789abcdef', 'abcdef0123456789'])
     }
     request = self.factory.post('/projects/groups/' + str(gtenant_id),
                                 tenant_group_data,
                                 format='json')
     response = projects_group_detail(request, gtenant_id)
     self.assertEqual(response.status_code,
                      status.HTTP_405_METHOD_NOT_ALLOWED)
예제 #6
0
파일: tests.py 프로젝트: cy0713/controller
    def test_delete_tenant_group_with_non_existent_id(self):
        gtenant_id = '2'
        request = self.factory.delete('/projects/groups/' + gtenant_id)
        response = projects_group_detail(request, gtenant_id)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

        # Check nothing was deleted
        request = self.factory.get('/projects/groups')
        response = add_projects_group(request)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertNotEqual(response.content, "[]")
        tenants_groups = json.loads(response.content)
        self.assertEqual(len(tenants_groups), 1)  # 1 group
        self.assertEqual(len(tenants_groups[0]['attached_projects']),
                         2)  # 2 tenants in the group
예제 #7
0
파일: tests.py 프로젝트: cy0713/controller
 def test_tenant_group_detail_with_non_existent_id(self):
     gtenant_id = '2'
     request = self.factory.get('/projects/groups/' + gtenant_id)
     response = projects_group_detail(request, gtenant_id)
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)