def test_upload_delete_relations_with_circular_reference(self): cs = CreateTestChangeset(self.user, tags={"foo": "me"}, is_open=True) node = create_node(self.user.id, self.user.username) relation = create_relation(self.user.id, self.user.username, [("node", node.objId, "parrot")]) relation2 = create_relation(self.user.id, self.user.username, [("node", node.objId, "parrot"), ("relation", relation.objId, "dead")]) relation = modify_relation(self.user.id, self.user.username, relation, [("node", node.objId, "parrot"), ("relation", relation2.objId, "dead")], {}) xml = """<osmChange version="0.6" generator="JOSM"> <delete> <relation id='{}' version='{}' changeset='{}'/> <relation id='{}' version='{}' changeset='{}'/> </delete> </osmChange>""".format(relation.objId, relation.metaData.version, cs.objId, relation2.objId, relation2.metaData.version, cs.objId) response = self.client.post(reverse('changeset:upload', args=(cs.objId, )), xml, content_type='text/xml') #print (response.content) self.assertEqual(response.status_code, 200)
def test_upload_delete_relation_used_by_relation_if_unused(self): cs = CreateTestChangeset(self.user, tags={"foo": "me"}, is_open=True) node = create_node(self.user.id, self.user.username) node2 = create_node(self.user.id, self.user.username, node) relation = create_relation(self.user.id, self.user.username, [("node", node.objId, "parrot"), ("node", node2.objId, "dead")]) relation2 = create_relation(self.user.id, self.user.username, [("node", node.objId, "parrot"), ("relation", relation.objId, "dead")]) xml = """<osmChange generator="JOSM" version="0.6"> <delete if-unused="true"> <relation changeset="{}" id="{}" version="{}"/> </delete> </osmChange>""".format(cs.objId, relation.objId, relation.metaData.version) response = self.client.post(reverse('changeset:upload', args=(cs.objId,)), xml, content_type='text/xml') #print (response.content) self.assertEqual(response.status_code, 200)
def test_create_relation_diff(self): ts = time.time() - 60 node1 = qmt.create_node(self.user.id, self.user.username, timestamp = ts) node2 = qmt.create_node(self.user.id, self.user.username, timestamp = ts) refs = [("node", node1.objId, "foo"), ("node", node2.objId, "bar")] relation = qmt.create_relation(self.user.id, self.user.username, refs, timestamp = ts) cat = rv.TimestampToPath(relation.metaData.timestamp, "minute") anonClient = Client() response = anonClient.get(reverse('replicate:diffdata', args=['minute', str(cat[0]), str(cat[1]), str(cat[2])])) if response.status_code != 200: print (response.content) self.assertEqual(response.status_code, 200) osc = pgmap.OsmChange() pgmap.LoadFromOsmChangeXml(response.content.decode("utf-8"), osc) oscIndex = CreateIndexOsmChange(osc) self.assertEqual(relation.objId in oscIndex["relation"], True) self.assertEqual(oscIndex["relation"][relation.objId][0][0], "create")