def test_interaction(self): # The WorkingBase.interaction context manager will begin an # interaction on entry and end it on exit. base = WorkingBase() base.init(self.email, transaction.manager, self.logger) endInteraction() self.assertIs(None, queryInteraction()) with base.interaction: self.assertIsNot(None, queryInteraction()) self.assertIs(None, queryInteraction())
def test_interaction_nested(self): # If an interaction is already in progress, the interaction # context manager will not begin a new interaction on entry, # nor will it end the interaction on exit. base = WorkingBase() base.init(self.email, transaction.manager, self.logger) endInteraction() self.assertIs(None, queryInteraction()) with base.interaction: self.assertIsNot(None, queryInteraction()) with base.interaction: self.assertIsNot(None, queryInteraction()) self.assertIsNot(None, queryInteraction()) self.assertIs(None, queryInteraction())