~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/testing/factory.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2013-07-18 19:23:09 UTC
  • mfrom: (313.1.6 bundle-api)
  • Revision ID: tarmac-20130718192309-gpskenwvljiy47em
[r=sinzui][bug=][author=bac] Minimal implementation of API for fetching bundles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    process_charm,
28
28
)
29
29
from charmworld.models import (
 
30
    Bundle,
30
31
    CharmFileSet,
31
32
    getfs,
32
33
    options_to_storage,
139
140
        "series": series,
140
141
    }
141
142
 
142
 
 
143
143
def get_charm_json(name=None, changes=None, subordinate=False, tests=None,
144
144
                   with_real_files=False, branch_root=None, bname=None,
145
145
                   series=None, owner=None, description=None, revision=1,
296
296
    return record_id, charm
297
297
 
298
298
 
 
299
def get_bundle_data(name='hoopy', owner='', basket=None, inherits=None,
 
300
                    series='precise', title='', description='',
 
301
                    services=dict(), relations=dict(), promulgated=False,
 
302
                    branch_deleted=False):
 
303
    return dict(**vars())
 
304
 
 
305
 
 
306
def makeBundle(db, *args, **kwargs):
 
307
    bundle_data = get_bundle_data(*args, **kwargs)
 
308
    bundle = Bundle(bundle_data)
 
309
    bundle_data['_id'] = bundle.id
 
310
    db.bundles.insert(bundle_data)
 
311
    return bundle
 
312
 
 
313
 
299
314
def make_charm_file(db, charm, path, content=None):
300
315
    fs = getfs(db)
301
316
    charm_file = CharmFileSet.make_charm_file(fs, charm, path, basename(path))