'Test for operational uk_transport sensor with proper attributes.'

@requests_mock.Mocker()
def test_train(self, mock_req):

    with requests_mock.Mocker() as mock_req:
        uri = re.compile((UkTransportSensor.TRANSPORT_API_URL_BASE + '*'))
        mock_req.get(uri, text=load_fixture('uk_transport_train.json'))
        self.assertTrue(setup_component(self.hass, 'sensor', {'sensor': self.config}))
    train_state = self.hass.states.get('sensor.next_train_to_WAT')
    assert (type(train_state.state) == str)
    assert (train_state.name == 'Next    train    to    {}'.format(TRAIN_DESTINATION_NAME))
    assert (train_state.attributes.get(ATTR_STATION_CODE) == TRAIN_STATION_CODE)
    assert (train_state.attributes.get(ATTR_CALLING_AT) == TRAIN_DESTINATION_NAME)
    assert (len(train_state.attributes.get(ATTR_NEXT_TRAINS)) == 25)
    assert (train_state.attributes.get(ATTR_NEXT_TRAINS)[0]['destination_name'] == 'London    Waterloo')
    assert (train_state.attributes.get(ATTR_NEXT_TRAINS)[0]['estimated'] == '06:13')
