def test_add_user_defined_data(self): vnf_package_db = models.VnfPackage() vnf_package_db.update(fakes.fake_vnf_package()) vnf_package_db.save(self.context.session) result = vnf_package._add_user_defined_data( self.context, vnf_package_db.id, vnf_package_db.user_data) self.assertEqual(None, result)
def test_add_user_defined_data(self): vnf_package_db = models.VnfPackage() vnf_package_db.update(fakes.fake_vnf_package()) vnf_package_db.save(self.context.session) expected_result = {'key1': 'value1', 'key2': 'value2'} result = vnf_package._add_user_defined_data(self.context, vnf_package_db.id, vnf_package_db.user_data) self.assertEqual(expected_result, result)
def _vnf_package_create(context, values, user_data=None): vnf_package = models.VnfPackage() vnf_package.update(values) vnf_package.save(context.session) vnf_package._metadata = [] if user_data: _add_user_defined_data(context, vnf_package.id, user_data) context.session.expire(vnf_package, ['_metadata']) vnf_package._metadata return vnf_package
def test_create_ignore_flavours(self, mock_vnf_package_create, mock_uuid): fake_data = fakes.fake_vnf_package_response mock_uuid.return_value = fake_data['id'] mock_vnf_package_create.return_value = models.VnfPackage(**fake_data) flavour_data = fakes.vnf_deployment_flavour flavour_data.update({'package_uuid': self.vnf_package.id}) vnf_deployment_flavour = objects.VnfDeploymentFlavour(**flavour_data) fake_vnf_deployment_flavours = objects.VnfDeploymentFlavoursList( objects=[vnf_deployment_flavour]) vnf_pack = fakes.vnf_package_data vnf_pack.update( {'vnf_deployment_flavours': fake_vnf_deployment_flavours}) vnfpkgm = objects.VnfPackage(context=self.context, **vnf_pack) vnfpkgm.create() mock_vnf_package_create.assert_called_once_with( self.context, fake_data, user_data={'abc': 'xyz'})
def return_vnf_package(): model_obj = models.VnfPackage() model_obj.update(fake_vnf_package()) return model_obj