def test_the_stock_is_not_soft_deleted(self): # when with pytest.raises(TooLateToDeleteError): delete_stock_and_cancel_bookings(self.stock) # then assert not self.stock.isSoftDeleted
def test_all_bookings_are_cancelled(self): # given self.stock.bookings = [ create_booking(user1, is_used=False, is_cancelled=False), create_booking(user2, is_used=False, is_cancelled=False), ] # when bookings = delete_stock_and_cancel_bookings(self.stock) # then assert all(map(lambda b: b.isCancelled, bookings))
def test_all_bookings_are_not_cancelled(self): # given self.stock.bookings = [ create_booking(user1, is_used=False, is_cancelled=False), create_booking(user2, is_used=False, is_cancelled=False), ] # when with pytest.raises(TooLateToDeleteError): bookings = delete_stock_and_cancel_bookings(self.stock) # then assert all(map(lambda b: not b.isCancelled, bookings))
def test_used_bookings_are_not_cancelled(self): # given self.stock.bookings = [ create_booking(user1, is_used=True, is_cancelled=False), create_booking(user2, is_used=False, is_cancelled=False) ] # when bookings = delete_stock_and_cancel_bookings(self.stock) # then used_bookings = filter(lambda b: b.isUsed, bookings) assert all(map(lambda b: not b.isCancelled, used_bookings))
def delete_stock(id): stock = load_or_404(Stock, id) check_offer_is_editable(stock.offer) offerer_id = stock.resolvedOffer.venue.managingOffererId ensure_current_user_has_rights(RightsType.editor, offerer_id) bookings = delete_stock_and_cancel_bookings(stock) if bookings: try: send_batch_cancellation_emails_to_users(bookings, send_raw_email) send_batch_cancellation_email_to_offerer(bookings, 'stock', send_raw_email) except MailServiceException as e: app.logger.error('Mail service failure', e) PcObject.save(stock, *bookings) return jsonify(as_dict(stock)), 200
def test_the_stock_is_soft_deleted(self): # when delete_stock_and_cancel_bookings(self.stock) # then assert self.stock.isSoftDeleted