def test_check_lots_awarding(self, mock_set_stand_still_ends, mock_check_pending_awards_complaints, mock_check_pending_complaints): need_status = 'active' need_status_award = 'unsuccessful' need_lot_id = uuid.uuid4().hex lot = munch.Munch({'status': need_status, 'id': need_lot_id}) award = munch.Munch({ 'lotID': need_lot_id, 'status': need_status_award }) auction = munch.Munch({'lots': [lot], 'awards': [award]}) mock_check_pending_complaints.return_value = None mock_check_pending_awards_complaints.return_value = None mock_set_stand_still_ends.return_value = [0, 1] result = check_lots_awarding(auction) self.assertEqual(result, [1]) mock_check_pending_complaints.return_value = True mock_set_stand_still_ends.return_value = [0, 1] result = check_lots_awarding(auction) self.assertEqual(result, []) mock_check_pending_complaints.return_value = None mock_check_pending_awards_complaints.return_value = True mock_set_stand_still_ends.return_value = [0, 1] result = check_lots_awarding(auction) self.assertEqual(result, [])
def next_check_awarding(auction): checks = [] if not auction.lots and auction.status == 'active.qualification': for award in auction.awards: if award.status == 'pending.admission': checks.append(award.admissionPeriod.endDate.astimezone(TZ)) elif awarded_and_lots_predicate(auction): checks = check_lots_awarding(auction) return min(checks) if checks else None
def next_check_awarding(auction): checks = [] if awarded_and_lots_predicate(auction): checks = check_lots_awarding(auction) return min(checks) if checks else None