Exemple #1
0
 def test_escape(self) -> None:
     """Tests escaping."""
     sock = util.CsvIO(io.StringIO("\"h,1\"\th2\n"))
     ret = util.tsv_to_list(sock)
     self.assertEqual(len(ret), 1)
     row1 = [cell.getvalue() for cell in ret[0]]
     # Note how this is just h,1 and not "h,1".
     self.assertEqual(row1, ['h,1', 'h2'])
Exemple #2
0
 def test_addr_place(self) -> None:
     """Tests the case when addr:place is used."""
     with util.CsvIO(
             open("tests/workdir/street-housenumbers-gh964.csv",
                  "r")) as stream:
         actual = util.get_street_from_housenumber(stream)
     # This is picked up from addr:place because addr:street was empty.
     self.assertEqual(actual, [util.Street(osm_name="Tolvajos tanya")])
Exemple #3
0
 def test_happy(self) -> None:
     """Tests the happy path."""
     sock = util.CsvIO(io.StringIO("h1\th2\n\nv1\tv2\n"))
     ret = util.tsv_to_list(sock)
     self.assertEqual(len(ret), 2)
     row1 = [cell.getvalue() for cell in ret[0]]
     self.assertEqual(row1, ['h1', 'h2'])
     row2 = [cell.getvalue() for cell in ret[1]]
     self.assertEqual(row2, ['v1', 'v2'])
Exemple #4
0
 def test_type(self) -> None:
     """Tests when a @type column is available."""
     stream = util.CsvIO(io.StringIO("@id\t@type\n42\tnode\n"))
     ret = util.tsv_to_list(stream)
     self.assertEqual(len(ret), 2)
     row1 = [cell.getvalue() for cell in ret[0]]
     self.assertEqual(row1, ["@id", "@type"])
     row2 = [cell.getvalue() for cell in ret[1]]
     cell_a2 = '<a href="https://www.openstreetmap.org/node/42" target="_blank">42</a>'
     self.assertEqual(row2, [cell_a2, "node"])
Exemple #5
0
 def get_osm_housenumbers_csv_stream(self) -> util.CsvIO:
     """Gets a CSV reader for the OSM house number list."""
     return util.CsvIO(self.__get_osm_housenumbers_stream("r"))
Exemple #6
0
 def get_osm_streets_csv_stream(self) -> util.CsvIO:
     """Gets a CSV reader for the OSM street list."""
     return util.CsvIO(self.__get_osm_streets_stream("r"))
Exemple #7
0
 def get_osm_housenumbers_csv_stream(self, ctx: context.Context) -> util.CsvIO:
     """Gets a CSV reader for the OSM house number list."""
     return util.CsvIO(self.__get_osm_housenumbers_stream(ctx, "rb"))