Exemplo n.º 1
0
 def test_assign_projects_from_ticket_filter(self):
     project = ProjectFactory.create()
     tickets = MaximoTicket.objects.all()[:5]
     for ticket in tickets:
         ticket.project = project
         ticket.save()
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     updated = MaximoTimeRegister.objects.filter(date__range=(date(2015, 9, 1), date(2015, 9, 15))).assign_projects_from_ticket()
     self.assertEqual(154, updated)
     registers = MaximoTimeRegister.objects.filter(project__isnull=False)
     self.assertEqual(79, len(registers))
Exemplo n.º 2
0
 def test_assign_projects_from_ticket(self):
     project = ProjectFactory.create()
     tickets = MaximoTicket.objects.all()[:5]
     for ticket in tickets:
         ticket.project = project
         ticket.save()
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     updated = MaximoTimeRegister.objects.assign_projects_from_ticket()
     self.assertEqual(294, updated)
     registers = MaximoTimeRegister.objects.filter(project__isnull=False)
     self.assertEqual(149, len(registers))
Exemplo n.º 3
0
 def test_export_time(self):
     '''
     Verifies the export for MaximoTimeRegister objects to an excel sheet. That contains the following columns:
     Company Id	Username	Date	Hours	Pay Rate	Ticket Type	Ticket Number	Ticket Name	Memo	Project	Project Source
     :return:
     '''
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     out = StringIO()
     filename = os.path.join(TEST_OUTPUT_PATH, '%s_%s.xlsx' % ('test_export_time', timezone.now().strftime('%Y%m%d_%H%M')))
     call_command('maximo_data', filename, export_time=True)
     self.assertTrue(os.path.exists(filename))
     row_data, row_count = TestExcel.get_list_from_workbook(filename, 'Time')
     self.assertEqual(row_count, MaximoTimeRegister.objects.count())
     self.assertEqual(11, len(row_data[0]))
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
Exemplo n.º 4
0
 def test_sum_hours(self):
     project = ProjectFactory.create()
     tickets = MaximoTicket.objects.all()[:5]
     for ticket in tickets:
         ticket.project = project
         ticket.save()
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 3))
     updated = MaximoTimeRegister.objects.assign_projects_from_ticket()
     #self.assertEqual(294, updated)
     total_hours = Decimal(0.0)
     for tr in MaximoTimeRegister.objects.filter(project=project):
         total_hours += tr.regular_hours
     project_with_hours2 = Project.objects.filter(pk=project.pk).sum_regular_hours()[0]
     project_with_hours = Project.objects.filter(pk=project.pk).sum_regular_hours()[0]
     self.assertEqual(total_hours, project_with_hours.total_regular_hours)
     self.assertEqual(120.0, project_with_hours.total_regular_hours)
Exemplo n.º 5
0
 def test_export_employees(self):
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     content = StringIO()
     #filename = os.path.join(TEST_OUTPUT_PATH, filename_with_datetime('test_')
     call_command('export_employees', 'TINO-NS', stdout=content)
     content.seek(0)
     lines = content.readlines()
     filename = None
     for line in lines:
         regexp = r'^File\sexport\s([\w,\-,\\,:]+)(\.xlsx)'
         pattern  = re.compile(regexp)
         match = pattern.match(line)
         if match:
             filename =  match.group(1) + match.group(2)
             #print(filename)
         #print(line)
     self.assertTrue(os.path.exists(filename))
Exemplo n.º 6
0
 def test_export_employees(self):
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     content = StringIO()
     #filename = os.path.join(TEST_OUTPUT_PATH, filename_with_datetime('test_')
     call_command('export_employees', 'TINO-NS', stdout=content)
     content.seek(0)
     lines = content.readlines()
     filename = None
     for line in lines:
         regexp = r'^File\sexport\s([\w,\-,\\,:]+)(\.xlsx)'
         pattern = re.compile(regexp)
         match = pattern.match(line)
         if match:
             filename = match.group(1) + match.group(2)
             #print(filename)
         #print(line)
     self.assertTrue(os.path.exists(filename))
Exemplo n.º 7
0
 def test_sum_hours(self):
     project = ProjectFactory.create()
     tickets = MaximoTicket.objects.all()[:5]
     for ticket in tickets:
         ticket.project = project
         ticket.save()
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 3))
     updated = MaximoTimeRegister.objects.assign_projects_from_ticket()
     #self.assertEqual(294, updated)
     total_hours = Decimal(0.0)
     for tr in MaximoTimeRegister.objects.filter(project=project):
         total_hours += tr.regular_hours
     project_with_hours2 = Project.objects.filter(
         pk=project.pk).sum_regular_hours()[0]
     project_with_hours = Project.objects.filter(
         pk=project.pk).sum_regular_hours()[0]
     self.assertEqual(total_hours, project_with_hours.total_regular_hours)
     self.assertEqual(120.0, project_with_hours.total_regular_hours)
Exemplo n.º 8
0
 def test_export_time(self):
     '''
     Verifies the export for MaximoTimeRegister objects to an excel sheet. That contains the following columns:
     Company Id	Username	Date	Hours	Pay Rate	Ticket Type	Ticket Number	Ticket Name	Memo	Project	Project Source
     :return:
     '''
     TestExcel.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     out = StringIO()
     filename = os.path.join(
         TEST_OUTPUT_PATH, '%s_%s.xlsx' %
         ('test_export_time', timezone.now().strftime('%Y%m%d_%H%M')))
     call_command('maximo_data', filename, export_time=True)
     self.assertTrue(os.path.exists(filename))
     row_data, row_count = TestExcel.get_list_from_workbook(
         filename, 'Time')
     self.assertEqual(row_count, MaximoTimeRegister.objects.count())
     self.assertEqual(11, len(row_data[0]))
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))