Exemplo n.º 1
0
def test_get_tickets_with_multiple_commands(ticket_app: TicketsApplication):
    with freeze_time("2012-01-14"):
        ticket = ticket_app.create_ticket(name="original name")
        ticket_id = str(ticket.id)
    with freeze_time("2012-01-15"):
        ticket_app.rename_ticket(ticket_id, "new ticket name")
        ticket_app.update_ticket_description(ticket_id,
                                             "new ticket description")

    assert tickets_as_assertable_tickets(ticket_app.get_tickets()) == [
        AssertableTicket(
            id=any_instance_of(str),
            name="new ticket name",
            description="new ticket description",
            updated_at="2012-01-15T00:00:00",
            history=[
                TicketFieldUpdated(
                    field="name",
                    old_value="original name",
                    new_value="new ticket name",
                    timestamp=datetime(year=2012, month=1, day=15),
                ),
                TicketFieldUpdated(
                    field="description",
                    old_value=None,
                    new_value="new ticket description",
                    timestamp=datetime(year=2012, month=1, day=15),
                ),
            ],
        )
    ]
Exemplo n.º 2
0
def test_get_ticket(snapshot, ticket_app: TicketsApplication,
                    graphql_context: Context):
    ticket = ticket_app.create_ticket(name="My ticket",
                                      description="My ticket description")
    ticket_app.rename_ticket(str(ticket.id), "Ticket renamed")
    ticket_app.update_ticket_description(str(ticket.id),
                                         "New ticket description")
    client = Client(schema,
                    context=graphql_context,
                    format_error=raise_original_error)
    get_ticket = """
        query ($id: ID!) {
            ticket(id: $id) {
                name
                description
                updatedAt
                history {
                    __typename
                    timestamp
                    ... on TicketFieldUpdated {
                        field
                        oldValue
                        newValue
                    }
                    ... on TicketCloned {
                        originalTicketId
                        originalTicketName
                    }
                }
            }
        }
    """

    executed = client.execute(get_ticket, variables={"id": str(ticket.id)})
    snapshot.assert_match(executed)
Exemplo n.º 3
0
def test_update_description_ticket(ticket_app: TicketsApplication):
    ticket = ticket_app.create_ticket()
    ticket_id = str(ticket.id)
    ticket_app.update_ticket_description(id=ticket_id,
                                         description="New description")

    saved = ticket_app.repository[ticket_id]
    assert AssertableTicket.from_model(saved) == AssertableTicket(
        id=any_instance_of(str),
        name=None,
        description="New description",
        updated_at=any_instance_of(str),
        history=[
            TicketFieldUpdated(
                field="description",
                old_value=None,
                new_value="New description",
                timestamp=any_instance_of(datetime),
            )
        ],
    )
Exemplo n.º 4
0
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)