コード例 #1
0
ファイル: test_util.py プロジェクト: Athoss9/osm-gimmisn
 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, "hazszamok_20190511.tsv")
     util.build_reference_cache(refpath, "01")
     memory_cache = util.build_reference_cache(refpath, "01")
     expected = {'01': {'011': {'Hamzsabégi út': hnr_list(['1']),
                                'Ref Name 1': hnr_list(['1', '2']),
                                'Törökugrató utca': hnr_list(['1', '10', '11', '12', '2', '7']),
                                'Tűzkő utca': hnr_list(['1', '10', '2', '9'])}}}
     self.assertEqual(memory_cache, expected)
     os.unlink(util.get_reference_cache_path(refpath, "01"))
コード例 #2
0
 def test_missing(self) -> None:
     """Tests the case when the street is not in the reference."""
     relations = get_relations()
     refdir = os.path.join(os.path.dirname(__file__), "refdir")
     refpath = os.path.join(refdir, "hazszamok_20190511.tsv")
     memory_cache = util.build_reference_cache(refpath, "01")
     relation_name = "gazdagret"
     street = "No such utca"
     relation = relations.get_relation(relation_name)
     ret = relation.build_ref_housenumbers(memory_cache, street, "")
     self.assertEqual(ret, [])
コード例 #3
0
ファイル: test_util.py プロジェクト: ImreSamu/osm-gimmisn
 def test_happy(self) -> None:
     """Tests the happy path."""
     refdir = os.path.join(os.path.dirname(__file__), "refdir")
     refpath = os.path.join(refdir, "hazszamok_20190511.tsv")
     memory_cache = util.build_reference_cache(refpath)
     expected = {
         '01': {
             '011': {
                 'Ref Name 1': ['1', '2'],
                 'Törökugrató utca': ['1', '10', '11', '12', '2', '7'],
                 'Tűzkő utca': ['1', '10', '2', '9'],
                 'Hamzsabégi út': ['1']
             }
         }
     }
     self.assertEqual(memory_cache, expected)
     os.unlink(refpath + ".pickle")
コード例 #4
0
 def test_happy(self) -> None:
     """Tests the happy path."""
     refdir = os.path.join(os.path.dirname(__file__), "refdir")
     relations = get_relations()
     refpath = os.path.join(refdir, "hazszamok_20190511.tsv")
     memory_cache = util.build_reference_cache(refpath, "01")
     relation_name = "gazdagret"
     street = "Törökugrató utca"
     relation = relations.get_relation(relation_name)
     ret = relation.build_ref_housenumbers(memory_cache, street, "")
     expected = [
         'Törökugrató utca\t1\tcomment',
         'Törökugrató utca\t10\t',
         'Törökugrató utca\t11\t',
         'Törökugrató utca\t12\t',
         'Törökugrató utca\t2\t',
         'Törökugrató utca\t7\t',
     ]
     self.assertEqual(ret, expected)
コード例 #5
0
ファイル: test_areas.py プロジェクト: kadarivan/osm-gimmisn
 def test_happy(self) -> None:
     """Tests the happy path."""
     with unittest.mock.patch('util.get_abspath', get_abspath):
         refdir = os.path.join(os.path.dirname(__file__), "refdir")
         relations = get_relations()
         refpath = os.path.join(refdir, "hazszamok_20190511.tsv")
         memory_cache = util.build_reference_cache(refpath)
         relation_name = "gazdagret"
         street = "Törökugrató utca"
         relation = relations.get_relation(relation_name)
         ret = relation.build_ref_housenumbers(memory_cache, street, "")
         expected = [
             'Törökugrató utca\t1',
             'Törökugrató utca\t10',
             'Törökugrató utca\t11',
             'Törökugrató utca\t12',
             'Törökugrató utca\t2',
             'Törökugrató utca\t7',
         ]
         self.assertEqual(ret, expected)