def test_new_entities2(snapshot, request): """ Test success new entities """ ClientFactory.create_batch(size=2) client = Client(schema) executed = client.execute(""" query newEntities { newEntities { id date count } } """) snapshot.assert_match(executed)
def test_invoices_query(snapshot, request): """ Test invoices query""" client_instance = ClientFactory() matter_instance = MatterFactory(client=client_instance, ) InvoiceFactory(id=1231, matter=matter_instance) InvoiceFactory(id=4322, matter=matter_instance) InvoiceFactory(id=3233, matter=matter_instance) staff_member = UserFactory(id=1) request.user = staff_member client = Client(schema, context=request) query = client.execute(""" query getInvoices { invoices(first: 3) { edges { node { statusDisplay valueExGst valueInclGst receivedPayments netOutstanding history totalBilledValue isPaid dueDate number friendlyReminder firstReminder secondReminder timeEntries{ edges{ node{ description } } } billingMethod timeEntryValue fixedPriceValue canSendXero isInXero } } } } """) snapshot.assert_match(query)
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)
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)
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)
def test_client_value_reports(snapshot, request): """ Test success client value reports """ clients = ClientFactory.create_batch(size=3, created_date='2015-11-20') from_date = '2015-05-20' to_date = '2018-02-20' client = Client(schema) executed = client.execute( """ query clientValueReports( $clients:[ID], $fromDate:String, $toDate:String ) { clientValueReports( clients:$clients, fromDate:$fromDate, toDate:$toDate ) { id name value } } """, variable_values={ 'clients': [ to_global_id('ClientType', client_instance.id) for client_instance in clients ], 'fromDate': from_date, 'toDate': to_date, }, ) snapshot.assert_match(executed)