Пример #1
0
    def test_geocode_error_string(self):
        DAMS.init_dams()

        address = "東京都足立区/バイク/スポーツ/仲間集め"
        returned = DAMS.geocode(address)
        expected = {"score": 0, "tail": "", "candidates": []}
        self.assertEqual(returned, expected)
Пример #2
0
    def test_geocode_segfault_string(self):
        DAMS.init_dams()

        address = "東京都足立区/バイク/スポーツ/仲間集め"
        try:
            returned = DAMS.geocode(address)
        except Exception as e:
            self.fail("unexpectedly caught exception.")
Пример #3
0
    def test_geocode_level_3(self):
        DAMS.init_dams()

        address = "港区"
        returned = DAMS.geocode(address)

        expected = {
            "score":
            2,
            "candidates": [[{
                "name": "愛知県",
                "x": 136.907,
                "y": 35.1809,
                "level": 1
            }, {
                "name": "名古屋市",
                "x": 136.907,
                "y": 35.1809,
                "level": 3
            }, {
                "name": "港区",
                "x": 136.885,
                "y": 35.1082,
                "level": 4
            }],
                           [{
                               "name": "大阪府",
                               "x": 135.52,
                               "y": 34.6864,
                               "level": 1
                           }, {
                               "name": "大阪市",
                               "x": 135.501,
                               "y": 34.6939,
                               "level": 3
                           }, {
                               "name": "港区",
                               "x": 135.461,
                               "y": 34.6641,
                               "level": 4
                           }],
                           [
                               {
                                   "name": "東京都",
                                   "x": 139.692,
                                   "y": 35.6895,
                                   "level": 1
                               },
                               {
                                   "name": "港区",
                                   "x": 139.752,
                                   "y": 35.6585,
                                   "level": 3
                               },
                           ]]
        }
        self._assert_geocoded_object(returned, expected)
Пример #4
0
    def test_geocode_oaza_batch(self):
        DAMS.init_dams()

        for address in self._lst_oaza:
            returned = DAMS.geocode(address)
            n_candidates = len(returned["candidates"])
            score = returned["score"]
            if n_candidates == 1:
                self.assertGreaterEqual(score, 3)
            else:
                self.assertGreaterEqual(score, 1)
Пример #5
0
    def test_pretty_print(self):
        DAMS.init_dams()

        address = "東京都"
        returned = DAMS.geocode(address)
        with suppress_stdout():
            pretty_print(returned)

        address = "東京都千代田区富士見3-1-11"
        returned = DAMS.geocode_simplify(address)
        with suppress_stdout():
            pretty_print(returned)

        self.assertTrue(True)
Пример #6
0
    def test_geocode_oaza_subtest(self):
        DAMS.init_dams()

        for address in self._lst_oaza:
            returned = DAMS.geocode(address)
            n_candidates = len(returned["candidates"])
            score = returned["score"]
            with self.subTest(address=address,
                              score=score,
                              candidates=n_candidates):
                if n_candidates == 1:
                    self.assertGreaterEqual(score, 3)
                else:
                    self.assertGreaterEqual(score, 1)
Пример #7
0
    def test_geocode_level_1(self):
        DAMS.init_dams()

        address = "東京都"
        returned = DAMS.geocode(address)

        expected = {
            "score":
            3,
            "candidates": [[{
                "name": "東京都",
                "x": 139.692,
                "y": 35.6895,
                "level": 1
            }]]
        }
        self._assert_geocoded_object(returned, expected)