def test_clone_ticket_are_not_impacted_by_changes_to_the_original( ticket_app: TicketsApplication): original_ticket = ticket_app.create_ticket( name="Original ticket name", description="Original ticket description") original_ticket_id = str(original_ticket.id) new_ticket = ticket_app.clone_ticket(id=original_ticket_id) new_ticket_id = str(new_ticket.id) ticket_app.rename_ticket(id=original_ticket_id, name="New ticket name") new_ticket_reloaded = ticket_app.get_ticket(new_ticket_id) assert original_ticket_id != str(new_ticket.id) assert AssertableTicket.from_model( new_ticket_reloaded) == AssertableTicket( id=any_instance_of(str), name="CLONED - Original ticket name", description="Original ticket description", updated_at=any_instance_of(str), history=[ TicketCloned( original_ticket_id=original_ticket_id, original_ticket_name="Original ticket name", timestamp=any_instance_of(datetime), ) ], )
def get_latest_ticket_as_dict(tickets_apps: TicketsApplication, ticket: Ticket): latest_ticket = tickets_apps.get_ticket(str(ticket.id)) if latest_ticket is None: return None return { "name": latest_ticket.name, "description": latest_ticket.description }
def test_delete_ticket(ticket_app: TicketsApplication): ticket = ticket_app.create_ticket() ticket_id = str(ticket.id) ticket_app.delete_ticket(ticket_id) assert ticket_app.get_ticket(ticket_id) is None