def test_ticket_totals(): start_date = date(day=3, month=2, year=2017) ticket = TicketFactory() """ This loop generates the following timerecords: Date Start Tm End Tm Delta Billable Invoice Line 2017-02-03 01:01:00 01:02:00 0:01:00 False None 2017-02-03 02:02:00 02:05:00 0:03:00 True None 2017-02-03 03:03:00 03:10:00 0:07:00 False None 2017-02-03 04:04:00 04:17:00 0:13:00 True None 2017-02-03 05:05:00 05:26:00 0:21:00 False None 2017-02-03 06:06:00 06:37:00 0:31:00 True 0 1.00 description_0 @0.00 2017-02-03 08:00:00 None 0:00:00 True None """ for t in range(1, 7): start_time = time(hour=t, minute=t) end_time = time(hour=t, minute=t*t+1) tr = TimeRecordFactory( ticket=ticket, date_started=start_date, start_time=start_time, end_time=end_time, billable=t % 2 == 0, ) # make the last time record invoiced tr.invoice_line = InvoiceLineFactory(timerecord=tr) tr.save() # open time record - should be ignored TimeRecordFactory( ticket=ticket, date_started=start_date, start_time=time(hour=8), end_time=None, billable=True, ) totals = ticket.totals() assert str(totals['total']) == '1:16:00' assert str(totals['not_billable']) == '0:29:00' assert str(totals['pending']) == '0:16:00' assert str(totals['billable']) == '0:47:00' assert str(totals['invoiced']) == '0:31:00'
def test_contact(): contact = ContactFactory() TicketFactory(contact=contact, due=date.today(), title='t1') TicketFactory(contact=contact, title='t2') TicketFactory(contact=contact, complete=timezone.now(), title='t3') TicketFactory(title='t4') qs = Ticket.objects.contact(contact) assert ['t3', 't2', 't1'] == [obj.title for obj in qs]
def test_report_time_by_ticket(): user = UserFactory(username='******') d = timezone.now().date() t1 = TicketFactory(pk=1, contact=ContactFactory()) TimeRecordFactory( ticket=t1, date_started=d, start_time=time(11, 0), end_time=time(11, 30), user=user, ) TimeRecordFactory( ticket=TicketFactory(pk=2, contact=ContactFactory()), date_started=d, start_time=time(10, 0), end_time=time(10, 15), user=user, ) # another date (so not included) TimeRecordFactory( ticket=t1, date_started=d + relativedelta(days=-1), start_time=time(12, 0), end_time=time(12, 10), user=UserFactory(), ) # another user (so not included) TimeRecordFactory( ticket=t1, date_started=d, start_time=time(12, 0), end_time=time(12, 10), user=UserFactory(), ) TimeRecordFactory( ticket=t1, date_started=d, start_time=time(12, 0), end_time=time(12, 10), user=user, ) data = TimeRecord.objects.report_time_by_ticket(user, d) assert { 1: { 'Chargeable': 40.0, 'Fixed-Price': 0, 'Non-Chargeable': 0 }, 2: { 'Chargeable': 15.0, 'Fixed-Price': 0, 'Non-Chargeable': 0 }, } == data
def test_ticket_timerecord_list(perm_check): ticket = TicketFactory() url = reverse( 'invoice.time.ticket.list', kwargs={'pk': ticket.pk} ) perm_check.staff(url)
def test_start_and_stop_too_many(): user = UserFactory() TimeRecordFactory(user=user, end_time=None) TimeRecordFactory(user=user, end_time=None) quick = QuickTimeRecordFactory(user=user) ticket = TicketFactory() with pytest.raises(InvoiceError) as e: TimeRecord.objects.start(ticket, quick) assert 'Cannot start a time record when 2 are already' in str(e.value)
def test_start(): user = UserFactory() quick = QuickTimeRecordFactory(user=user) ticket = TicketFactory() time_record = TimeRecord.objects.start(ticket, quick) assert quick.time_code == time_record.time_code assert ticket == time_record.ticket assert time_record.end_time is None assert time_record.start_time is not None assert quick.user == time_record.user
def test_invoice_create_pdf(self): InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) ticket = TicketFactory(contact=contact) TimeRecordFactory(ticket=ticket, date_started=date(2013, 12, 1)) invoice = InvoiceCreate().create(UserFactory(), contact, date(2013, 12, 31)) InvoicePrint().create_pdf(invoice, None)
def test_report_total_by_user(): contact = ContactFactory() invoice = InvoiceFactory(contact=contact) InvoiceSettingsFactory() # no time records InvoiceLineFactory(invoice=invoice) # u1's time records invoice_line = InvoiceLineFactory(invoice=invoice) t1 = TicketFactory(contact=contact) TimeRecordFactory(ticket=t1, user=UserFactory(username='******'), invoice_line=invoice_line) # u2's time records invoice_line = InvoiceLineFactory(invoice=invoice) u2 = UserFactory(username='******') t2 = TicketFactory(contact=contact) TimeRecordFactory(ticket=t2, user=u2, invoice_line=invoice_line) invoice_line = InvoiceLineFactory(invoice=invoice) t3 = TicketFactory(contact=contact) TimeRecordFactory(ticket=t3, user=u2, invoice_line=invoice_line) result = invoice.time_analysis() # invoice has a line with no time records assert '' in result # fred recorded time on one ticket assert 'u1' in result u1 = result['u1'] assert 1 == len(u1) assert t1.pk in u1 # sara recorded time on two tickets assert 'u2' in result u2 = result['u2'] assert 2 == len(u2) assert t2.pk in u2 assert t3.pk in u2 # web user added an invoice line, but didn't record time assert 'web' not in result # check net total matches invoice net = Decimal() for user, tickets in result.items(): for ticket_pk, totals in tickets.items(): net = net + totals['net'] assert invoice.net == net
def test_ticket_update(client): user = UserFactory(username='******', is_staff=True) assert client.login(username=user.username, password=TEST_PASSWORD) is True priority = PriorityFactory() ticket = TicketFactory() assert ticket.fixed_price is False url = reverse('crm.ticket.update', kwargs={'pk': ticket.pk}) data = { 'fixed_price': True, 'priority': priority.pk, 'title': 'Apple Juice', } response = client.post(url, data) assert 302 == response.status_code, response.context['form'].errors expect = reverse('crm.ticket.detail', args=[ticket.pk]) assert expect == response['Location'] ticket.refresh_from_db() assert ticket.fixed_price is True assert priority.pk == ticket.priority.pk assert 'Apple Juice' == ticket.title
def test_report_time_by_contact_user(): user = UserFactory() to_date = timezone.now() from_date = to_date + relativedelta(months=-1) d = from_date + relativedelta(days=7) bob = TicketFactory(contact=ContactFactory(slug='bob')) sam = TicketFactory(contact=ContactFactory(slug='sam')) # these time records are for a different user, so exclude them TimeRecordFactory( ticket=bob, billable=True, date_started=d, start_time=time(11, 0), end_time=time(11, 30), ) TimeRecordFactory( ticket=sam, billable=False, date_started=d, start_time=time(10, 0), end_time=time(10, 15), ) # include these time records TimeRecordFactory( ticket=bob, billable=True, date_started=d, start_time=time(11, 0), end_time=time(11, 30), user=user, ) TimeRecordFactory( ticket=sam, billable=False, date_started=d, start_time=time(10, 0), end_time=time(10, 15), user=user, ) data = TimeRecord.objects.report_time_by_contact(from_date, to_date, user) assert {'bob': 30, 'sam': 15} == data
def test_create_invoices_not_fixed_price(): InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) # ticket 1 t1 = TicketFactory(contact=contact) TimeRecordFactory(ticket=t1, title='t1', date_started=date(2012, 7, 1)) # ticket 2 is for fixed price work t2 = TicketFactory(contact=contact, fixed_price=True) TimeRecordFactory(ticket=t2, title='t2', date_started=date(2012, 7, 2)) # ticket 3 t3 = TicketFactory(contact=contact) TimeRecordFactory(ticket=t3, title='t3', date_started=date(2012, 7, 3)) # test InvoiceCreateBatch().create(UserFactory(), date(2012, 9, 30)) assert 1 == Invoice.objects.filter(contact=contact).count() invoice = Invoice.objects.get(contact=contact) assert ['t1', 't3'] == [ x.timerecord.title for x in InvoiceLine.objects.filter(invoice=invoice) ]
def test_report_time_by_contact(): to_date = timezone.now() from_date = to_date + relativedelta(months=-1) d = from_date + relativedelta(days=7) ticket = TicketFactory(contact=ContactFactory(slug='bob')) TimeRecordFactory( ticket=ticket, billable=True, date_started=d, start_time=time(11, 0), end_time=time(11, 30), ) ticket = TicketFactory(contact=ContactFactory(slug='sam')) TimeRecordFactory( ticket=ticket, billable=False, date_started=d, start_time=time(10, 0), end_time=time(10, 15), ) data = TimeRecord.objects.report_time_by_contact(from_date, to_date) assert {'bob': 30, 'sam': 15} == data
def test_create_invoices_do_not_bill_twice(): """Check we can't include the time records more than once""" InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) ticket = TicketFactory(contact=contact) TimeRecordFactory(ticket=ticket, date_started=date(2012, 7, 1)) user = UserFactory() InvoiceCreateBatch().create(user, date(2012, 9, 30)) assert 1 == Invoice.objects.filter(contact=contact).count() InvoiceCreateBatch().create(user, date(2012, 9, 30)) assert 1 == Invoice.objects.filter(contact=contact).count()
def test_api_ticket(api_client): user = UserFactory(first_name='Andrea', username='******') t1 = TicketFactory( contact=ContactFactory(company_name='', user=user), priority=PriorityFactory(name='Medium'), title='Mow the lawn', user_assigned=UserFactory(username='******'), ) user = UserFactory(first_name='Patrick', username='******') t2 = TicketFactory( contact=ContactFactory(company_name='', user=user), priority=PriorityFactory(name='High'), title='Make a cup of tea', user_assigned=UserFactory(username='******'), ) # get response = api_client.get(reverse('api.crm.ticket')) assert status.HTTP_200_OK == response.status_code assert [ { 'contact': 'andrea', 'due': None, 'id': t1.pk, 'priority': 'Medium', 'title': 'Mow the lawn', 'username': '******', }, { 'contact': 'patrick', 'due': None, 'id': t2.pk, 'priority': 'High', 'title': 'Make a cup of tea', 'username': '******', }, ] == response.data
def test_create_invoices_only_billable_time(): InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) ticket = TicketFactory(contact=contact) TimeRecordFactory(ticket=ticket, date_started=date(2012, 7, 1)) InvoiceCreateBatch().create(UserFactory(), date(2012, 9, 30)) TimeRecordFactory( ticket=ticket, date_started=date(2012, 7, 1), billable=False, ) InvoiceCreateBatch().create(UserFactory(), date(2012, 9, 30)) assert 1 == Invoice.objects.filter(contact=contact).count()
def test_invoice_download(perm_check): InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) ticket = TicketFactory(contact=contact) TimeRecordFactory(ticket=ticket, date_started=date(2013, 12, 1)) invoice = InvoiceCreate().create( UserFactory(), contact, date(2013, 12, 31) ) InvoicePrint().create_pdf(invoice, header_image=None) url = reverse('invoice.download', kwargs={'pk': invoice.pk}) perm_check.staff(url)
def test_start_and_stop(): user = UserFactory() running = TimeRecordFactory(user=user, end_time=None) assert running.end_time is None quick = QuickTimeRecordFactory(user=user) ticket = TicketFactory() time_record = TimeRecord.objects.start(ticket, quick) assert quick.time_code == time_record.time_code assert quick.description == time_record.title assert time_record.billable is False assert time_record.end_time is None assert time_record.start_time is not None assert user == time_record.user running.refresh_from_db() assert running.end_time == time_record.start_time
def test_invoice_with_time_records_no_end_time(): """One of the time records has no end time, so cannot be invoiced.""" InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) ticket = TicketFactory(contact=contact) tr1 = TimeRecordFactory(ticket=ticket) TimeRecordFactory(ticket=ticket, end_time=None) TimeRecordFactory(ticket=ticket) with pytest.raises(InvoiceError) as ex: InvoiceCreate().create(tr1.user, contact, date.today()) message = str(ex.value) assert 'does not have a' in message assert 'end time' in message
def test_invoice_with_time_records(): """Invoice time records.""" InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) ticket = TicketFactory(contact=contact) tr1 = TimeRecordFactory(ticket=ticket) TimeRecordFactory(ticket=ticket) invoice = InvoiceCreate().create( tr1.user, contact, date.today() ) assert invoice.is_draft InvoicePrint().create_pdf(invoice, None) assert not invoice.is_draft assert Decimal('40.00') == invoice.net
def test_create_invoices(): """Create an invoice""" InvoiceSettingsFactory() VatSettingsFactory() contact = ContactFactory() InvoiceContactFactory(contact=contact) ticket = TicketFactory(contact=contact) TimeRecordFactory(ticket=ticket, date_started=date(2012, 7, 1)) TimeRecordFactory(ticket=ticket, date_started=date(2012, 8, 1)) TimeRecordFactory(ticket=ticket) # action InvoiceCreateBatch().create(UserFactory(), date(2012, 9, 30)) invoices = Invoice.objects.filter(contact=contact) assert 1 == len(invoices) invoice = invoices[0] assert 2 == len(invoice.invoiceline_set.all())
def test_tickets(): """List of tickets where time was recorded for a user.""" user = UserFactory() today = date.today() # first day of the month from_date = today + relativedelta(day=1) # last day of the month to_date = today + relativedelta(months=+1, day=1, days=-1) # last month last_month = today + relativedelta(months=-1) # next month next_month = today + relativedelta(months=+1) TimeRecordFactory( ticket=TicketFactory(title='t0'), user=user, date_started=last_month, ) TimeRecordFactory( ticket=TicketFactory(title='t1'), user=user, date_started=from_date, ) TimeRecordFactory( ticket=TicketFactory(title='t2'), user=user, date_started=today, ) TimeRecordFactory( ticket=TicketFactory(title='t3'), date_started=to_date, ) TimeRecordFactory( ticket=TicketFactory(title='t4'), user=user, date_started=to_date, end_time=None, ) TimeRecordFactory( ticket=TicketFactory(title='t5'), user=user, date_started=to_date, ) TimeRecordFactory( ticket=TicketFactory(title='t6'), user=user, date_started=next_month, ) qs = TimeRecord.objects.tickets(from_date, to_date, user) assert ['t1', 't2', 't5'] == [x.title for x in qs]
def test_to_invoice(): contact = ContactFactory() d = date(2012, 7, 1) # TimeRecordFactory( title='t1', ticket=TicketFactory(contact=contact), date_started=d, ) # exclude records created after the invoice date TimeRecordFactory( title='t2', ticket=TicketFactory(contact=contact), date_started=date(2012, 8, 1), ) # exclude records for another contact TimeRecordFactory( title='t3', ticket=TicketFactory(contact=ContactFactory()), date_started=d, ) # exclude records which have already been invoiced TimeRecordFactory( title='t4', ticket=TicketFactory(contact=contact), date_started=d, invoice_line=InvoiceLineFactory(), ) # exclude records which have a fixed price ticket TimeRecordFactory( title='t5', ticket=TicketFactory(contact=contact, fixed_price=True), date_started=d, ) # TimeRecordFactory( title='t6', ticket=TicketFactory(contact=contact), date_started=d, ) qs = TimeRecord.objects.to_invoice(contact, date(2012, 7, 31)) assert ['t1', 't6'] == [x.title for x in qs]
def test_time_summary(): user = UserFactory(username='******', first_name='P', last_name='Kimber') d = date(2017, 4, 16) contact = ContactFactory( user=UserFactory(username='******', first_name='O', last_name='Rind')) t1 = TicketFactory(pk=1, contact=ContactFactory(user=user)) TimeRecordFactory( ticket=t1, date_started=d, start_time=time(11, 0), end_time=time(11, 30), user=user, ) contact = ContactFactory( user=UserFactory(username='******', first_name='A', last_name='Teal')) TimeRecordFactory( ticket=TicketFactory(pk=2, contact=contact), date_started=d, start_time=time(10, 0), end_time=time(10, 15), user=user, ) # another date (so not included) TimeRecordFactory( ticket=t1, date_started=d + relativedelta(days=-1), start_time=time(12, 0), end_time=time(12, 10), user=UserFactory(), ) # another user (so not included) TimeRecordFactory( ticket=t1, date_started=d, start_time=time(12, 0), end_time=time(12, 10), user=UserFactory(), ) TimeRecordFactory( ticket=t1, date_started=d, start_time=time(12, 0), end_time=time(12, 10), user=user, ) data = time_summary(user) assert { date(2017, 4, 16): { 'tickets': [{ 'analysis': { 'charge_minutes': 40.0, 'charge_minutes_format': '00:40', 'fixed_minutes': 0, 'fixed_minutes_format': '00:00', 'non_minutes': 0, 'non_minutes_format': '00:00' }, 'contact': 'P Kimber', 'description': '', 'pk': 1, 'user_name': 'green' }, { 'analysis': { 'charge_minutes': 15.0, 'charge_minutes_format': '00:15', 'fixed_minutes': 0, 'fixed_minutes_format': '00:00', 'non_minutes': 0, 'non_minutes_format': '00:00' }, 'contact': 'A Teal', 'description': '', 'pk': 2, 'user_name': 'blue' }], 'total': 55.0, 'total_format': '00:55', 'total_charge': 55.0, 'total_charge_format': '00:55', 'total_fixed': 0, 'total_fixed_format': '00:00', 'total_non': 0, 'total_non_format': '00:00', } } == data
def test_start_and_stop_billable(): quick = QuickTimeRecordFactory(chargeable=True) ticket = TicketFactory() time_record = TimeRecord.objects.start(ticket, quick) assert time_record.billable is True
def test_overdue(): ticket = TicketFactory(due=date(2010, 1, 1)) assert ticket.is_overdue
def test_search_methods(): check_search_methods(TicketFactory())
def test_str(): str(TicketFactory())
def test_ticket_update(perm_check): ticket = TicketFactory() url = reverse('crm.ticket.update', kwargs={'pk': ticket.pk}) perm_check.staff(url)
def test_time_summary_by_user(): user = UserFactory(username='******', first_name='P', last_name='Kimber') contact = ContactFactory(user=user) TimeRecordFactory( ticket=TicketFactory(contact=contact), date_started=date(2017, 1, 16), start_time=time(11, 0), end_time=time(11, 30), user=user, ) TimeRecordFactory( billable=False, ticket=TicketFactory(contact=contact), date_started=date(2016, 12, 1), start_time=time(11, 0), end_time=time(11, 15), user=user, ) TimeRecordFactory( ticket=TicketFactory(contact=contact, fixed_price=True), date_started=date(2016, 11, 30), start_time=time(11, 0), end_time=time(11, 10), user=user, ) assert 0 == ReportSchedule.objects.count() # test the task time_summary_by_user() assert 1 == ReportSchedule.objects.count() report_schedule = ReportSchedule.objects.first() reader = csv.reader(open(report_schedule.full_path), 'excel') first_row = None result = [] for row in reader: if not first_row: first_row = row else: # check the values in the last three columns (dates will change) result.append(row[4:]) print(row) assert [ 'user_name', 'year', 'month', 'label', 'non_minutes', 'fixed_minutes', 'charge_minutes', ] == first_row assert [ ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0'], ['0', '10', '0'], ['15', '0', '0'], ['0', '0', '30'], ['0', '0', '0'], ['0', '0', '0'], ] == result
def test_time_summary_by_user(): user = UserFactory(username='******', first_name='P', last_name='Kimber') contact = ContactFactory(user=user) TimeRecordFactory( ticket=TicketFactory(contact=contact), date_started=date(2017, 1, 16), start_time=time(11, 0), end_time=time(11, 30), user=user, ) TimeRecordFactory( billable=False, ticket=TicketFactory(contact=contact), date_started=date(2016, 12, 1), start_time=time(11, 0), end_time=time(11, 15), user=user, ) TimeRecordFactory( ticket=TicketFactory(contact=contact, fixed_price=True), date_started=date(2016, 11, 30), start_time=time(11, 0), end_time=time(11, 10), user=user, ) data = time_summary_by_user(date(2017, 3, 17)) assert { 'green': { '2015-03': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Mar', 'month': 3, 'non_minutes': 0, 'year': 2015, }, '2015-04': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Apr', 'month': 4, 'non_minutes': 0, 'year': 2015, }, '2015-05': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'May', 'month': 5, 'non_minutes': 0, 'year': 2015, }, '2015-06': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Jun', 'month': 6, 'non_minutes': 0, 'year': 2015, }, '2015-07': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Jul', 'month': 7, 'non_minutes': 0, 'year': 2015, }, '2015-08': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Aug', 'month': 8, 'non_minutes': 0, 'year': 2015, }, '2015-09': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Sep', 'month': 9, 'non_minutes': 0, 'year': 2015, }, '2015-10': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Oct', 'month': 10, 'non_minutes': 0, 'year': 2015, }, '2015-11': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Nov', 'month': 11, 'non_minutes': 0, 'year': 2015, }, '2015-12': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Dec', 'month': 12, 'non_minutes': 0, 'year': 2015, }, '2016-01': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Jan', 'month': 1, 'non_minutes': 0, 'year': 2016, }, '2016-02': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Feb', 'month': 2, 'non_minutes': 0, 'year': 2016, }, '2016-03': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Mar', 'month': 3, 'non_minutes': 0, 'year': 2016, }, '2016-04': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Apr', 'month': 4, 'non_minutes': 0, 'year': 2016, }, '2016-05': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'May', 'month': 5, 'non_minutes': 0, 'year': 2016, }, '2016-06': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Jun', 'month': 6, 'non_minutes': 0, 'year': 2016, }, '2016-07': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Jul', 'month': 7, 'non_minutes': 0, 'year': 2016, }, '2016-08': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Aug', 'month': 8, 'non_minutes': 0, 'year': 2016, }, '2016-09': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Sep', 'month': 9, 'non_minutes': 0, 'year': 2016, }, '2016-10': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Oct', 'month': 10, 'non_minutes': 0, 'year': 2016, }, '2016-11': { 'charge_minutes': 0, 'fixed_minutes': 10, 'label': 'Nov', 'month': 11, 'non_minutes': 0, 'year': 2016, }, '2016-12': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Dec', 'month': 12, 'non_minutes': 15, 'year': 2016, }, '2017-01': { 'charge_minutes': 30.0, 'fixed_minutes': 0, 'label': 'Jan', 'month': 1, 'non_minutes': 0, 'year': 2017, }, '2017-02': { 'charge_minutes': 0, 'fixed_minutes': 0, 'label': 'Feb', 'month': 2, 'non_minutes': 0, 'year': 2017, }, } } == data
def test_due(): ticket = TicketFactory(due=date.today()) assert not ticket.is_overdue