コード例 #1
0
ファイル: agent_exporter.py プロジェクト: brandizzi/netunong
    def test_export_two_wps(self): 
        emp, task, start, end = self.get_depencencies()

        wp1 = WorkingPeriod(employee=emp,
            intended="Write a function for creating better descriptions",
            intended_task=task,
            executed="Created function to describe exported WP",
            executed_task=task,
            start= start, end=end)
        wp1.save()

        delta = timedelta(1)
        tomorrow_start=start+delta
        tomorrow_end=end+delta
        wp2 = WorkingPeriod(employee=emp,
            intended="Export stuff",
            intended_task=task,
            executed="Exporting WPs to old netuno",
            executed_task=task,
            start=tomorrow_start, end=tomorrow_end)
        wp2.save()



        exporter = agents.Exporter()
        exporter.export_logs([wp1, wp2], ROOT_URL, 'adam', 'senha')
        
        content = self.get_list_of_submitted_logs()
        self.assertTrue(('Task id: 2376') in content)
        self.assertTrue('Log creator: 1' in content)
        self.assertTrue(('Date: %s' % start.strftime("%Y%m%d")) in content)
        self.assertTrue('Worked hours: %s' % wp1.total_time in content)
        self.assertTrue('Description: %s' % get_exported_description(wp1) in content)     
        self.assertTrue(('Task id: 2376') in content)
        self.assertTrue('Log creator: 1' in content)
        self.assertTrue(('Date: %s' % tomorrow_start.strftime("%Y%m%d")) in content)
        self.assertTrue('Worked hours: %s' % wp2.total_time in content)
        self.assertTrue('Description: %s' % get_exported_description(wp2) in content)    
コード例 #2
0
ファイル: agent.py プロジェクト: brandizzi/netunong
 def export_logs(self, wps, url, username, password):
     crawler = NetunoCrawler(url)
     if not crawler.logged_in:
         crawler.login(username, password)
     exportables = (wp 
             for wp in wps 
             if not ExportedLog.is_exported(wp)
                 and wp.is_complete())
     for wp in exportables:
         task_id = wp.executed_task.id
         entity = ImportedEntity.objects.get(category='T', new_id=task_id)
         original_task_id  = entity.original_id
         crawler.go_to_task_log_registration(original_task_id)
         crawler.register_log(wp.end, wp.total_time, get_exported_description(wp))
         log = ExportedLog(working_period=wp)
         log.save()
コード例 #3
0
    def test_get_something(self):
        org, _, task = get_organization_project_task()
        emp = get_employee(org)
        start = datetime(2011, 12, 31, 8, 0)
        end = datetime(2011, 12, 31, 12, 0)
        wp = WorkingPeriod(
            employee=emp,
            intended="Write a function for creating better descriptions",
            intended_task=task,
            executed="Created function to describe exported WP",
            executed_task=task,
            start=start,
            end=end)

        self.assertEqual(
            "%s - %s: Created function to describe exported WP" % (
                start.strftime(settings.NETUNONG_TIME_FORMAT),
                end.strftime(settings.NETUNONG_TIME_FORMAT),
            ), parser.get_exported_description(wp))
コード例 #4
0
ファイル: agent_exporter.py プロジェクト: brandizzi/netunong
    def test_export(self): 
        emp, task, start, end = self.get_depencencies()

        wp = WorkingPeriod(employee=emp,
            intended="Write a function for creating better descriptions",
            intended_task=task,
            executed="Created function to describe exported WP",
            executed_task=task,
            start= start, end=end)
        wp.save()

        exporter = agents.Exporter()
        exporter.export_logs([wp], ROOT_URL, 'adam', 'senha')
        
        content = self.get_list_of_submitted_logs()
        self.assertTrue(('Task id: 2376') in content)
        self.assertTrue('Log creator: 1' in content)
        self.assertTrue(('Date: %s' % start.strftime("%Y%m%d")) in content)
        self.assertTrue('Worked hours: %s' % wp.total_time in content)
        self.assertTrue('Description: %s' % get_exported_description(wp) in content)
コード例 #5
0
ファイル: agent_exporter.py プロジェクト: brandizzi/netunong
    def test_does_not_export_incomplete(self): 
        emp, task, start, end = self.get_depencencies()

        wp1 = WorkingPeriod(employee=emp,
            intended="Write a function for creating better descriptions",
            intended_task=task,
            executed="Created function to describe exported WP",
            executed_task=task,
            start= start, end=end)
        wp1.save()

        wp2 = WorkingPeriod(employee=emp,
            intended="Export stuff",
            intended_task=task,
            executed="Exporting WPs to old netuno",
            executed_task=task,
            start=start) # No end
        wp2.save()

        wp3 = WorkingPeriod(employee=emp,
            intended="Thinking about future",
            intended_task=task,
            #executed="Exporting WPs to old netuno", # No final message
            executed_task=task,
            start=start, end=end)
        wp3.save()

        wp4 = WorkingPeriod(employee=emp,
            intended="PLanning how to spend money",
            intended_task=task,
            executed="Exporting WPs to old netuno",
            # executed_task=task, # No updated task
            start=start, end=end)
        wp4.save()

        wp5 = WorkingPeriod(employee=emp,
            intended="Write a function for creating better descriptions",
            intended_task=task,
            executed="Closing WP",
            executed_task=task,
            start= start, end=end)
        wp5.save()

        exporter = agents.Exporter()
        exporter.export_logs([wp1, wp2, wp3, wp4, wp5], ROOT_URL, 'adam', 'senha')
        
        content = self.get_list_of_submitted_logs()
        self.assertTrue(('Task id: 2376') in content)
        self.assertTrue('Log creator: 1' in content)
        self.assertTrue(('Date: %s' % start.strftime("%Y%m%d")) in content)
        self.assertTrue('Worked hours: %s' % wp1.total_time in content)

        self.assertTrue('Description: %s' % get_exported_description(wp1) in content)     
        self.assertFalse('Description: %s' % get_exported_description(wp2) in content)     
        self.assertFalse('Description: %s' % get_exported_description(wp3) in content)     
        self.assertFalse('Description: %s' % get_exported_description(wp4) in content)     
        self.assertTrue('Description: %s' % get_exported_description(wp5) in content)     

        self.assertTrue(ExportedLog.is_exported(wp1))
        self.assertFalse(ExportedLog.is_exported(wp2))
        self.assertFalse(ExportedLog.is_exported(wp3))
        self.assertFalse(ExportedLog.is_exported(wp4))
        self.assertTrue(ExportedLog.is_exported(wp5))