Пример #1
0
def test_get_documents_query_with_contact_id(snapshot, request):
    """ Test get documents query with contact id """

    DocumentFactory.create_batch(size=4)
    contact = ContactFactory()
    staff_member = UserFactory(id=1)
    request.user = staff_member
    client = Client(schema, context=request)
    query = client.execute("""
        query getDocuments($contactId: ID!) {
            documents(first:3, contactId: $contactId) {
                edges{
                    node {
                        status
                        documentType {
                            name
                        }
                    }
                }
            }
        }
    """,
                           variable_values={
                               'contactId':
                               to_global_id('ContactType', contact.id),
                           })

    snapshot.assert_match(query)
Пример #2
0
def test_time_entrie_clients_name_filter_with_value_error(snapshot, request):
    """ Test time entries clients name filter with value error """

    client_instance = ClientFactory(organisation=None,
                                    contact=ContactFactory(first_name='name',
                                                           last_name='name'),
                                    second_contact=None)

    TimeEntryFactory.create_batch(size=5,
                                  client=client_instance,
                                  date='2017-10-20')

    staff_member = UserFactory(id=1)
    request.user = staff_member

    client = Client(schema, context=request)
    query = client.execute("""
          query timeEntries($clientName: String) {
            timeEntries(first: 3, clientName: $clientName) {
              totalPages
              edges {
                cursor
                node {
                  id
                  description
                  date
                  matter {
                    id
                    name
                  }
                  client {
                    id
                    name
                  }
                }
              }
              pageInfo {
                endCursor
                hasNextPage
              }
            }
          }
    """,
                           variable_values={
                               'clientName': 'name',
                           })
    snapshot.assert_match(query)
Пример #3
0
def test_invoices_number_or_client_name_filter_with_str(snapshot, request):
    """ Test invoices number or client name filter with string value"""

    client_instance = ClientFactory(organisation=None,
                                    contact=ContactFactory(first_name='first',
                                                           last_name='last'),
                                    second_contact=None)

    matter_instance = MatterFactory(client=client_instance, )

    InvoiceFactory(id=6735, matter=matter_instance)
    InvoiceFactory(id=7845, matter=matter_instance)
    InvoiceFactory(id=9965, matter=matter_instance)

    staff_member = UserFactory(id=1)
    request.user = staff_member

    client = Client(schema, context=request)
    query = client.execute("""
        query getInvoices($numberOrClientName: String) {
            invoices(first: 3, numberOrClientName: $numberOrClientName) {
                edges {
                    node {
                        id
                        matter{
                            id
                            name
                            client {
                                id
                                name
                            }
                        }
                    }
                }
            }
        }
    """,
                           variable_values={
                               'numberOrClientName': client_instance.name,
                           })
    snapshot.assert_match(query)
Пример #4
0
def test_matters_client_name_filter_with_not_full_client_name(
        snapshot, request):
    """ Test matters client name filter with contacts name """

    client_instance = ClientFactory(organisation=None,
                                    contact=ContactFactory(
                                        first_name='first',
                                        last_name='contact'),
                                    second_contact=None)

    MatterFactory.create_batch(
        size=5,
        client=client_instance,
    )

    staff_member = UserFactory(id=1)
    request.user = staff_member

    client = Client(schema, context=request)
    query = client.execute("""
        query getMatters($clientName: String) {
            matters(first: 3, clientName: $clientName) {
                edges {
                    node {
                        id
                        name
                        client {
                            id
                            name
                        }
                        billableStatus
                    }
                }
            }
        }
    """,
                           variable_values={
                               'clientName': client_instance.name,
                           })
    snapshot.assert_match(query)