def setUp(self): """ testdata is created and an employee is set up for the first test """ self.create_test_data() self.employee = Employee.select().get()
def test_search_query_by_employee(self): employee = Employee.select().get() tasks = LogEntry.select().where(LogEntry.employee_id == employee.id) self.dialog.search_parameters = SearchParameters( employee_id=employee.id) self.dialog.query_by_employee() self.assertEqual(tasks, self.dialog.logentry_queryset)
def setUp(self): """ the list is set up """ self.create_test_data() self.dialog = SearchDialog() self.dialog.active_choice_index = 1 employee_list = list(Employee.select()) self.employee = employee_list[1] self.dialog.choice_list = ChoiceList(list=employee_list)
def setUp(self): """ Szenario: temporary logentry has been build. the user can now decide what to do with it. """ self.create_test_data() self.dialog = CreateDialog() employee = Employee.select().get() self.dialog.logentry_tmp = { 'task': "some exotic task", 'time_spent': 20, 'note': "some note", 'employee': employee, }
def setUp(self): """ Szenario: temporary logentry has been build. the user can now decide what to do with it. """ self.create_test_data() self.logentry = LogEntry.select().get() data = {'logentry': self.logentry} self.dialog = UpdateDialog(**data) self.employee = Employee.select().get() self.dialog.logentry_tmp = { 'task': "some exotic task", 'time_spent': 20, 'note': "some note", 'employee': self.employee, } self.print_stack = ['some item'] self.print_logentries = _print_logentry_tmp(self.dialog.logentry_tmp, self.logentry)
def test_helpers__print_logentry_tmp_filled(self): """ print in case of create the filled out form """ with test_database(test_db, (Employee, LogEntry)): self.create_test_data() employee = Employee.select().get() logentry_tmp = { 'employee': employee, 'task': 'some task', 'time_spent': 30, 'note': 'some note', } printstring = _print_logentry_tmp(logentry_tmp=logentry_tmp, logentry=None) self.assertEqual(printstring, (("{0:<20s} {1}\n{2:<20s} {3}\n" "{4:<20s} {5} min\n{6}\n{7}").format( 'Employee:', employee, 'Task:', 'some task', 'Time spent:', 30, 'Note:', 'some note')))
def test_helpers__print_logentry_tmp_for_update(self): """ print in case of update: fields are taken from tmps and if they are not filled, from the database record """ with test_database(test_db, (Employee, LogEntry)): self.create_test_data() employee = Employee.select().get() logentry = LogEntry.select().get() logentry_tmp = { 'employee': employee, 'time_spent': 45, } printstring = _print_logentry_tmp(logentry_tmp=logentry_tmp, logentry=logentry) self.assertEqual( printstring, (("{0:<20s} {1}\n{2:<20s} {3}\n" "{4:<20s} {5} min\n{6}\n{7}").format( 'Employee:', employee, 'Task:', logentry.task, 'Time spent:', 45, 'Note:', logentry.note)))
def create_test_data(self): """ ... create a bunch of employees""" employees = [ {'first_name': 'Kenneth', 'last_name': 'Love'}, {'first_name': 'Sabine', 'last_name': 'Maennel'}, {'first_name': 'Sabine', 'last_name': 'Konecny'}, ] task_set_m = [ {'task': 'Cleaning', 'time_spent': 15, 'note': 'fun', 'logdate': datetime.date(2016, 8, 29), }, {'task': 'Baking', 'time_spent': 23, 'note': 'hard', 'logdate': datetime.date(2015, 8, 29), }, {'task': 'Cooking', 'time_spent': 45, 'note': 'my best dinner ever', 'logdate': datetime.date(2016, 8, 30), }, ] task_set_l = [ {'task': 'Testing', 'time_spent': 15, 'note': 'hard stuff', 'logdate': datetime.date(2016, 8, 29), }, {'task': 'Programming Python', 'time_spent': 30, 'note': 'was fun', 'logdate': datetime.date(2015, 9, 29), }, {'task': 'Learning Javascript', 'time_spent': 30, 'note': 'difficult', 'logdate': datetime.date(2016, 9, 29), }, ] task_set_k = [ {'task': 'Gardening', 'time_spent': 15, 'note': 'the rain is helping', 'logdate': datetime.date(2016, 8, 30), }, {'task': 'Building a chincilla cage', 'time_spent': 200, 'note': 'need more wood', 'logdate': datetime.date(2015, 8, 29), }, {'task': 'Jogging', 'time_spent': 15, 'note': 'my usual round', 'logdate': datetime.date(2016, 8, 29), }, ] task_sets = {'Maennel': task_set_m, 'Konecny': task_set_k, 'Love': task_set_l} self.employee_list = [] self.task_list = [] for employee_record in employees: employee, created = Employee.get_or_create( first_name=employee_record['first_name'], last_name=employee_record['last_name'] ) self.employee_list.append(employee) for task in task_sets[employee.last_name]: logentry, created = LogEntry.get_or_create( task=task['task'], time_spent=task['time_spent'], note=task['note'], employee=employee.id, logdate=task['logdate'] ) self.task_list.append(logentry)