def test_rename_ticket(snapshot, ticket_app: TicketsApplication,
                       graphql_context: Context):
    client = Client(schema,
                    context=graphql_context,
                    format_error=raise_original_error)
    ticket = ticket_app.create_ticket(name="My ticket")

    create_ticket = """
        mutation ($id: ID!, $name: String!) {
            renameTicket(id: $id, name: $name) {
                ok
            }
        }
    """
    executed = client.execute(create_ticket,
                              variables={
                                  "id": str(ticket.id),
                                  "name": "testing ticket"
                              })

    assert executed["data"]["renameTicket"]["ok"]
    snapshot.assert_match(get_latest_ticket_as_dict(ticket_app, ticket))
def test_update_ticket_description(snapshot, ticket_app: TicketsApplication,
                                   graphql_context: Context):
    client = Client(schema,
                    context=graphql_context,
                    format_error=raise_original_error)
    ticket = ticket_app.create_ticket(name="My ticket")

    create_ticket = """
        mutation ($id: ID!, $description: String!) {
            updateTicketDescription(id: $id, description: $description) {
                ok
            }
        }
    """
    executed = client.execute(
        create_ticket,
        variables={
            "id": str(ticket.id),
            "description": "updated description"
        },
    )

    assert executed["data"]["updateTicketDescription"]["ok"]
    snapshot.assert_match(get_latest_ticket_as_dict(ticket_app, ticket))
def test_clone_ticket(snapshot, ticket_app: TicketsApplication,
                      graphql_context: Context):
    client = Client(schema,
                    context=graphql_context,
                    format_error=raise_original_error)
    original_ticket = ticket_app.create_ticket(name="My ticket")
    original_ticket_id = str(original_ticket.id)

    delete_ticket = """
        mutation ($id: ID!) {
            cloneTicket(id: $id) {
                ok
                ticket {
                    name
                    description
                    history {
                        __typename
                        timestamp
                        ... on TicketFieldUpdated {
                            field
                            oldValue
                            newValue
                        }
                        ... on TicketCloned {
                            originalTicketName
                        }
                    }
                }
            }
        }
    """
    executed = client.execute(delete_ticket,
                              variables={"id": original_ticket_id})

    assert executed["data"]["cloneTicket"]["ok"]
    snapshot.assert_match(executed)
示例#4
0
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
示例#5
0
def test_get_tickets_with_deleted_tickets(ticket_app: TicketsApplication):
    ticket = ticket_app.create_ticket()
    ticket_id = str(ticket.id)
    ticket_app.delete_ticket(ticket_id)

    assert ticket_app.get_tickets() == []
示例#6
0
def test_get_tickets_when_none_created(ticket_app: TicketsApplication):
    assert ticket_app.get_tickets() == []