~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/testing/factory.py

[r=adeuring,abentley][bug=1199790][author=adeuring] Return dummy data for Charm.last_change and Charm.first_change, if a branch does not have any commits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
                   date_created=None, downloads=0,
173
173
                   downloads_in_past_30_days=0, is_featured=False,
174
174
                   promulgated=False, categories=None, branch_deleted=False,
175
 
                   proof=None, payload=None):
 
175
                   proof=None, payload=None, empty_branch=False):
176
176
    """Return the json of a charm."""
177
177
    if not description:
178
178
        description = """byobu-class provides remote terminal access through
254
254
        "changes": changes,
255
255
        "description": description,
256
256
        "doctype": "charm",
257
 
        "first_change": {
258
 
            "committer": "Jane Doe <jane@sample.com>",
259
 
            "created": 1308093138.892,
260
 
            "message": "initial checkin\n",
261
 
            "revno": 1
262
 
        },
263
257
        "hooks": [
264
258
            "install",
265
259
            "start",
267
261
            "website-relation-joined"
268
262
        ],
269
263
        'is_featured': is_featured,
270
 
        "last_change": {
271
 
            "committer": "John Doe <jdoe@example.com>",
272
 
            "created": 1343082725.06,
273
 
            "message": commit_message,
274
 
            "revno": revno,
275
 
        },
276
264
        "maintainer": maintainer,
277
265
        "proof": proof,
278
266
        "provides": provides,
287
275
        'downloads_in_past_30_days': downloads_in_past_30_days,
288
276
        'date_created': date_created.isoformat(),
289
277
    })
 
278
    if empty_branch:
 
279
        charm["first_change"] = None
 
280
        charm["last_change"] = None
 
281
    else:
 
282
        charm["first_change"] = {
 
283
            "committer": "Jane Doe <jane@sample.com>",
 
284
            "created": 1308093138.892,
 
285
            "message": "initial checkin\n",
 
286
            "revno": 1
 
287
        }
 
288
        charm["last_change"] = {
 
289
            "committer": "John Doe <jdoe@example.com>",
 
290
            "created": 1343082725.06,
 
291
            "message": commit_message,
 
292
            "revno": revno,
 
293
        }
290
294
    if tests is not None:
291
295
        charm['tests'] = tests
292
296
        charm['test_results'] = {}