Example #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'])
Example #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)
Example #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)
Example #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)
Example #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'])
Example #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)
Example #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)
Example #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)
Example #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'])
Example #10
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"])
Example #11
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)
Example #12
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'])
Example #13
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'])
Example #14
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)
Example #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'])
Example #16
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)
Example #17
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'])
Example #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'])
Example #19
0
 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)
Example #20
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'])
Example #21
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(404, response.status_int)
Example #22
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'])
Example #23
0
 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)
Example #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'])
Example #25
0
 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)
Example #26
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)
Example #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)
Example #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)
Example #29
0
 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"])
Example #30
0
 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"])
Example #31
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'])
Example #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'])
Example #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)
Example #34
0
 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)
Example #35
0
 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)
Example #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)
Example #37
0
 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])
Example #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']))
Example #39
0
 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])
Example #40
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'])
Example #41
0
 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])
Example #42
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']))
Example #43
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)
Example #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'])
Example #45
0
    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"]))
Example #46
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)
Example #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)
Example #48
0
 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)
Example #49
0
    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)
Example #50
0
    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)
Example #51
0
 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)
Example #52
0
    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)
Example #53
0
    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)
Example #54
0
    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)
Example #55
0
 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)
Example #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'])
Example #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)
Example #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)
Example #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)
Example #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'])