Пример #1
0
 def test_create_pod_no_id_in_manifest(self):
     pdict = apiutils.pod_post_data()
     pdict['manifest'] = {}
     response = self.post_json('/pods', pdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Пример #2
0
 def test_create_pod_no_id_in_manifest(self):
     pdict = apiutils.pod_post_data()
     pdict['manifest'] = {}
     response = self.post_json('/pods', pdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['error_message'])
Пример #3
0
 def test_policy_disallow_create(self):
     bay = obj_utils.create_test_bay(self.context)
     pdict = apiutils.pod_post_data(bay_uuid=bay.uuid)
     self._common_policy_check('pod:create',
                               self.post_json,
                               '/pods',
                               pdict,
                               expect_errors=True)
Пример #4
0
 def test_create_pod_doesnt_contain_id(self):
     with mock.patch.object(self.dbapi, 'create_pod',
                            wraps=self.dbapi.create_pod) as cc_mock:
         pdict = apiutils.pod_post_data(desc='pod_example_A_desc')
         response = self.post_json('/pods', pdict)
         self.assertEqual(pdict['desc'], response.json['desc'])
         cc_mock.assert_called_once_with(mock.ANY)
         # Check that 'id' is not in first arg of positional args
         self.assertNotIn('id', cc_mock.call_args[0][0])
Пример #5
0
    def test_create_pod_generate_uuid(self):
        pdict = apiutils.pod_post_data()
        del pdict['uuid']

        response = self.post_json('/pods', pdict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(pdict['desc'], response.json['desc'])
        self.assertTrue(utils.is_uuid_like(response.json['uuid']))
Пример #6
0
    def test_create_pod_generate_uuid(self):
        pdict = apiutils.pod_post_data()
        del pdict['uuid']

        response = self.post_json('/pods', pdict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(pdict['desc'], response.json['desc'])
        self.assertTrue(utils.is_uuid_like(response.json['uuid']))
Пример #7
0
 def test_create_pod_doesnt_contain_id(self):
     with mock.patch.object(self.dbapi, 'create_pod',
                            wraps=self.dbapi.create_pod) as cc_mock:
         pdict = apiutils.pod_post_data(desc='pod_example_A_desc')
         response = self.post_json('/pods', pdict)
         self.assertEqual(pdict['desc'], response.json['desc'])
         cc_mock.assert_called_once_with(mock.ANY)
         # Check that 'id' is not in first arg of positional args
         self.assertNotIn('id', cc_mock.call_args[0][0])
Пример #8
0
    def test_create_pod_set_project_id_and_user_id(self):
        pdict = apiutils.pod_post_data()

        def _simulate_rpc_pod_create(pod):
            self.assertEqual(pod.project_id, self.context.project_id)
            self.assertEqual(pod.user_id, self.context.user_id)
            return pod
        self.mock_pod_create.side_effect = _simulate_rpc_pod_create

        self.post_json('/pods', pdict)
Пример #9
0
    def test_create_pod_generate_uuid(self, mock_pod_create):
        pdict = apiutils.pod_post_data()
        del pdict['uuid']

        mock_pod_create.return_value = self.pod_obj
        response = self.post_json('/pods', pdict, expect_errors=True)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(pdict['desc'], response.json['desc'])
        self.assertTrue(utils.is_uuid_like(response.json['uuid']))
Пример #10
0
    def test_create_pod(self, mock_rc_create, mock_utcnow):
        pdict = apiutils.pod_post_data()
        test_time = datetime.datetime(2000, 1, 1, 0, 0)
        mock_utcnow.return_value = test_time

        mock_rc_create.return_value = self.pod_obj
        response = self.post_json('/pods', pdict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        # Check location header
        self.assertIsNotNone(response.location)
        expected_location = '/v1/pods/%s' % pdict['uuid']
        self.assertEqual(expected_location,
                         urlparse.urlparse(response.location).path)
        self.assertEqual(pdict['uuid'], response.json['uuid'])
        self.assertNotIn('updated_at', response.json.keys)
Пример #11
0
 def test_create_pod_with_non_existent_bay_uuid(self):
     pdict = apiutils.pod_post_data(bay_uuid=utils.generate_uuid())
     response = self.post_json('/pods', pdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['error_message'])
Пример #12
0
 def test_create_pod_no_bay_uuid(self):
     pdict = apiutils.pod_post_data()
     del pdict['bay_uuid']
     response = self.post_json('/pods', pdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
Пример #13
0
 def test_policy_disallow_create(self):
     pdict = apiutils.pod_post_data()
     self._common_policy_check(
         'pod:create', self.post_json, '/pods', pdict)
Пример #14
0
 def test_pod_init(self):
     pod_dict = apiutils.pod_post_data(bay_uuid=None)
     del pod_dict['desc']
     pod = api_pod.Pod(**pod_dict)
     self.assertEqual(wtypes.Unset, pod.desc)
Пример #15
0
 def test_policy_disallow_create(self):
     bay = obj_utils.create_test_bay(self.context)
     pdict = apiutils.pod_post_data(bay_uuid=bay.uuid)
     self._common_policy_check(
         'pod:create', self.post_json, '/pods', pdict, expect_errors=True)
Пример #16
0
 def test_pod_init(self):
     pod_dict = apiutils.pod_post_data(bay_uuid=None)
     del pod_dict['desc']
     pod = api_pod.Pod(**pod_dict)
     self.assertEqual(wtypes.Unset, pod.desc)
Пример #17
0
 def test_create_pod_with_non_existent_bay_uuid(self):
     pdict = apiutils.pod_post_data(bay_uuid=utils.generate_uuid())
     response = self.post_json('/pods', pdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Пример #18
0
 def test_create_pod_doesnt_contain_id(self, mock_pod_create):
     pdict = apiutils.pod_post_data(desc='pod_example_A_desc')
     mock_pod_create.return_value = self.pod_obj
     mock_pod_create.return_value.desc = 'pod_example_A_desc'
     response = self.post_json('/pods', pdict)
     self.assertEqual(pdict['desc'], response.json['desc'])
Пример #19
0
 def test_policy_disallow_create(self):
     pdict = apiutils.pod_post_data()
     self._common_policy_check('pod:create', self.post_json, '/pods', pdict)
Пример #20
0
 def test_create_pod_no_bay_uuid(self):
     pdict = apiutils.pod_post_data()
     del pdict['bay_uuid']
     response = self.post_json('/pods', pdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)