Beispiel #1
0
def delete_testrun(testrun_id):
    """Remove a testrun."""
    orig = Testrun.objects(id=testrun_id).first()

    # delete the reference from any testrun groups
    trdbref = bson.DBRef('testruns', bson.ObjectId("531e4d26ded43258823d9c3a"))
    TestrunGroup.objects(__raw__={'testruns': {'$elemMatch': trdbref}}).update(pull__testruns=trdbref)

    # add an event
    events.DeleteEvent(orig)

    orig.delete()
    return JsonResponse(orig)
Beispiel #2
0
def add_testrun_to_testrun_group(testrungroup_id, testrun_id):
    """Add a testrun to a testrun group"""
    orig = TestrunGroup.objects(id=ObjectId(testrungroup_id)).first()
    testrun = Testrun.objects(id=ObjectId(testrun_id)).first()
    if (not hasattr(orig, 'testruns')) or orig.testruns is None:
        orig.testruns = []
    orig.testruns.append(testrun)
    orig.save()
    return JsonResponse(orig)
Beispiel #3
0
def remove_testrun_from_testrun_group(testrungroup_id, testrun_id):
    """Remove a testrun from a testrun group"""
    orig = TestrunGroup.objects(id=ObjectId(testrungroup_id)).first()
    real_testrunid = ObjectId(testrun_id)
    index = -1
    for i in range(len(orig.testruns)):
        if orig.testruns[i].id == real_testrunid:
            index = i
            break
    if index >= 0:
        del orig.testruns[index]
        orig.save()
    return JsonResponse(orig)
Beispiel #4
0
def delete_testrungroup(testrungroup_id):
    """Remove a testrun group"""
    orig = TestrunGroup.objects(id=testrungroup_id).first()
    orig.delete()
    return JsonResponse(orig)
Beispiel #5
0
def update_testrungroup(testrungroup_id):
    """Update a testrun group's properties."""
    orig = TestrunGroup.objects(id=testrungroup_id).first()
    deserialize_that(read_request(), orig)
    orig.save()
    return JsonResponse(orig)
Beispiel #6
0
def get_testrungroup_by_id(testrungroup_id):
    """Find a testrungroup by it's id."""
    return JsonResponse(TestrunGroup.objects(id=testrungroup_id).first())