def handle_describechannels_for_missing_tip(self): test_id = u"tests/1" test_channel = u"test_channel" test_protocol = u"test_protocol" gref = Gref(self.station.station.store, test_channel, test_id) root_obj = RootObject(test_id, test_channel, test_protocol) root_oid = self.station.station.write(root_obj.as_object()) current_oid = [root_oid] for i in xrange(10): update_obj = UpdateObject([current_oid.pop()], "loldata") current_oid.append(self.station.station.write(update_obj.as_object())) update_obj = UpdateObject([current_oid.pop()], "loldata") current_oid.append(binascii.hexlify(pygit2.hash(update_obj.as_object()))) self.station.station.update_gref(gref, [Tip(root_oid, "")]) self.assertEqual([root_oid], gref.tips()) current_oid = current_oid.pop() self.station.payload = _payload(update_obj, gref, [current_oid]) handle_describechannels(self.station) self.assertEqual([current_oid], gref.tips())
def handle_describechannels_for_missing_tip(self): test_id = u"tests/1" test_channel = u"test_channel" test_protocol = u"test_protocol" gref = Gref(self.station.station.store, test_channel, test_id) root_obj = RootObject(test_id, test_channel, test_protocol) root_oid = self.station.station.write(root_obj.as_object()) current_oid = [root_oid] for i in xrange(10): update_obj = UpdateObject([current_oid.pop()], "loldata") current_oid.append(self.station.station.write(update_obj.as_object())) update_obj = UpdateObject([current_oid.pop()], "loldata") current_oid.append(binascii.hexlify(pygit2.hash(update_obj.as_object()))) self.station.station.update_gref(gref, [root_oid]) self.assertEqual([root_oid], gref.tips()) current_oid = current_oid.pop() self.station.payload = _payload(update_obj, gref, [current_oid]) handle_describechannels(self.station) self.assertEqual([current_oid], gref.tips())
def test_hydate_update_with_1_parent(self): update = UpdateObject( ["d41e2dadaf624319518a9dfa8ef4cb0dde055b5c"], "Lol I r update data" ) hydrated_update = object_factory.hydrate_object(update.as_object()) self.assertTrue(isinstance(hydrated_update, UpdateObject))
def test_hydate_update_with_2_parent(self): update = UpdateObject([ "d41e2dadaf624319518a9dfa8ef4cb0dde055b5c", "d41e2dadaf624319518a9dfa8ef4cb0dde055bff" ], "Lol I r update data") hydrated_update = object_factory.hydrate_object(update.as_object()) self.assertTrue(isinstance(hydrated_update, UpdateObject))
def main(): myself = Node() station = Station.from_env(myself) filename = sys.argv[1] log("Stealing %s" % filename) with open(filename) as fh: obj = UpdateObject([], os.path.basename(filename) + chr(0x00) + bz2.compress(fh.read())) name = station.write(obj.as_object()) log("Wrote %s into stationdb" % name)
def update_gref(channel, identifier): # adaptor = github_protocol.GithubWriteAdaptor(station, channel) gref = Gref(station.store, channel, identifier) # Ugly type coercion user = request.form["user"] body = request.form["body"] parents = map(str, json.loads(request.form["parents"])) payload = {"type": "comment", "id": None, "body": body, "user": user} update_object = UpdateObject(parents, json.dumps(payload)) oid = station.write(update_object.as_object()) _update_gref(gref, [Tip(oid, "")], parents) return jsonate({"response": "ok"}, False)
def main(): myself = Node() station = Station.from_env(myself) filename = sys.argv[1] log("Stealing %s" % filename) with open(filename) as fh: obj = UpdateObject([], os.path.basename(filename) + chr(0x00) + bz2.compress(fh.read()) ) name = station.write(obj.as_object()) log("Wrote %s into stationdb" % name)
def update_gref(channel, identifier): # adaptor = github_protocol.GithubWriteAdaptor(station, channel) gref = Gref(station.store, channel, identifier) # Ugly type coercion user = request.form["user"] body = request.form["body"] parents = map(str, json.loads(request.form["parents"])) payload = { "type": "comment", "id": None, "body": body, "user": user } update_object = UpdateObject(parents, json.dumps(payload)) oid = station.write(update_object.as_object()) _update_gref(gref, [Tip(oid,"")], parents) return jsonate({"response": "ok"}, False)
# Creates a thread in the current groundstation context import uuid import stricken from groundstation.node import Node from groundstation.station import Station from groundstation.objects.root_object import RootObject from groundstation.objects.update_object import UpdateObject from groundstation.gref import Gref node = Node() station = Station.from_env(node) CHANNEL = "messages" thread_id = str(uuid.uuid1()) gref = Gref(station.store, CHANNEL, thread_id) root = RootObject(thread_id, CHANNEL, stricken.PROTOCOL) oid = station.write(root.as_object()) print("Root id: %s" % (oid)) update = UpdateObject([oid], "Post content") oid = station.write(update.as_object()) print("Update id: %s" % (oid)) gref.write_tip(oid, "")