Esempio n. 1
0
 def test_geosearch_with_existing_title(self):
     """Test parsing a Wikipedia location request result."""
     self.assertEqual(
         wikipedia.geosearch(Decimal('40.67693'),
                             Decimal('117.23193'),
                             title='Great Wall of China'), mock_data['data']
         ["great_wall_of_china.geo_seach_with_existing_article_name"])
Esempio n. 2
0
 def test_geosearch_with_non_existing_title(self):
     ''' Test the results when no title exists '''
     self.assertEqual(
         wikipedia.geosearch(Decimal('40.67693'),
                             Decimal('117.23193'),
                             title='Test'), mock_data['data']
         ["great_wall_of_china.geo_seach_with_non_existing_article_name"])
Esempio n. 3
0
 def test_geosearch_with_radius(self):
     """Test parsing a Wikipedia location request result."""
     self.assertEqual(
         wikipedia.geosearch(Decimal('40.67693'),
                             Decimal('117.23193'),
                             radius=10000),
         mock_data['data']["great_wall_of_china.geo_seach_with_radius"])
Esempio n. 4
0
 def test_geosearch_with_non_existing_title(self):
     self.assertEqual(
         wikipedia.geosearch(Decimal("40.67693"),
                             Decimal("117.23193"),
                             title="Test"),
         mock_data["data"]
         ["great_wall_of_china.geo_seach_with_non_existing_article_name"],
     )
Esempio n. 5
0
 def test_geosearch_with_non_existing_title(self):
   self.assertEqual(wikipedia.geosearch(
     Decimal('40.67693'), Decimal('117.23193'), title='Test'),
     mock_data['data']["great_wall_of_china.geo_seach_with_non_existing_article_name"]
   )
Esempio n. 6
0
 def test_geosearch_with_existing_title(self):
   """Test parsing a Wikipedia location request result."""
   self.assertEqual(wikipedia.geosearch(
     Decimal('40.67693'), Decimal('117.23193'), title='Great Wall of China'),
     mock_data['data']["great_wall_of_china.geo_seach_with_existing_article_name"]
   )
Esempio n. 7
0
 def test_geosearch_with_radius(self):
   """Test parsing a Wikipedia location request result."""
   self.assertEqual(wikipedia.geosearch(
     Decimal('40.67693'), Decimal('117.23193'), radius=10000),
     mock_data['data']["great_wall_of_china.geo_seach_with_radius"]
   )
Esempio n. 8
0
def geo(lat: float, lon: float) -> str:
    wikipedia.set_lang('en')
    return json.dumps(
        filterResult(
            wikipedia.page(
                wikipedia.geosearch(lat, lon))))
Esempio n. 9
0
 def test_wikipedia_exception_invalid_coordinate(self):
     with self.assertRaises(Exception) as context:
         wikipedia.geosearch('40.67693', '117..23193')  # invalid coordinate
     self.assertFalse(
         "wikipedia.exceptions.WikipediaException: An unknown error occured: \"{0}\". Please report it on GitHub!"
         in str(context.exception))
Esempio n. 10
0
 def test_geosearch(self):
     """Test parsing a Wikipedia location request result."""
     self.assertEqual(
         wikipedia.geosearch(Decimal("40.67693"), Decimal("117.23193")),
         mock_data["data"]["great_wall_of_china.geo_seach"],
     )