Ejemplo n.º 1
0
	def test_upload_multi_action(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)
		way = create_way(self.user.id, self.user.username, [node.objId, node2.objId])

		xml = """<osmChange version="0.6" generator="JOSM">
		<create>
		  <node id='-3912' changeset='{0}' lat='50.78673385857' lon='-1.04730886255'>
			<tag k='abc' v='def' />
		  </node>
		</create>
		<modify>
		  <way id='{1}' changeset='{0}' version="{2}">
			<nd ref='-3912' />
			<nd ref='{3}' />
			<nd ref='{4}' />
			<tag k='ghi' v='jkl' />
		  </way>
		</modify>
		</osmChange>""".format(cs.objId, way.objId, way.metaData.version, node.objId, node2.objId)

		response = self.client.post(reverse('changeset:upload', args=(cs.objId,)), xml, 
			content_type='text/xml')
		if response.status_code != 200:
			print (response.content)
		self.assertEqual(response.status_code, 200)

		xml = fromstring(response.content)
		diffDict = ParseOsmDiffToDict(xml)
Ejemplo n.º 2
0
    def test_upload_delete_interdependent_objects(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)
        way = create_way(self.user.id, self.user.username,
                         [node.objId, node2.objId])

        xml = """<osmChange version="0.6" generator="JOSM">
		<delete>
		  <way id='{}' version='{}' changeset='{}'/>
		  <node id='{}' version='{}' changeset='{}'/>
		  <node id='{}' version='{}' changeset='{}'/>
		</delete>
		</osmChange>""".format(way.objId, way.metaData.version, cs.objId, node.objId,
                         node.metaData.version, cs.objId, node2.objId,
                         node2.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)
Ejemplo n.º 3
0
	def test_get_ways_for_node(self):
		anonClient = Client()

		node = create_node(self.user.id, self.user.username)
		node2 = create_node(self.user.id, self.user.username, node)
		way = create_way(self.user.id, self.user.username, [node.objId, node2.objId])

		response = anonClient.get(reverse('elements:ways_for_node', args=['node', str(node.objId)]))
		if response.status_code != 200:
			print (response.content)
		self.assertEqual(response.status_code, 200)

		osmData = DecodeOsmdataResponse([response.content])
		wayIdDict = GetOsmDataIndex(osmData)['way']

		self.assertEqual(len(wayIdDict), 1)
		self.assertEqual(way.objId in wayIdDict, True)
Ejemplo n.º 4
0
	def test_upload_delete_node_used_by_way(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)
		way = create_way(self.user.id, self.user.username, [node.objId, node2.objId])

		xml = """<osmChange generator="JOSM" version="0.6">
		<delete>
		  <node changeset="{}" id="{}" lat="50.80" lon="-1.05" version="{}"/>
		</delete>
		</osmChange>""".format(cs.objId, node.objId, node.metaData.version)

		response = self.client.post(reverse('changeset:upload', args=(cs.objId,)), xml, 
			content_type='text/xml')
		self.assertEqual(response.status_code, 412)
Ejemplo n.º 5
0
	def test_upload_delete_way_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)
		way = create_way(self.user.id, self.user.username, [node.objId, node2.objId])
		relation = create_relation(self.user.id, self.user.username, [("node", node.objId, "parrot"), ("way", way.objId, "dead")])

		xml = """<osmChange generator="JOSM" version="0.6">
		<delete if-unused="true">
		  <way changeset="{}" id="{}" version="{}"/>
		</delete>
		</osmChange>""".format(cs.objId, way.objId, way.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)
Ejemplo n.º 6
0
	def test_upload_delete_undelete_way(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)
		way = create_way(self.user.id, self.user.username, [node.objId, node2.objId])

		xml = """<osmChange generator="JOSM" version="0.6">
		<delete>
		  <way changeset="{}" id="{}" version="{}"/>
		</delete>
		</osmChange>""".format(cs.objId, way.objId, node.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)

		ok, way = modify_way(way, [node.objId, node2.objId], {}, self.user)
		self.assertEqual(ok, True)
Ejemplo n.º 7
0
	def test_create_way_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 = [node1.objId, node2.objId]
		way = qmt.create_way(self.user.id, self.user.username, refs, timestamp = ts)
		cat = rv.TimestampToPath(way.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(way.objId in oscIndex["way"], True)
		self.assertEqual(oscIndex["way"][way.objId][0][0], "create")