Beispiel #1
0
def test_get_json_blob_bad_id(ptm):
    """Test get_json_blob method with a non-existent id."""
    blob = perftest_json(
        testrun={"date": 1330454756},
        test_build={"name": "one"},
    )
    badblob = "fooo{0}".format(blob)
    ptm.store_test_data(badblob, error="badness")

    result = objectstore_refdata.get_json_blob(ptm.project, 10)

    assert not result
def test_get_json_blob_bad_id(ptm):
    """Test get_json_blob method with a non-existent id."""
    blob = perftest_json(
        testrun={"date": 1330454756},
        test_build={"name": "one"},
        )
    badblob = "fooo{0}".format(blob)
    ptm.store_test_data(badblob, error="badness")

    result = objectstore_refdata.get_json_blob(ptm.project, 10)

    assert not result
Beispiel #3
0
def test_get_json_blob(ptm):
    """Test get_json_blob method"""

    blob = perftest_json(
        testrun={"date": 1330454756},
        test_build={"name": "one"},
    )
    badblob = "fooo{0}".format(blob)
    ptm.store_test_data(badblob, error="badness")

    result = objectstore_refdata.get_json_blob(ptm.project, 1)

    assert badblob == result['json_blob']
    assert 'Y' == result['error_flag']
    assert None == result['test_run_id']
def test_get_json_blob(ptm):
    """Test get_json_blob method"""

    blob = perftest_json(
        testrun={"date": 1330454756},
        test_build={"name": "one"},
        )
    badblob = "fooo{0}".format(blob)
    ptm.store_test_data(badblob, error="badness")

    result = objectstore_refdata.get_json_blob(ptm.project, 1)

    assert badblob == result['json_blob']
    assert 'Y' == result['error_flag']
    assert None == result['test_run_id']
def get_json_blob(request, project, id):
    """Return a json object for the objectstore id provided"""

    blob = objectstore_refdata.get_json_blob(project, id)

    if blob:

        # If we don't have malformed json load it so we can return
        # a single json data structure with all fields present including
        # json_blob.  Malformed json will be returned as an escaped
        # string.
        try:
            blob['json_blob'] = json.loads(blob['json_blob'])
        except ValueError as e:
            pass

        return HttpResponse(json.dumps(blob), content_type=API_CONTENT_TYPE)

    else:
        return HttpResponse("Id not found: {0}".format(id), status=404)
def get_json_blob(request, project, id):
    """Return a json object for the objectstore id provided"""

    blob = objectstore_refdata.get_json_blob(project, id)

    if blob:

        # If we don't have malformed json load it so we can return
        # a single json data structure with all fields present including
        # json_blob.  Malformed json will be returned as an escaped
        # string.
        try:
            blob['json_blob'] = json.loads(blob['json_blob'])
        except ValueError as e:
            pass

        return HttpResponse(json.dumps(blob), content_type=API_CONTENT_TYPE)

    else:
        return HttpResponse("Id not found: {0}".format(id), status=404)