Esempio n. 1
0
    def _do_placename(self):
        service = GeoNamesService(ServiceConfiguration.from_data("rest", "geonames", "geocode"))

        self.assertIsNotNone(service)

        client = GeoNamesServiceTestClient()
        service.initialise(client)

        response = service.latlng_for_placename("KY3 9UR")
        self.assertResponse(response, 'latlng_for_placename', "geonames", "geocode")
Esempio n. 2
0
    def test_placename_aiml_with_country(self):
        client = GeoNamesServiceTestClient()
        conf_file = GeoNamesService.get_default_conf_file()

        response = self._do_handler_load(client, conf_file, "geonames", "GEONAMES LATLNG PLACENAME KINGHORN COUNTRY UK")
        self.assertIsNotNone(response)
        self.assertEqual("LAT SIGN POS DEC 56 FRAC 07206630948395 LNG SIGN NEG DEC 3 FRAC 175233081708717.", response)
Esempio n. 3
0
    def test_postcode_aiml(self):
        client = GeoNamesServiceTestClient()
        conf_file = GeoNamesService.get_default_conf_file()

        response = self._do_handler_load(client, conf_file, "geonames", "GEONAMES LATLNG POSTCODE KY39UR")
        self.assertIsNotNone(response)
        self.assertEqual("LAT SIGN POS DEC 56 FRAC 07206630948395 LNG SIGN NEG DEC 3 FRAC 175233081708717.", response)
Esempio n. 4
0
    def load_storage(self):
        super(ServiceHandlerTestClient, self).load_storage()

        self.add_license_keys_store(filepath=os.path.dirname(__file__) + os.sep + "testdata" + os.sep + "license.keys")

        self.add_services_store(dirs=[MetOfficeService.get_default_conf_file(),
                                      WikipediaService.get_default_conf_file(),
                                      AccuWeatherService.get_default_conf_file(),
                                      CocktailDBService.get_default_conf_file(),
                                      DarkSkyService.get_default_conf_file(),
                                      DuckDuckGoService.get_default_conf_file(),
                                      GenericService.get_default_conf_file(),
                                      GeoNamesService.get_default_conf_file(),
                                      GetGuidelinesService.get_default_conf_file(),
                                      GNewsService.get_default_conf_file(),
                                      GoodReadsService.get_default_conf_file(),
                                      GoogleGeoCodeService.get_default_conf_file(),
                                      GoogleDistanceService.get_default_conf_file(),
                                      GoogleDirectionsService.get_default_conf_file(),
                                      NewsAPIService.get_default_conf_file(),
                                      OMDBService.get_default_conf_file(),
                                      PandoraService.get_default_conf_file(),
                                      ProgramyService.get_default_conf_file(),
                                      WolframAlphaService.get_default_conf_file(),
                                      WorldTradingDataStocksService.get_default_conf_file()
                                      ])
        self.add_pattern_nodes_store()
        self.add_template_nodes_store()
Esempio n. 5
0
    def test_placename_aiml_different_country(self):
        client = GeoNamesServiceTestClient()
        conf_file = GeoNamesService.get_default_conf_file()

        response = self._do_handler_load(client, conf_file, "geonames", "GEONAMES LATLNG PLACENAME WASHINGTON COUNTRY US")
        self.assertIsNotNone(response)
        self.assertEqual("LAT SIGN POS DEC 38 FRAC 545851 LNG SIGN NEG DEC 91 FRAC 019346.", response)

        response = self._do_handler_load(client, conf_file, "geonames", "GEONAMES LATLNG PLACENAME WASHINGTON COUNTRY UK")
        self.assertIsNotNone(response)
        self.assertEqual("LAT SIGN POS DEC 54 FRAC 885019095463335 LNG SIGN NEG DEC 1 FRAC 5427184694082379.", response)
Esempio n. 6
0
    def test_forecast_postcode_aiml(self):
        client = DarkSkyServiceTestClient()
        client_context = client.create_client_context("testuser")

        self._load_conf_file(client_context,
                             DarkSkyService.get_default_conf_file())
        self.assertTrue(
            "darksky" in client_context.brain.service_handler.services)
        self._load_conf_file(client_context,
                             GeoNamesService.get_default_conf_file())
        self.assertTrue(
            "geonames" in client_context.brain.service_handler.services)

        response = client_context.bot.ask_question(
            client_context, "DARKSKY FORECAST POSTCODE KY39UR")
        self.assertIsNotNone(response)
        self.assertTrue(response.startswith("It is currently"))
Esempio n. 7
0
    def test_timemachine_postcode_aiml(self):
        client = DarkSkyServiceTestClient()
        client_context = client.create_client_context("testuser")

        self._load_conf_file(client_context,
                             DarkSkyService.get_default_conf_file())
        self.assertTrue(
            "darksky" in client_context.brain.service_handler.services)
        self._load_conf_file(client_context,
                             GeoNamesService.get_default_conf_file())
        self.assertTrue(
            "geonames" in client_context.brain.service_handler.services)

        response = client_context.bot.ask_question(
            client_context,
            "DARKSKY TIMEMACHINE POSTCODE KY39UR TIME 255657600")
        self.assertIsNotNone(response)
        self.assertTrue(response.startswith("It was"))
Esempio n. 8
0
    def test_weather_postcode(self):
        client = MetOfficeTestClient()
        client_context = client.create_client_context("testuser")

        self._load_conf_file(client_context,
                             MetOfficeService.get_default_conf_file())
        self.assertTrue(
            "metoffice" in client_context.brain.service_handler.services)
        self._load_conf_file(client_context,
                             GeoNamesService.get_default_conf_file())
        self.assertTrue(
            "geonames" in client_context.brain.service_handler.services)

        response = client_context.bot.ask_question(
            client_context, "METOFFICE WEATHER POSTCODE KY39UR")

        self.assertIsNotNone(response)
        self.assertEqual(
            "It is currently Partly cloudy (day) , with a temperature of 12 . 3 'C.",
            response)
Esempio n. 9
0
 def test_init(self):
     service = GeoNamesService(ServiceConfiguration.from_data("rest", "geonames", "geocode"))
     self.assertIsNotNone(service)