l.a.t.t.BaseAnswerTrackerWorkflowTestCase(unittest.TestCase) : class documentation

Part of lp.answers.tests.test_question_workflow View In Hierarchy

Known subclasses: lp.answers.tests.test_question_workflow.ConfirmAnswerTestCase, lp.answers.tests.test_question_workflow.ExpireQuestionTestCase, lp.answers.tests.test_question_workflow.GiveAnswerTestCase, lp.answers.tests.test_question_workflow.GiveInfoTestCase, lp.answers.tests.test_question_workflow.LinkFAQTestCase, lp.answers.tests.test_question_workflow.MiscAnswerTrackerWorkflowTestCase, lp.answers.tests.test_question_workflow.RejectTestCase, lp.answers.tests.test_question_workflow.ReopenTestCase, lp.answers.tests.test_question_workflow.RequestInfoTestCase

Base class for test cases related to the Answer Tracker workflow.

It provides the common fixture and test helper methods.

Method setUp Undocumented
Method tearDown Undocumented
Method setQuestionStatus Utility metho to change a question status.
Method setUpEventListeners Install a listener for events emitted during the test.
Method collectEvent Collect events
Method nowPlus Return a DateTime a number of hours in the future.
Method checkTransitionMessage Helper method to check the message created by a transition.
Method checkTransitionEvents Helper method to validate the events triggered from the transition.
Method _testTransitionGuard Helper for transition guard tests.
Method _testValidTransition Helper for testing valid state transitions.
Method _testInvalidTransition Helper for testing invalid transitions.
def setUp(self):
Undocumented
def tearDown(self):
Undocumented
def setQuestionStatus(self, question, new_status, comment='Status change.'):
Utility metho to change a question status.

This logs in as admin, change the status and log back as the previous user.

def setUpEventListeners(self):
Install a listener for events emitted during the test.
def collectEvent(self, object, event):
Collect events
def nowPlus(self, n_hours):
Return a DateTime a number of hours in the future.
def _testTransitionGuard(self, guard_name, statuses_expected_true):
Helper for transition guard tests.

Helper that verifies that the Question guard_name attribute is True when the question status is one listed in statuses_expected_true and False otherwise.

def _testValidTransition(self, statuses, transition_method, expected_owner, expected_action, expected_status, extra_message_check=None, transition_method_args=(), transition_method_kwargs=None, edited_fields=None):
Helper for testing valid state transitions.

Helper that verifies that transition_method can be called when the question status is one listed in statuses. It will validate the returned message using checkTransitionMessage(). The transition_method is called with the transition_method_args as positional parameters and transition_method_kwargs as keyword parameters.

If extra_message_check is passed a function, it will be called with the returned message for extra checks.

The datecreated parameter to the transition_method is set automatically to a value that will make the message sort last.

The edited_fields parameter contain the list of field that are expected to be present in IObjectModifiedEvent that should be triggered.

def _testInvalidTransition(self, valid_statuses, transition_method, *args, **kwargs):
Helper for testing invalid transitions.

Helper that verifies that transition_method method cannot be called when the question status is different than the ones in valid_statuses.

args and kwargs contains the parameters that should be passed to the transition method.

def checkTransitionMessage(self, message, expected_owner, expected_action, expected_status):
Helper method to check the message created by a transition.

It make sure that the message provides IQuestionMessage and that it was appended to the question messages attribute. It also checks that the subject was computed correctly and that the new_status, action and owner attributes were set correctly.

It also verifies that the question status, datelastquery (or datelastresponse) were updated to reflect the time of the message.

def checkTransitionEvents(self, message, edited_fields, status_name):
Helper method to validate the events triggered from the transition.

Check that an IObjectCreatedEvent event was sent when the message was created and that an IObjectModifiedEvent was also sent. The event object and edited_fields attribute are checked.

API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.