def test_geonames(self): geonames = GeoNamesApi(self.license_keys) self.assertIsNotNone(geonames) latlng = geonames.get_latlong_for_postcode('KY39UR') self.assertIsNotNone(latlng) self.assertEqual(latlng.latitude, 56.07206267570594) self.assertEqual(latlng.longitude, -3.175233048730664)
def test_geonames(self): geonames = GeoNamesApi(self.license_keys) self.assertIsNotNone(geonames) latlng = geonames.get_latlong_for_postcode('KY39UR') self.assertIsNotNone(latlng) self.assertEquals(latlng.latitude, 56.07206267570594) self.assertEquals(latlng.longitude, -3.175233048730664)
def test_geonames_license_keys(self): license_keys = LicenseKeys() license_keys.add_key('GEO_NAMES_COUNTRY', "UK") license_keys.add_key('GEO_NAMES_ACCOUNTNAME', "TestAccount1") geonames = GeoNamesApi() geonames.check_for_license_keys(license_keys) self.assertEqual("UK", geonames.country) self.assertEqual("TestAccount1", geonames.account_name)
def test_geonames(self): client = TestClient() client.add_license_keys_store() geonames = GeoNamesApi(client.license_keys) self.assertIsNotNone(geonames) GeoNamesApi.get_latlong_for_postcode_response_file = os.path.dirname(__file__)+ os.sep + "geonames_latlong.json" latlng = geonames.get_latlong_for_postcode('KY39UR') self.assertIsNotNone(latlng) self.assertEqual(latlng.latitude, 56.07206267570594) self.assertEqual(latlng.longitude, -3.175233048730664)
def test_geonames(self): license_keys = LicenseKeys() license_keys.load_license_key_file(os.path.dirname(__file__)+"/test.keys") geonames = GeoNamesApi(license_keys) self.assertIsNotNone(geonames) GeoNamesApi.get_latlong_for_postcode_response_file = os.path.dirname(__file__)+"/postcode.json" latlng = geonames.get_latlong_for_postcode('KY39UR') self.assertIsNotNone(latlng) self.assertEquals(latlng.latitude, 56.07206267570594) self.assertEquals(latlng.longitude, -3.175233048730664)
def test_geonames(self): license_keys = LicenseKeys() license_keys.load_license_key_file(os.path.dirname(__file__)+ os.sep + "test.keys") geonames = GeoNamesApi(license_keys) self.assertIsNotNone(geonames) GeoNamesApi.get_latlong_for_postcode_response_file = os.path.dirname(__file__)+ os.sep + "geonames_latlong.json" latlng = geonames.get_latlong_for_postcode('KY39UR') self.assertIsNotNone(latlng) self.assertEquals(latlng.latitude, 56.07206267570594) self.assertEquals(latlng.longitude, -3.175233048730664)
import os from programy.utils.text.text import TextUtils from programy.utils.geo.geonames import GeoNamesApi from programy.utils.license.keys import LicenseKeys if __name__ == '__main__': # Only to be used to create test data for unit aiml_tests license_keys = LicenseKeys() license_keys.load_license_key_file(os.path.dirname(__file__) + TextUtils.replace_path_seperator('/../../../../bots/y-bot/config/license.keys')) geonamesapi = GeoNamesApi(license_keys) # Running these tools drops test files into the geocode test folder geonamesapi.store_get_latlong_for_postcode_to_file("KY39UR", TextUtils.replace_path_seperator("../../../test/utils/geocode/geonames_latlong.json")) geonamesapi.store_get_latlong_for_postcode_to_file("KY39UR", TextUtils.replace_path_seperator("../../../test/utils/geo/geonames_latlong.json")) # Only to be used to create test data for unit aiml_tests
def test_geonames_no_country(self): license_keys = LicenseKeys() license_keys.add_key('GEO_NAMES_ACCOUNTNAME', "DummyValue") with self.assertRaises(Exception): geonames = GeoNamesApi(license_keys)
def test_geonames_no_license_keys(self): license_keys = LicenseKeys() with self.assertRaises(Exception): geonames = GeoNamesApi(license_keys)
import os from programy.utils.text.text import TextUtils from programy.utils.geo.geonames import GeoNamesApi from programy.utils.license.keys import LicenseKeys if __name__ == '__main__': # Only to be used to create test data for unit aiml_tests license_keys = LicenseKeys() license_keys.load_license_key_file( os.path.dirname(__file__) + TextUtils.replace_path_seperator( '/../../../../bots/y-bot/config/license.keys')) geonamesapi = GeoNamesApi(license_keys) # Running these tools drops test files into the geocode test folder geonamesapi.store_get_latlong_for_postcode_to_file( "KY39UR", TextUtils.replace_path_seperator( "../../../test/utils/geocode/geonames_latlong.json")) geonamesapi.store_get_latlong_for_postcode_to_file( "KY39UR", TextUtils.replace_path_seperator( "../../../test/utils/geo/geonames_latlong.json")) # Only to be used to create test data for unit aiml_tests
def test_geonames_with_license_keys(self): license_keys = LicenseKeys() license_keys.add_key('GEO_NAMES_COUNTRY', "DummyValue") license_keys.add_key('GEO_NAMES_ACCOUNTNAME', "DummyValue") geonames = GeoNamesApi(license_keys)
def test_geonames_no_account_name(self): license_keys = LicenseKeys() license_keys.add_key('GEO_NAMES_COUNTRY', "DummyValue") with self.assertRaises(Exception): GeoNamesApi(license_keys)
def __init__(self, response): GeoNamesApi.__init__(self) self._response = response
def test_geonames_missing_license_keys(self): license_keys = LicenseKeys() geonames = GeoNamesApi() with self.assertRaises(Exception): geonames.check_for_license_keys(license_keys)