예제 #1
0
 def test_destroy(self):
     uuid = self.fake_flavor['uuid']
     with mock.patch.object(self.dbapi, 'flavor_destroy',
                            autospec=True) as mock_flavor_destroy:
         mock_flavor_destroy.return_value = self.fake_flavor
         flavor = objects.Flavor(self.context, **self.fake_flavor)
         flavor.destroy(self.context)
         mock_flavor_destroy.assert_called_once_with(self.context, uuid)
예제 #2
0
 def setUp(self):
     super(RPCAPITestCase, self).setUp()
     self.fake_server = dbutils.get_test_server()
     self.fake_server_obj = objects.Server._from_db_object(
         objects.Server(self.context), self.fake_server)
     self.fake_type = dbutils.get_test_flavor()
     self.fake_type['extra_specs'] = {}
     self.fake_type_obj = objects.Flavor._from_db_object(
         self.context, objects.Flavor(self.context), self.fake_type)
예제 #3
0
 def test_create(self):
     with mock.patch.object(self.dbapi, 'flavor_create',
                            autospec=True) as mock_flavor_create:
         mock_flavor_create.return_value = self.fake_flavor
         flavor = objects.Flavor(self.context, **self.fake_flavor)
         values = flavor.obj_get_changes()
         flavor.create(self.context)
         mock_flavor_create.assert_called_once_with(self.context, values)
         self.assertEqual(self.fake_flavor['uuid'], flavor['uuid'])
예제 #4
0
    def post(self, flavor):
        """Create an new flavor.

        :param flavor: a flavor within the request body.
        """
        validation.check_schema(flavor, flavor_schema.create_flavor)
        new_flavor = objects.Flavor(pecan.request.context, **flavor)
        new_flavor.create()
        # Set the HTTP Location Header
        pecan.response.location = link.build_url('flavors', new_flavor.uuid)
        return Flavor.convert_with_links(new_flavor)
예제 #5
0
 def test_save(self):
     uuid = self.fake_flavor['uuid']
     with mock.patch.object(self.dbapi, 'flavor_update',
                            autospec=True) as mock_flavor_update:
         flavor = objects.Flavor(self.context, **self.fake_flavor)
         flavor.name = 'changed_name'
         updates = flavor.obj_get_changes()
         flavor.save(self.context)
         mock_flavor_update.return_value = self.fake_flavor
         mock_flavor_update.assert_called_once_with(self.context, uuid,
                                                    updates)
예제 #6
0
 def _create_flavor(self):
     flavor = db_utils.get_test_flavor()
     flavor['extra'] = {}
     type_obj = objects.Flavor(self.context, **flavor)
     type_obj.create(self.context)
     return type_obj