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 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 direct_parents(self, tip): """Return all parents of `tip` in the order they're written into the object""" obj = object_factory.hydrate_object(self.store[tip].data) if isinstance(obj, RootObject): # Roots can't have parents return [] elif isinstance(obj, UpdateObject): return obj.parents else: raise "Unknown object hydrated %s" % (str(type(obj)))
def _process(node): if node in visited_nodes: log.debug("Bailing on visited node: %s" % (node)) return visited_nodes.add(node) obj = object_factory.hydrate_object(self.store[node].data) if isinstance(obj, RootObject): # We've found a root root_nodes.append(obj) return for tip in obj.parents: _process(tip) thread.insert(0, obj)
def fetch_object(object_id): try: obj = station[object_id] hydrated_obj = object_factory.hydrate_object(station[object_id].data) except: raise if isinstance(hydrated_obj, UpdateObject): t = "update" elif isinstance(hydrated_obj, RootObject): t = "root" else: raise Exception("Unhandled object type") return json.dumps({ "type": t, "object": base64.b64encode(obj.data) })
def _process(node): if node in visited_nodes: log.debug("Bailing on visited node: %s" % (node)) return visited_nodes.add(node) if crypto_adaptor: signature = self.get_signature(node) if signature: signatures[node] = crypto_adaptor.verify(node, signature) obj = object_factory.hydrate_object(self.store[node].data) if isinstance(obj, RootObject): # We've found a root root_nodes.append(obj) return for tip in obj.parents: _process(tip) thread.insert(0, obj)
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))