'Testing whether a download is stopped on error in the download states callback in LaunchManyCore'

@deferred(timeout=10)
def test_dlstates_cb_error(self):

    error_stop_deferred = Deferred()
    def mocked_stop():
        error_stop_deferred.callback(None)
    error_tdef = TorrentDef()
    error_tdef.get_infohash = (lambda : 'aaaa')
    fake_error_download = MockObject()
    fake_error_download.get_def = (lambda : error_tdef)
    fake_error_download.get_def().get_name_as_unicode = (lambda : 'test.iso')
    fake_error_download.stop = mocked_stop
    fake_error_state = MockObject()
    fake_error_state.get_infohash = (lambda : 'aaaa')
    fake_error_state.get_error = (lambda : 'test    error')
    fake_error_state.get_status = (lambda : DLSTATUS_STOPPED_ON_ERROR)
    fake_error_state.get_download = (lambda : fake_error_download)
    self.lm.downloads = {'aaaa': fake_error_download}
    self.lm.sesscb_states_callback([fake_error_state])
    return error_stop_deferred
