コード例 #1
0
 def test_create_bay_with_non_existent_baymodel_id(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data(baymodel_id=utils.generate_uuid())
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['error_message'])
コード例 #2
0
 def test_create_bay_no_baymodel_id(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     del bdict['baymodel_id']
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
コード例 #3
0
 def test_policy_disallow_create(self):
     bdict = apiutils.bay_post_data(name='bay_example_A')
     self._common_policy_check("bay:create",
                               self.post_json,
                               '/bays',
                               bdict,
                               expect_errors=True)
コード例 #4
0
 def test_create_bay_with_on_os_distro_image(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     mock_valid_os_res.side_effect = exception.OSDistroFieldNotFound('img')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(mock_valid_os_res.called)
     self.assertEqual(400, response.status_int)
コード例 #5
0
 def test_create_bay_with_timeout_negative(self):
     bdict = apiutils.bay_post_data()
     bdict['bay_create_timeout'] = -1
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
コード例 #6
0
 def test_create_bay_with_multi_images_same_name(self):
     bdict = apiutils.bay_post_data()
     self.mock_valid_os_res.side_effect = exception.Conflict('test-img')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(self.mock_valid_os_res.called)
     self.assertEqual(409, response.status_int)
コード例 #7
0
 def test_create_bay_with_invalid_flavor(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     mock_valid_os_res.side_effect = exception.FlavorNotFound('test-flavor')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(mock_valid_os_res.called)
     self.assertEqual(404, response.status_int)
コード例 #8
0
 def test_create_bay_with_timeout_zero(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     bdict['bay_create_timeout'] = 0
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
コード例 #9
0
 def test_create_bay_without_name(self):
     bdict = apiutils.bay_post_data()
     del bdict['name']
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertIsNotNone(response.json['name'])
コード例 #10
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
 def test_create_bay_with_non_existent_baymodel_id(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data(baymodel_id=utils.generate_uuid())
     mock_valid_os_res.return_value = None
     response = self.post_json("/bays", bdict, expect_errors=True)
     self.assertEqual("application/json", response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json["error_message"])
コード例 #11
0
ファイル: test_bay.py プロジェクト: pkdevboxy/magnum
 def test_create_bay_with_timeout_zero(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     bdict['bay_create_timeout'] = 0
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
コード例 #12
0
ファイル: test_bay.py プロジェクト: pkdevboxy/magnum
 def test_create_bay_with_invalid_empty_name(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data(name='')
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['error_message'])
コード例 #13
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_with_timeout_negative(self):
     bdict = apiutils.bay_post_data()
     bdict['bay_create_timeout'] = -1
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
コード例 #14
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_with_multi_images_same_name(self):
     bdict = apiutils.bay_post_data()
     self.mock_valid_os_res.side_effect = exception.Conflict('test-img')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(self.mock_valid_os_res.called)
     self.assertEqual(409, response.status_int)
コード例 #15
0
 def test_create_bay_with_master_count_zero(self):
     bdict = apiutils.bay_post_data()
     bdict['master_count'] = 0
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
コード例 #16
0
ファイル: test_bay.py プロジェクト: pkdevboxy/magnum
 def test_create_bay_no_baymodel_id(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     del bdict['baymodel_id']
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
コード例 #17
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_without_name(self):
     bdict = apiutils.bay_post_data()
     del bdict['name']
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertIsNotNone(response.json['name'])
コード例 #18
0
 def test_create_bay_with_invalid_empty_name(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data(name='')
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['error_message'])
コード例 #19
0
ファイル: test_bay.py プロジェクト: pkdevboxy/magnum
 def test_create_bay_with_invalid_keypair(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     mock_valid_os_res.side_effect = exception.KeyPairNotFound('test-key')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(mock_valid_os_res.called)
     self.assertEqual(404, response.status_int)
コード例 #20
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_with_master_count_zero(self):
     bdict = apiutils.bay_post_data()
     bdict['master_count'] = 0
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
コード例 #21
0
ファイル: test_bay.py プロジェクト: pkdevboxy/magnum
 def test_create_bay_with_on_os_distro_image(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     mock_valid_os_res.side_effect = exception.OSDistroFieldNotFound('img')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(mock_valid_os_res.called)
     self.assertEqual(404, response.status_int)
コード例 #22
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_with_no_master_count(self):
     bdict = apiutils.bay_post_data()
     del bdict['master_count']
     response = self.post_json('/bays', bdict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(1, response.json['master_count'])
コード例 #23
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
 def test_create_bay_with_nonexist_image(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     mock_valid_os_res.side_effect = exception.ImageNotFound("test-img")
     response = self.post_json("/bays", bdict, expect_errors=True)
     self.assertEqual("application/json", response.content_type)
     self.assertTrue(mock_valid_os_res.called)
     self.assertEqual(404, response.status_int)
コード例 #24
0
 def test_create_bay_with_no_master_count(self):
     bdict = apiutils.bay_post_data()
     del bdict['master_count']
     response = self.post_json('/bays', bdict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(1, response.json['master_count'])
コード例 #25
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
 def test_create_bay_with_timeout_none(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     bdict["bay_create_timeout"] = None
     mock_valid_os_res.return_value = None
     response = self.post_json("/bays", bdict, expect_errors=True)
     self.assertEqual("application/json", response.content_type)
     self.assertEqual(201, response.status_int)
コード例 #26
0
ファイル: test_bay.py プロジェクト: ragnaray/magnum
 def test_create_bay_with_docker_volume_size(self):
     bdict = apiutils.bay_post_data()
     bdict['docker_volume_size'] = 3
     response = self.post_json('/bays', bdict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     bay, timeout = self.mock_bay_create.call_args
     self.assertEqual(3, bay[0].docker_volume_size)
コード例 #27
0
 def test_create_bay_with_docker_volume_size(self):
     bdict = apiutils.bay_post_data()
     bdict['docker_volume_size'] = 3
     response = self.post_json('/bays', bdict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     bay, timeout = self.mock_bay_create.call_args
     self.assertEqual(3, bay[0].docker_volume_size)
コード例 #28
0
 def test_create_bay_with_no_lb_multi_node(self):
     cluster_template = obj_utils.create_test_cluster_template(
         self.context, name='foo', uuid='foo', master_lb_enabled=False)
     bdict = apiutils.bay_post_data(baymodel_id=cluster_template.name,
                                    master_count=3)
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
コード例 #29
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
 def test_create_bay_with_no_master_count(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     del bdict["master_count"]
     mock_valid_os_res.return_value = None
     response = self.post_json("/bays", bdict)
     self.assertEqual("application/json", response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(1, response.json["master_count"])
コード例 #30
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
 def test_create_bay_with_master_count_zero(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     bdict["master_count"] = 0
     mock_valid_os_res.return_value = None
     response = self.post_json("/bays", bdict, expect_errors=True)
     self.assertEqual("application/json", response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json["error_message"])
コード例 #31
0
ファイル: test_bay.py プロジェクト: pkdevboxy/magnum
 def test_create_bay_with_no_node_count(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     del bdict['node_count']
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(1, response.json['node_count'])
コード例 #32
0
 def test_create_bay_with_no_node_count(self, mock_valid_os_res):
     bdict = apiutils.bay_post_data()
     del bdict['node_count']
     mock_valid_os_res.return_value = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(1, response.json['node_count'])
コード例 #33
0
 def test_create_bay_with_invalid_ext_network(self):
     bdict = apiutils.bay_post_data()
     self.mock_valid_os_res.side_effect = exception.NetworkNotFound(
         'test-net')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(self.mock_valid_os_res.called)
     self.assertEqual(400, response.status_int)
コード例 #34
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_with_invalid_ext_network(self):
     bdict = apiutils.bay_post_data()
     self.mock_valid_os_res.side_effect = exception.ExternalNetworkNotFound(
         'test-net')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(self.mock_valid_os_res.called)
     self.assertEqual(400, response.status_int)
コード例 #35
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_with_no_lb_multi_node(self):
     baymodel = obj_utils.create_test_baymodel(
         self.context, name='foo', uuid='foo', master_lb_enabled=False)
     bdict = apiutils.bay_post_data(baymodel_id=baymodel.name,
                                    master_count=3)
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
コード例 #36
0
 def test_bay_init(self):
     bay_dict = apiutils.bay_post_data(baymodel_id=None)
     del bay_dict['node_count']
     del bay_dict['master_count']
     del bay_dict['bay_create_timeout']
     bay = api_bay.Bay(**bay_dict)
     self.assertEqual(1, bay.node_count)
     self.assertEqual(1, bay.master_count)
     self.assertEqual(0, bay.bay_create_timeout)
コード例 #37
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
 def test_create_bay_doesnt_contain_id(self, mock_valid_os_res):
     with mock.patch.object(self.dbapi, "create_bay", wraps=self.dbapi.create_bay) as cc_mock:
         bdict = apiutils.bay_post_data(name="bay_example_A")
         mock_valid_os_res.return_value = None
         response = self.post_json("/bays", bdict)
         self.assertEqual(bdict["name"], response.json["name"])
         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])
コード例 #38
0
    def test_create_bay_generate_uuid(self):
        bdict = apiutils.bay_post_data()
        del bdict['uuid']

        response = self.post_json('/bays', bdict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(bdict['name'], response.json['name'])
        self.assertTrue(uuidutils.is_uuid_like(response.json['uuid']))
コード例 #39
0
ファイル: test_bay.py プロジェクト: drzaeus77/magnum
 def test_create_bay_doesnt_contain_id(self):
     with mock.patch.object(self.dbapi, 'create_bay',
                            wraps=self.dbapi.create_bay) as cc_mock:
         bdict = apiutils.bay_post_data(name='bay_example_A')
         response = self.post_json('/bays', bdict)
         self.assertEqual(bdict['name'], response.json['name'])
         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])
コード例 #40
0
ファイル: test_bay.py プロジェクト: ragnaray/magnum
 def test_as_dict_faults(self):
     bay_dict = apiutils.bay_post_data(baymodel_id=None)
     del bay_dict['node_count']
     del bay_dict['master_count']
     del bay_dict['bay_create_timeout']
     bay = api_bay.Bay(**bay_dict)
     bay.bay_faults = {'testfault': 'fault'}
     dict = bay.as_dict()
     self.assertEqual({'testfault': 'fault'}, dict['faults'])
コード例 #41
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_doesnt_contain_id(self):
     with mock.patch.object(self.dbapi, 'create_bay',
                            wraps=self.dbapi.create_bay) as cc_mock:
         bdict = apiutils.bay_post_data(name='bay_example_A')
         response = self.post_json('/bays', bdict)
         self.assertEqual(bdict['name'], response.json['name'])
         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])
コード例 #42
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
    def test_create_bay_generate_uuid(self):
        bdict = apiutils.bay_post_data()
        del bdict['uuid']

        response = self.post_json('/bays', bdict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(bdict['name'], response.json['name'])
        self.assertTrue(uuidutils.is_uuid_like(response.json['uuid']))
コード例 #43
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_bay_init(self):
     bay_dict = apiutils.bay_post_data(baymodel_id=None)
     del bay_dict['node_count']
     del bay_dict['master_count']
     del bay_dict['bay_create_timeout']
     bay = api_bay.Bay(**bay_dict)
     self.assertEqual(1, bay.node_count)
     self.assertEqual(1, bay.master_count)
     self.assertEqual(60, bay.bay_create_timeout)
コード例 #44
0
 def test_as_dict_faults(self):
     bay_dict = apiutils.bay_post_data(baymodel_id=None)
     del bay_dict['node_count']
     del bay_dict['master_count']
     del bay_dict['bay_create_timeout']
     bay = api_bay.Bay(**bay_dict)
     bay.bay_faults = {'testfault': 'fault'}
     dict = bay.as_dict()
     self.assertEqual({'testfault': 'fault'}, dict['faults'])
コード例 #45
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
    def test_create_bay_generate_uuid(self, mock_valid_os_res):
        bdict = apiutils.bay_post_data()
        del bdict["uuid"]
        mock_valid_os_res.return_value = None

        response = self.post_json("/bays", bdict)
        self.assertEqual("application/json", response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(bdict["name"], response.json["name"])
        self.assertTrue(utils.is_uuid_like(response.json["uuid"]))
コード例 #46
0
ファイル: test_bay.py プロジェクト: ragnaray/magnum
 def test_create_bay_without_docker_volume_size(self):
     bdict = apiutils.bay_post_data()
     # Remove the default docker_volume_size from the bay dict.
     del bdict['docker_volume_size']
     response = self.post_json('/bays', bdict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     bay, timeout = self.mock_bay_create.call_args
     # Verify docker_volume_size from BayModel is used
     self.assertEqual(20, bay[0].docker_volume_size)
コード例 #47
0
 def test_create_bay_without_docker_volume_size(self):
     bdict = apiutils.bay_post_data()
     # Remove the default docker_volume_size from the bay dict.
     del bdict['docker_volume_size']
     response = self.post_json('/bays', bdict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     bay, timeout = self.mock_bay_create.call_args
     # Verify docker_volume_size from BayModel is used
     self.assertEqual(20, bay[0].docker_volume_size)
コード例 #48
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
 def test_create_bay_with_no_timeout(self):
     def _simulate_rpc_bay_create(bay, bay_create_timeout):
         self.assertEqual(60, bay_create_timeout)
         bay.create()
         return bay
     self.mock_bay_create.side_effect = _simulate_rpc_bay_create
     bdict = apiutils.bay_post_data()
     del bdict['bay_create_timeout']
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
コード例 #49
0
ファイル: test_bay.py プロジェクト: larsbutler/magnum
    def test_create_bay_set_project_id_and_user_id(self):
        bdict = apiutils.bay_post_data()

        def _simulate_rpc_bay_create(bay, bay_create_timeout):
            self.assertEqual(self.context.project_id, bay.project_id)
            self.assertEqual(self.context.user_id, bay.user_id)
            bay.create()
            return bay
        self.mock_bay_create.side_effect = _simulate_rpc_bay_create

        self.post_json('/bays', bdict)
コード例 #50
0
ファイル: test_bay.py プロジェクト: drzaeus77/magnum
    def test_create_bay_set_project_id_and_user_id(self):
        bdict = apiutils.bay_post_data()

        def _simulate_rpc_bay_create(bay, bay_create_timeout):
            self.assertEqual(self.context.project_id, bay.project_id)
            self.assertEqual(self.context.user_id, bay.user_id)
            bay.create()
            return bay
        self.mock_bay_create.side_effect = _simulate_rpc_bay_create

        self.post_json('/bays', bdict)
コード例 #51
0
ファイル: test_bay.py プロジェクト: drzaeus77/magnum
 def test_create_bay_with_no_timeout(self):
     def _simulate_rpc_bay_create(bay, bay_create_timeout):
         self.assertEqual(0, bay_create_timeout)
         bay.create()
         return bay
     self.mock_bay_create.side_effect = _simulate_rpc_bay_create
     bdict = apiutils.bay_post_data()
     del bdict['bay_create_timeout']
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
コード例 #52
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
    def test_create_bay_with_no_timeout(self, mock_valid_os_res):
        def _simulate_rpc_bay_create(bay, bay_create_timeout):
            self.assertEqual(0, bay_create_timeout)
            bay.create()
            return bay

        self.mock_bay_create.side_effect = _simulate_rpc_bay_create
        bdict = apiutils.bay_post_data()
        del bdict["bay_create_timeout"]
        mock_valid_os_res.return_value = None
        response = self.post_json("/bays", bdict, expect_errors=True)
        self.assertEqual("application/json", response.content_type)
        self.assertEqual(201, response.status_int)
コード例 #53
0
ファイル: test_bay.py プロジェクト: thomasem/magnum
    def test_create_bay_set_project_id_and_user_id(self, mock_valid_os_res):
        bdict = apiutils.bay_post_data()
        mock_valid_os_res.return_value = None

        def _simulate_rpc_bay_create(bay, bay_create_timeout):
            self.assertEqual(self.context.project_id, bay.project_id)
            self.assertEqual(self.context.user_id, bay.user_id)
            bay.create()
            return bay

        self.mock_bay_create.side_effect = _simulate_rpc_bay_create

        self.post_json("/bays", bdict)
コード例 #54
0
ファイル: test_bay.py プロジェクト: wirespecter/magnum
    def test_create_bay_set_project_id_and_user_id(self):
        bdict = apiutils.bay_post_data()

        def _simulate_rpc_bay_create(bay, node_count, master_count,
                                     bay_create_timeout):
            self.assertEqual(self.context.project_id, bay.project_id)
            self.assertEqual(self.context.user_id, bay.user_id)
            bay.create()
            db_utils.create_nodegroups_for_cluster(
                cluster_id=bay.uuid, node_count=node_count,
                master_count=master_count)
            return bay
        self.mock_bay_create.side_effect = _simulate_rpc_bay_create

        self.post_json('/bays', bdict)
コード例 #55
0
ファイル: test_bay.py プロジェクト: wirespecter/magnum
 def test_create_bay_with_no_timeout(self):
     def _simulate_rpc_bay_create(bay, node_count, master_count,
                                  bay_create_timeout):
         self.assertEqual(60, bay_create_timeout)
         bay.create()
         db_utils.create_nodegroups_for_cluster(
             cluster_id=bay.uuid, node_count=node_count,
             master_count=master_count)
         return bay
     self.mock_bay_create.side_effect = _simulate_rpc_bay_create
     bdict = apiutils.bay_post_data()
     del bdict['bay_create_timeout']
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
コード例 #56
0
    def test_create_bay(self, mock_utcnow):
        bdict = apiutils.bay_post_data()
        test_time = datetime.datetime(2000, 1, 1, 0, 0)
        mock_utcnow.return_value = test_time

        response = self.post_json('/bays', bdict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        # Check location header
        self.assertIsNotNone(response.location)
        self.assertTrue(uuidutils.is_uuid_like(response.json['uuid']))
        self.assertNotIn('updated_at', response.json.keys)
        return_created_at = timeutils.parse_isotime(
            response.json['created_at']).replace(tzinfo=None)
        self.assertEqual(test_time, return_created_at)
        self.assertEqual(bdict['bay_create_timeout'],
                         response.json['bay_create_timeout'])
コード例 #57
0
    def test_create_bay(self, mock_utcnow, mock_valid_os_res):
        bdict = apiutils.bay_post_data()
        test_time = datetime.datetime(2000, 1, 1, 0, 0)
        mock_utcnow.return_value = test_time
        mock_valid_os_res.return_value = None

        response = self.post_json('/bays', bdict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        # Check location header
        self.assertIsNotNone(response.location)
        expected_location = '/v1/bays/%s' % bdict['uuid']
        self.assertEqual(expected_location,
                         urlparse.urlparse(response.location).path)
        self.assertEqual(bdict['uuid'], response.json['uuid'])
        self.assertNotIn('updated_at', response.json.keys)
        return_created_at = timeutils.parse_isotime(
            response.json['created_at']).replace(tzinfo=None)
        self.assertEqual(test_time, return_created_at)
コード例 #58
0
    def test_bay_init(self):
        bay_dict = apiutils.bay_post_data(baymodel_id=None)
        del bay_dict['node_count']
        del bay_dict['master_count']
        del bay_dict['bay_create_timeout']
        bay = api_bay.Bay(**bay_dict)
        self.assertEqual(1, bay.node_count)
        self.assertEqual(1, bay.master_count)
        self.assertEqual(60, bay.bay_create_timeout)

        # test unset value for baymodel_id
        bay.baymodel_id = wtypes.Unset
        self.assertEqual(wtypes.Unset, bay.baymodel_id)

        # test backwards compatibility of bay fields with new objects
        bay_dict['bay_create_timeout'] = 15
        bay_dict['bay_faults'] = {'testfault': 'fault'}
        bay = api_bay.Bay(**bay_dict)
        self.assertEqual(15, bay.bay_create_timeout)
        self.assertEqual(15, bay.create_timeout)
        self.assertIn('testfault', bay.bay_faults)
        self.assertIn('testfault', bay.faults)
コード例 #59
0
 def test_create_bay_with_timeout_none(self):
     bdict = apiutils.bay_post_data()
     bdict['bay_create_timeout'] = None
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
コード例 #60
0
 def test_create_bay_with_invalid_empty_name(self):
     bdict = apiutils.bay_post_data(name='')
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])