

def create_release(self, api=False, **kwargs):
    os = kwargs.get('operating_system', consts.RELEASE_OS.centos)
    version = kwargs.get('version', '{0}-6.1'.format(randint(0, 100000000)))
    releases = self.read_fixtures(('openstack',))
    release_data = next((r for r in releases if (r['fields']['operating_system'] == os)), releases[0])
    release_data = release_data['fields']
    release_data.update({
        'name': ('release_name_' + version),
        'version': version,
        'state': consts.RELEASE_STATES.available,
        'description': ('release_desc' + version),
    })
    if (kwargs.get('deployment_tasks') is None):
        kwargs['deployment_tasks'] = load_fake_deployment_tasks(apply_to_db=False)
    release_data.update(kwargs)
    if api:
        resp = self.app.post(reverse('ReleaseCollectionHandler'), params=jsonutils.dumps(release_data), headers=self.default_headers)
        self.tester.assertEqual(resp.status_code, 201)
        release = resp.json_body
        self.releases.append(self.db.query(Release).get(release['id']))
    else:
        release = Release.create(release_data)
        db().commit()
        self.releases.append(release)
    return release

dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/test/base.py EnvironmentManager.create_release/original