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 test_clone_ticket(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) assert original_ticket_id != new_ticket_id assert AssertableTicket.from_model(new_ticket) == 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 test_get_cloned_ticket(snapshot, ticket_app: TicketsApplication, graphql_context: Context): original_ticket = ticket_app.create_ticket( name="My ticket", description="My ticket description") original_ticket_id = str(original_ticket.id) ticket_app.rename_ticket(original_ticket_id, "Original ticket name") ticket_app.update_ticket_description(original_ticket_id, "Original ticket description") new_ticket = ticket_app.clone_ticket(id=original_ticket_id) new_ticket_id = str(new_ticket.id) ticket_app.rename_ticket(id=new_ticket_id, name="New ticket name") client = Client(schema, context=graphql_context, format_error=raise_original_error) get_ticket = """ query ($id: ID!) { ticket(id: $id) { name description updatedAt history { __typename ... on TicketFieldUpdated { field oldValue newValue } ... on TicketCloned { originalTicketName } } } } """ executed = client.execute(get_ticket, variables={"id": new_ticket_id}) snapshot.assert_match(executed)