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 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 test_hydrate_root_object(self): root = RootObject( "test_object", "[email protected]:groundstation/tests", "[email protected]:groundstation/testcase" ) hydrated_root = object_factory.hydrate_object(root.as_object()) self.assertTrue(isinstance(hydrated_root, RootObject))
def test_handle_listallchannels(self): test_id = u"tests/1" test_channel = u"test_channel" test_protocol = u"test_protocol" obj = RootObject(test_id, test_channel, test_protocol) gref = Gref(self.station.station.store, test_channel, test_id) oid = self.station.station.write(obj.as_object()) self.station.station.update_gref(gref, [Tip(oid, "")], []) handle_listallchannels(self.station) response = self.station.stream.pop() serialized_response = response.SerializeToString() self.assertIsInstance(serialized_response, str) assert len(self.station.stream) == 0, "Someone is leaving objects lyind around" channel_description = ChannelList() channel_description.ParseFromString(response.payload) self.assertEqual(channel_description.channels[0].channelname, test_channel) self.assertEqual(channel_description.channels[0].grefs[0].identifier, test_id) self.assertEqual(channel_description.channels[0].grefs[0].tips[0].tip, oid)
# 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, "")
def test_hydrate_root_object(self): root = RootObject("test_object", "[email protected]:groundstation/tests", "[email protected]:groundstation/testcase") hydrated_root = object_factory.hydrate_object(root.as_object()) self.assertTrue(isinstance(hydrated_root, RootObject))