def missing_housenumbers_view_turbo(relations: areas.Relations, request_uri: str) -> yattag.doc.Doc: """Expected request_uri: e.g. /osm/missing-housenumbers/ormezo/view-turbo.""" tokens = request_uri.split("/") relation_name = tokens[-2] doc = yattag.doc.Doc() relation = relations.get_relation(relation_name) ret = relation.write_missing_housenumbers() _todo_street_count, _todo_count, _done_count, _percent, table = ret query = areas.make_turbo_query_for_streets(relation, table) with doc.tag("pre"): doc.text(query) return doc
def test_happy(self) -> None: """Tests the happy path.""" relations = get_relations() relation = relations.get_relation("gazdagret") fro = ["A2"] ret = areas.make_turbo_query_for_streets(relation, fro) expected = """[out:json][timeout:425]; rel(2713748)->.searchRelation; area(3602713748)->.searchArea; (way["name"="A2"](r.searchRelation); way["name"="A2"](area.searchArea); ); out body; >; out skel qt;""" self.assertEqual(ret, expected)
def missing_streets_view_turbo(relations: areas.Relations, request_uri: str) -> yattag.doc.Doc: """Expected request_uri: e.g. /osm/missing-streets/ormezo/view-turbo.""" tokens = request_uri.split("/") relation_name = tokens[-2] doc = yattag.doc.Doc() relation = relations.get_relation(relation_name) refstreets = relation.get_config().get_refstreets() streets: List[str] = [] for key, _value in refstreets.items(): if relation.should_show_ref_street(key): streets.append(key) query = areas.make_turbo_query_for_streets(relation, streets) with doc.tag("pre"): doc.text(query) return doc
def missing_housenumbers_view_turbo(relations: areas.Relations, request_uri: str) -> yattag.doc.Doc: """Expected request_uri: e.g. /osm/missing-housenumbers/ormezo/view-turbo.""" tokens = request_uri.split("/") relation_name = tokens[-2] doc = yattag.doc.Doc() relation = relations.get_relation(relation_name) ongoing_streets, _ = relation.get_missing_housenumbers() streets: List[str] = [] for result in ongoing_streets: # Street name, # of only_in_reference items. streets.append(result[0].get_osm_name()) query = areas.make_turbo_query_for_streets(relation, streets) with doc.tag("pre"): doc.text(query) return doc
def test_happy(self) -> None: """Tests the happy path.""" with unittest.mock.patch('util.get_abspath', get_abspath): relations = get_relations() relation = relations.get_relation("gazdagret") fro = [[util.html_escape("A1"), util.html_escape("B1")], [util.html_escape("A2"), util.html_escape("B2")]] ret = areas.make_turbo_query_for_streets(relation, fro) expected = """[out:json][timeout:425]; rel(2713748)->.searchRelation; area(3602713748)->.searchArea; (way["name"="A2"](r.searchRelation); way["name"="A2"](area.searchArea); ); out body; >; out skel qt;""" self.assertEqual(ret, expected)
def test_happy(self) -> None: """Tests the happy path.""" relations = areas.Relations(test_context.make_test_context()) relation = relations.get_relation("gazdagret") fro = ["A2"] ret = areas.make_turbo_query_for_streets(relation, fro) expected = """[out:json][timeout:425]; rel(2713748)->.searchRelation; area(3602713748)->.searchArea; (rel(2713748); way["name"="A2"](r.searchRelation); way["name"="A2"](area.searchArea); ); out body; >; out skel qt; {{style: relation{width:3} way{color:blue; width:4;} }}""" self.assertEqual(ret, expected)