Пример #1
0
    def test_init_no_wsdl_with_stationcodes(self):

        config = NationalRailEnquiriesWSDLServiceConfiguration.from_data(
            "wsdl", "nationalrailenquiries", "travel")
        config._station_codes_file = os.path.dirname(
            __file__) + os.sep + 'station_codes.csv'

        wsdl_client = NationalRailEnquiriesWSDLService(config)
        self.assertIsNotNone(wsdl_client)

        client = NationalRailEnquiriesServiceTestClient()
        wsdl_client.initialise(client)

        result = wsdl_client.get_station_name_from_code('KGH')
        self.assertEquals("KINGHORN",
                          result['response']['payload']['station_name'])

        result = wsdl_client.get_station_code_from_name('KINGHORN')
        self.assertEquals("KGH", result['response']['payload']['station_code'])

        self.assertEquals([], wsdl_client._match_station("XXXXXXX"))

        self.assertEquals(['KINGHORN'], wsdl_client._match_station("Kinghorn"))

        self.assertEquals(
            ['KIRKBY (MERSEYSIDE)', 'KIRKBY STEPHEN', 'KIRKBY-IN-ASHFIELD'],
            wsdl_client._match_station("Kirkby"))
Пример #2
0
    def test_get_service_details(self):

        config = NationalRailEnquiriesWSDLServiceConfiguration.from_data(
            "wsdl", "nationalrailenquiries", "travel")
        config._station_codes_file = os.path.dirname(
            __file__) + os.sep + 'station_codes.csv'

        wsdl_client = NationalRailEnquiriesWSDLService(config)
        self.assertIsNotNone(wsdl_client)

        client = NationalRailEnquiriesServiceTestClient()
        wsdl_client.initialise(client)

        departures = wsdl_client.get_next_departures('KGH', ['EDB'])

        response = departures['response']
        payload = response['payload']
        next_departures = payload['next_departures']
        departures = next_departures['departures']
        destination = departures['destination'][0]
        service = destination['service']
        serviceID = service['serviceID']

        details = wsdl_client.get_service_details(serviceID)
        self.assertIsNotNone(details)
        self.assertTrue('response' in details)
        response = details['response']
        self.assertEquals(response['status'], 'success')
        self.assertTrue('payload' in response)
        payload = response['payload']
        self.assertTrue('service_details' in payload)
Пример #3
0
    def test_init_no_wsdl(self):

        config = NationalRailEnquiriesWSDLServiceConfiguration.from_data(
            "wsdl", "nationalrailenquiries", "travel")

        wsdl_client = NationalRailEnquiriesWSDLService(config)
        self.assertIsNotNone(wsdl_client)

        client = NationalRailEnquiriesServiceTestClient()
        wsdl_client.initialise(client)
Пример #4
0
    def test_next_trains_from_station(self):

        config = NationalRailEnquiriesWSDLServiceConfiguration.from_data(
            "wsdl", "nationalrailenquiries", "travel")
        config._station_codes_file = os.path.dirname(
            __file__) + os.sep + 'station_codes.csv'

        wsdl_client = NationalRailEnquiriesWSDLService(config)
        self.assertIsNotNone(wsdl_client)

        client = NationalRailEnquiriesServiceTestClient()
        wsdl_client.initialise(client)

        response = wsdl_client.next_trains_from_station('Kinghorn')
        self.assertIsNotNone(response)
Пример #5
0
    def test_next_trains_from_station_platform_origin_destination(self):

        config = NationalRailEnquiriesWSDLServiceConfiguration.from_data(
            "wsdl", "nationalrailenquiries", "travel")
        config._station_codes_file = os.path.dirname(
            __file__) + os.sep + 'station_codes.csv'

        wsdl_client = NationalRailEnquiriesWSDLService(config)
        self.assertIsNotNone(wsdl_client)

        client = NationalRailEnquiriesServiceTestClient()
        wsdl_client.initialise(client)

        response = wsdl_client.next_trains_from_station(
            station='Kinghorn',
            platform='2',
            origin="Edinburgh",
            destination='Glenrothes with Thornton')

        self.assertIsNotNone(response)
Пример #6
0
    def test_get_arrival_boards_with_details(self):

        config = NationalRailEnquiriesWSDLServiceConfiguration.from_data(
            "wsdl", "nationalrailenquiries", "travel")
        config._station_codes_file = os.path.dirname(
            __file__) + os.sep + 'station_codes.csv'

        wsdl_client = NationalRailEnquiriesWSDLService(config)
        self.assertIsNotNone(wsdl_client)

        client = NationalRailEnquiriesServiceTestClient()
        wsdl_client.initialise(client)

        details = wsdl_client.get_arrival_boards_with_details(10, 'KGH')

        self.assertIsNotNone(details)
        self.assertTrue('response' in details)
        response = details['response']
        self.assertEquals(response['status'], 'success')
        self.assertTrue('payload' in response)
        payload = response['payload']
        self.assertTrue('arrival_boards_with_details' in payload)