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"])
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"])
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"])
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"], )
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"] )
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"] )
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"] )
def geo(lat: float, lon: float) -> str: wikipedia.set_lang('en') return json.dumps( filterResult( wikipedia.page( wikipedia.geosearch(lat, lon))))
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))
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"], )