Example #1
0
def test_delete(cl, bucket, key):
    data = UserInfo(uid=1)
    put = cl.put(bucket, key, data.dumps())

    cl.delete(bucket, key)
    gone = cl.get(bucket, key)
    assert gone == None, "value still persists after delete"
    print "\nsuccessfully did delete\n"
Example #2
0
def test_many(cl, bucket):
    data = UserInfo(uid=1)

    mos = [ cl.newMontageObject(bucket, str(i), data.dumps()) for i in xrange(0,2) ]
    ref = cl.put_many(mos)
    found = cl.get_many([(bucket, str(i)) for i in xrange(0,2) ])

    assert len(ref) == len(found), "Num put %d and num found %d don't match" % (len(ref), len(found))
    for (r, f) in zip(ref, found):
        assert r.data == f.data, "put data does not match found data"
    print "\nsuccessfully matched put many with get many\n"
def main():
    cl = MontageClient('localhost', 7078)

    refdata = UserInfo(uid=2)
    ref = cl.put('u-info', str(1), refdata.dumps())

    target1data = UserEvent(eid=3)
    target1 = cl.put('u-event', str(2), target1data.dumps())

    target2data = UserName(name="montage")
    target2 = cl.put('u-name', str(2), target2data.dumps())

    (refObj, values) = cl.get_by('u-info', str(1), ['u-event', 'u-name'])
    assert UserInfo(refObj.data) == refdata, "reference key found did not match"
    assert len(values) == 2, "incorrect num values"
    assert values[0] is not None, "Could not retrieve u-event data, nothing found"
    assert values[1] is not None, "Could not retrieve u-name data, nothing found"
    assert UserEvent(values[0].data) == target1data, "value 1 found did not match"
    assert UserName(values[1].data) == target2data, "value 2 found did not match"
    print "\npassed reference get identity\n"
    quickstop()