def test_sort_key_wip(self):
     # If the proposal is a work in progress, the date_created is used.
     bmp = self.factory.makeBranchMergeProposal(
         date_created=datetime(2009, 6, 1, tzinfo=pytz.UTC))
     login_person(bmp.target_branch.owner)
     item = BranchMergeProposalListingItem(bmp, None, None)
     self.assertEqual(bmp.date_created, item.sort_key)
 def test_sort_key_approved_from_wip(self):
     # If the proposal is approved and the review has been bypassed, the
     # date_reviewed is used.
     bmp = self.factory.makeBranchMergeProposal(
         date_created=datetime(2009, 6, 1, tzinfo=pytz.UTC))
     login_person(bmp.target_branch.owner)
     review_date = datetime(2009, 8, 1, tzinfo=pytz.UTC)
     bmp.approveBranch(bmp.target_branch.owner, 'rev-id', review_date)
     item = BranchMergeProposalListingItem(bmp, None, None)
     self.assertEqual(review_date, item.sort_key)
 def test_sort_key_needs_review(self):
     # If the proposal is in needs review, the sort_key will be the
     # date_review_requested.
     bmp = self.factory.makeBranchMergeProposal(
         date_created=datetime(2009, 6, 1, tzinfo=pytz.UTC))
     login_person(bmp.registrant)
     request_date = datetime(2009, 7, 1, tzinfo=pytz.UTC)
     bmp.requestReview(request_date)
     item = BranchMergeProposalListingItem(bmp, None, None)
     self.assertEqual(request_date, item.sort_key)
 def test_sort_key_approved(self):
     # If the proposal is approved, the sort_key will default to the
     # date_review_requested.
     bmp = self.factory.makeBranchMergeProposal(
         date_created=datetime(2009, 6, 1, tzinfo=pytz.UTC))
     login_person(bmp.target_branch.owner)
     request_date = datetime(2009, 7, 1, tzinfo=pytz.UTC)
     bmp.requestReview(request_date)
     bmp.approveBranch(bmp.target_branch.owner, 'rev-id',
                       datetime(2009, 8, 1, tzinfo=pytz.UTC))
     item = BranchMergeProposalListingItem(bmp, None, None)
     self.assertEqual(request_date, item.sort_key)