Example #1
0
    def test_share_create_invalid_availability_zone(self):
        self.mock_object(
            db, 'availability_zone_get',
            mock.Mock(side_effect=exception.AvailabilityZoneNotFound(id='id')))
        body = {"share": copy.deepcopy(self.share)}

        req = fakes.HTTPRequest.blank('/shares')
        self.assertRaises(webob.exc.HTTPNotFound, self.controller.create, req,
                          body)
Example #2
0
    def test_create_az_not_found(self, data):
        req = fakes.HTTPRequest.blank('/share-networks', version="2.51")

        self.mock_object(
            db_api, 'availability_zone_get',
            mock.Mock(side_effect=exception.AvailabilityZoneNotFound(
                id='fake')))

        body = {share_networks.RESOURCE_NAME: data}

        self.assertRaises(webob_exc.HTTPBadRequest, self.controller.create,
                          req, body)
Example #3
0
    def test_subnet_create_az_not_found(self):
        fake_sn_id = 'fake_id'
        req = fakes.HTTPRequest.blank('/subnets', version="2.51")
        context = req.environ['manila.context']
        body = {
            'share-network-subnet': self._setup_create_test_request_body()
        }
        mock_sn_get = self.mock_object(db_api, 'share_network_get')
        mock_az_get = self.mock_object(
            db_api, 'availability_zone_get',
            mock.Mock(side_effect=exception.AvailabilityZoneNotFound(id='')))

        expected_az = body['share-network-subnet']['availability_zone']

        self.assertRaises(exc.HTTPBadRequest,
                          self.controller.create,
                          req,
                          fake_sn_id,
                          body)
        mock_sn_get.assert_called_once_with(context, fake_sn_id)
        mock_az_get.assert_called_once_with(
            context, expected_az)
Example #4
0
    def test_share_group_create_with_nonexistent_az(self):
        fake_az_name = 'fake_az_name'
        fake_az_id = 'fake_az_id'
        fake_share_group, expected_share_group = self._get_fake_share_group(
            availability_zone_id=fake_az_id)
        self.mock_object(self.controller.share_group_api, 'create',
                         mock.Mock(return_value=fake_share_group))
        self.mock_object(
            share_groups.db, 'availability_zone_get',
            mock.Mock(side_effect=exception.AvailabilityZoneNotFound(
                id=fake_az_id)))

        body = {"share_group": {"availability_zone": fake_az_name}}

        self.assertRaises(webob.exc.HTTPNotFound, self.controller.create,
                          self.request, body)

        self.assertEqual(0, self.controller.share_group_api.create.call_count)
        share_groups.db.availability_zone_get.assert_called_once_with(
            self.context, fake_az_name)
        self.mock_policy_check.assert_called_once_with(self.context,
                                                       self.resource_name,
                                                       'create')