def setUp(self): super(ReportsTestBase, self).setUp() self.user = factories.User() self.user2 = factories.User() self.superuser = factories.Superuser() self.devl_activity = factories.Activity(billable=True) self.activity = factories.Activity() self.sick = factories.Project() self.vacation = factories.Project() settings.EMS_PAID_LEAVE_PROJECTS = { 'sick': self.sick.pk, 'vacation': self.vacation.pk, } self.leave = [self.sick.pk, self.vacation.pk] self.p1 = factories.BillableProject(name='1') self.p2 = factories.NonbillableProject(name='2') self.p4 = factories.BillableProject(name='4') self.p3 = factories.NonbillableProject(name='1') self.p5 = factories.BillableProject(name='3') self.default_projects = [self.p1, self.p2, self.p3, self.p4, self.p5] self.default_dates = [ utils.add_timezone(datetime.datetime(2011, 1, 3)), utils.add_timezone(datetime.datetime(2011, 1, 4)), utils.add_timezone(datetime.datetime(2011, 1, 10)), utils.add_timezone(datetime.datetime(2011, 1, 16)), utils.add_timezone(datetime.datetime(2011, 1, 17)), utils.add_timezone(datetime.datetime(2011, 1, 18)), ]
def setUp(self): super(TestProjectTimesheet, self).setUp() self.user = factories.User() self.user2 = factories.User() self.superuser = factories.Superuser() self.p1 = factories.BillableProject(name='1') self.p2 = factories.NonbillableProject(name='2') self.p4 = factories.BillableProject(name='4') self.p3 = factories.NonbillableProject(name='1') self.url_args = (self.p1.pk, ) self.devl_activity = factories.Activity(billable=True) self.activity = factories.Activity()
def test_previous_invoice_list_search(self): def search(query): response = self.client.get(list_url, data={'search': query}) return response.context['object_list'] list_url = reverse('list_invoices') project3 = factories.BillableProject(name=':-D') self.log_many([project3], 10) self.create_invoice(project=project3, data={ 'status': EntryGroup.INVOICED, 'comments': 'comment!', 'number': '###', }) # Search comments, project name, and number. for query in ['comment!', ':-D', '###']: results = search(query) self.assertEqual(len(results), 1) self.assertEqual(results[0].project, project3) # Search in username results = search(self.user.username) self.assertEqual(len(results), 3) # all were created by this user # No results results = search("You won't find me here") self.assertEquals(len(results), 0)
def setUp(self): super(ListOutstandingInvoicesViewTestCase, self).setUp() self.user = factories.Superuser() self.login_user(self.user) start = utils.add_timezone(datetime.datetime(2011, 1, 1, 8)) end = utils.add_timezone(datetime.datetime(2011, 1, 1, 12)) self.project_billable = factories.BillableProject() self.project_billable2 = factories.BillableProject() self.project_non_billable = factories.NonbillableProject() self.entry1 = factories.Entry( user=self.user, project=self.project_billable, activity=factories.Activity(billable=True), start_time=start, end_time=end, status=Entry.APPROVED) self.entry2 = factories.Entry( user=self.user, project=self.project_billable, activity=factories.Activity(billable=True), start_time=start - relativedelta(days=5), end_time=end - relativedelta(days=5), status=Entry.APPROVED) self.entry3 = factories.Entry( user=self.user, project=self.project_billable2, activity=factories.Activity(billable=False), start_time=start - relativedelta(days=10), end_time=end - relativedelta(days=10), status=Entry.APPROVED) self.entry4 = factories.Entry(user=self.user, project=self.project_non_billable, start_time=start + relativedelta(hours=11), end_time=end + relativedelta(hours=15), status=Entry.APPROVED) # Default get kwargs. self.to_date = utils.add_timezone( datetime.datetime(2011, 1, 31, 0, 0, 0)) self.get_kwargs = { 'to_date': self.to_date.strftime(DATE_FORM_FORMAT), 'statuses': list(Attribute.statuses.values_list('pk', flat=True)), }
def setUp(self): self.user = factories.User() permissions = Permission.objects.filter( content_type=ContentType.objects.get_for_model(Entry), codename__in=('can_clock_in', 'can_clock_out', 'can_pause', 'change_entry')) self.user.user_permissions = permissions self.user.save() self.superuser = factories.Superuser() self.tracked_status = factories.StatusAttribute( label='Current', billable=True, enable_timetracking=True) self.untracked_status = factories.StatusAttribute( label='Closed', billable=False, enable_timetracking=False) self.tracked_type = factories.TypeAttribute( label='Tracked', billable=True, enable_timetracking=True) self.untracked_type = factories.TypeAttribute( label='Untracked', billable=False, enable_timetracking=False) self.work_activities = factories.ActivityGroup(name='Work') self.leave_activities = factories.ActivityGroup(name='Leave') self.all_activities = factories.ActivityGroup(name='All') self.leave_activity = factories.Activity( code='leave', name='Leave', billable=False) self.leave_activity.activity_group.add( self.leave_activities, self.all_activities) self.work_activity = factories.Activity( code='work', name='Work', billable=True) self.work_activity.activity_group.add( self.work_activities, self.all_activities) data = { 'type': self.tracked_type, 'status': self.tracked_status, 'activity_group': self.work_activities, } self.tracked_project = factories.BillableProject( name='Tracked', **data) data = { 'type': self.untracked_type, 'status': self.untracked_status, 'activity_group': self.all_activities, } self.untracked_project = factories.BillableProject( name='Untracked', **data)
def setUp(self): super(InvoiceViewPreviousTestCase, self).setUp() self.user = factories.Superuser() self.login_user(self.user) self.devl_activity = factories.Activity(code='devl', name='development', billable=True) self.activity = factories.Activity(code='WRK', name='Work') # Make some projects and entries for invoice creation self.project = factories.BillableProject() self.project2 = factories.BillableProject() last_start = self.log_many([self.project, self.project2]) # Add some non-billable entries self.log_many([self.project, self.project2], start=last_start, billable=False) self.create_invoice(self.project, {'static': EntryGroup.INVOICED}) self.create_invoice(self.project2, {'status': EntryGroup.NOT_INVOICED})
def setUp(self): super(InvoiceCreateTestCase, self).setUp() self.user = factories.Superuser() self.login_user(self.user) start = utils.add_timezone(datetime.datetime(2011, 1, 1, 8)) end = utils.add_timezone(datetime.datetime(2011, 1, 1, 12)) self.project_billable = factories.BillableProject() self.project_billable2 = factories.BillableProject() self.project_non_billable = factories.NonbillableProject() self.entry1 = factories.Entry( user=self.user, project=self.project_billable, activity=factories.Activity(billable=True), start_time=start, end_time=end, status=Entry.APPROVED) self.entry2 = factories.Entry( user=self.user, project=self.project_billable, activity=factories.Activity(billable=True), start_time=start - relativedelta(days=5), end_time=end - relativedelta(days=5), status=Entry.APPROVED) self.entry3 = factories.Entry( user=self.user, project=self.project_billable2, activity=factories.Activity(billable=False), start_time=start - relativedelta(days=10), end_time=end - relativedelta(days=10), status=Entry.APPROVED) self.entry4 = factories.Entry(user=self.user, project=self.project_non_billable, start_time=start + relativedelta(hours=11), end_time=end + relativedelta(hours=15), status=Entry.APPROVED)
def _setupMonthlyTotals(self): """ Helps set up environment for testing aspects of the monthly payroll summary. """ self.billable_project = factories.BillableProject() self.nonbillable_project = factories.NonbillableProject() self.all_logs(self.user, self.billable_project, self.nonbillable_project) self.all_logs(self.user2, self.billable_project, self.nonbillable_project) self.login_user(self.superuser) self.response = self.client.get(self.url, self.args) self.rows = self.response.context['monthly_totals'] self.labels = self.response.context['labels']