def test_setting_result(self): """Ensure the result can be set if the execute flag is set.""" from furious.async import Async job = Async(target=dir) job.executing = True job.result = 123 self.assertEqual(123, job.result) self.assertTrue(job.executed)
def test_setting_result(self): """Ensure the result can be set if the execute flag is set.""" from furious. async import Async job = Async(target=dir) job.executing = True job.result = 123 self.assertEqual(123, job.result) self.assertTrue(job.executed)
def test_getting_result(self): """Ensure getting the result after executing works.""" from furious.async import Async job = Async(target=dir) job._executing = True job.result = 123456 self.assertEqual(123456, job.result) self.assertTrue(job.executed)
def test_getting_result(self): """Ensure getting the result after executing works.""" from furious. async import Async job = Async(target=dir) job._executing = True job.result = 123456 self.assertEqual(123456, job.result) self.assertTrue(job.executed)
def test_setting_result_calls_persist(self): """Ensure setting the result calls the persist_result method.""" from furious.async import Async result = "here be the results." persistence_engine = mock.Mock() job = Async(target=dir, persist_result=True) # Manually set the persistence_engine so that the Async doesn't try to # reload the mock persistence_engine. job._persistence_engine = persistence_engine job.executing = True job.result = result persistence_engine.store_async_result.assert_called_once_with(job.id, result)
def test_setting_result_calls_persist(self): """Ensure setting the result calls the persist_result method.""" from furious. async import Async result = "here be the results." persistence_engine = mock.Mock() job = Async(target=dir, persist_result=True) # Manually set the persistence_engine so that the Async doesn't try to # reload the mock persistence_engine. job._persistence_engine = persistence_engine job.executing = True job.result = result persistence_engine.store_async_result.assert_called_once_with( job.id, result)
def test_setting_result_does_not_call_persist(self): """Ensure setting the result doesn't call persist result if not in persist mode. """ from furious.async import Async result = "here be the results." persistence_engine = mock.Mock() job = Async(target=dir) # Manually set the persistence_engine so that the Async doesn't try to # reload the mock persistence_engine. job._persistence_engine = persistence_engine job.executing = True job.result = result self.assertEqual(persistence_engine.store_async_result.call_count, 0)
def test_setting_result_does_not_call_persist(self): """Ensure setting the result doesn't call persist result if not in persist mode. """ from furious. async import Async result = "here be the results." persistence_engine = mock.Mock() job = Async(target=dir) # Manually set the persistence_engine so that the Async doesn't try to # reload the mock persistence_engine. job._persistence_engine = persistence_engine job.executing = True job.result = result self.assertEqual(persistence_engine.store_async_result.call_count, 0)