Пример #1
0
    def test_handle_soap_fault_server(self):
        test_response = helpers.generate_test_soap_response(
            'open_ldbws', 'darwin_fault.xml')
        with self.assertRaises(OpenLDBWSError) as context:
            data.handle_soap_fault(test_response)

        expected_err = 'Request to Darwin failed - Internal server error'
        self.assertEqual(expected_err, str(context.exception))
Пример #2
0
    def test_handle_soap_fault_client(self):
        test_response = helpers.generate_test_soap_response(
            'open_ldbws', 'client_err.xml')
        with self.assertRaises(ApplicationError) as context:
            data.handle_soap_fault(test_response)

        expected_err = 'Request to Darwin failed - Invalid crs code supplied'
        self.assertEqual(expected_err, str(context.exception))
Пример #3
0
    def test_parse_departures_soap_response_no_departures(self, mock_logger):
        test_response = helpers.generate_test_soap_response(
            'open_ldbws', 'departure_board_empty.xml')

        departures = data.parse_departures_soap_response(test_response, 'last')
        self.assertIsNone(departures)
        mock_logger.warning.assert_called_with(
            'OpenLDBWS returned no departures')
Пример #4
0
    def test_parse_departures_soap_response_last(self):
        test_response = helpers.generate_test_soap_response(
            'open_ldbws', 'departure_board.xml')

        departures = data.parse_departures_soap_response(test_response, 'last')
        expected_first_departure = helpers.generate_departure_details(
            etd='On time')
        self.assertEqual(len(departures), 10)
        self.assertTupleEqual(expected_first_departure, departures[0])
Пример #5
0
    def test_parse_departures_soap_response_fault(self, mock_fault_handler):
        test_response = helpers.generate_test_soap_response(
            'open_ldbws', 'darwin_fault.xml')
        mock_fault_handler.side_effect = OpenLDBWSError(
            'Request to Darwin failed - Internal server error')
        with self.assertRaises(OpenLDBWSError) as context:
            data.parse_departures_soap_response(test_response, 'last')

        expected_err = 'Request to Darwin failed - Internal server error'
        self.assertEqual(expected_err, str(context.exception))
        mock_fault_handler.assert_called_once()
Пример #6
0
 def test_parse_fastest_departure_soap_response(self):
     test_response = helpers.generate_test_soap_response(
         'open_ldbws', 'fastest_departure.xml')
     departure = data.parse_fastest_departure_soap_response(test_response)
     expected_departure = helpers.generate_departure_details(etd='On time')
     self.assertTupleEqual(departure, expected_departure)