def test_cached(self) -> None: """Tests the case when the pickle cache is already available.""" refdir = os.path.join(os.path.dirname(__file__), "refdir") refpath = os.path.join(refdir, "utcak_20190514.tsv") util.build_street_reference_cache(refpath) memory_cache = util.build_street_reference_cache(refpath) expected = {'01': {'011': ['Törökugrató utca', 'Tűzkő utca', 'Ref Name 1', 'Only In Ref utca', 'Only In Ref Nonsense utca', 'Hamzsabégi út']}} self.assertEqual(memory_cache, expected) os.unlink(refpath + ".pickle")
def write_ref_streets(self, reference: str) -> None: """Gets known streets (not their coordinates) from a reference site, based on relation names from OSM.""" memory_cache = util.build_street_reference_cache(reference) lst = self.build_ref_streets(memory_cache) lst = sorted(set(lst)) with self.get_files().get_ref_streets_stream("w") as sock: for line in lst: sock.write(line + "\n")
def test_happy(self) -> None: """Tests the happy path.""" refdir = os.path.join(os.path.dirname(__file__), "refdir") refpath = os.path.join(refdir, "utcak_20190514.tsv") memory_cache = util.build_street_reference_cache(refpath) relation_name = "gazdagret" relations = get_relations() relation = relations.get_relation(relation_name) ret = relation.get_config().build_ref_streets(memory_cache) self.assertEqual(ret, [ 'Törökugrató utca', 'Tűzkő utca', 'Ref Name 1', 'Only In Ref utca', 'Only In Ref Nonsense utca', 'Hamzsabégi út' ])