当前位置: 首页>>代码示例>>Python>>正文


Python models.Job类代码示例

本文整理汇总了Python中job.models.Job的典型用法代码示例。如果您正苦于以下问题:Python Job类的具体用法?Python Job怎么用?Python Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Job类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_increase_max_tries_canceled

    def test_increase_max_tries_canceled(self):
        '''Tests increasing the maximum number of tries for a job instance that was canceled prematurely.'''
        job_type = JobType(max_tries=10)
        job = Job(job_type=job_type, num_exes=3, max_tries=5)
        job.increase_max_tries()

        self.assertEqual(job.max_tries, 13)
开发者ID:cshamis,项目名称:scale,代码行数:7,代码来源:test_models.py

示例2: test_increase_max_tries_failed

    def test_increase_max_tries_failed(self):
        '''Tests increasing the maximum number of tries for a job instance that ran out of tries due to failures.'''
        job_type = JobType(max_tries=10)
        job = Job(job_type=job_type, num_exes=5, max_tries=5)
        job.increase_max_tries()

        self.assertEqual(job.max_tries, 15)
开发者ID:cshamis,项目名称:scale,代码行数:7,代码来源:test_models.py

示例3: test_get_shift_slots_remaining

    def test_get_shift_slots_remaining(self):
        """ Test get_shift_slots_remaining(s_id) """

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-12-10", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-6-25", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-1-9", start_time="12:00", end_time="6:00", max_volunteers=4, job=j1)

        s1.save()
        s2.save()
        s3.save()

        self.assertIsNotNone(get_shift_slots_remaining(s1.id))
        self.assertIsNotNone(get_shift_slots_remaining(s2.id))
        self.assertIsNotNone(get_shift_slots_remaining(s3.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:30,代码来源:tests.py

示例4: test_increment_slots_remaining

    def test_increment_slots_remaining(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")

        j1.save()

        s1 = Shift(date = "2012-10-23",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 0,
                    job = j1)

        s1.save()

        self.assertEqual(s1.slots_remaining, 0)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 1)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 2)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 3)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 4)
开发者ID:yaseppochi,项目名称:vms,代码行数:32,代码来源:tests.py

示例5: create

def create(request, project_id):
    project = get_object_or_404(
        Project,
        id=project_id,
        is_active=True,
        author=request.user
    )
    if request.method == 'POST':
        form = JobForm(request.POST)
        if form.is_valid():
            job = Job(
                project=project,
                title=form.cleaned_data['title'],
                area=form.cleaned_data['area'],
                description=form.cleaned_data['description']
            )
            job.save()
            return redirect(
                request,
                'project-read',
                [project.id],
                {request.url_name: 'True'}
            )
    else:
        form = JobForm()
    params = {'project': project, 'form': form}
    params.update(csrf(request))
    return response(request, params)
开发者ID:rodrigoalveslima,项目名称:runn,代码行数:28,代码来源:views.py

示例6: wm_import_job

 def wm_import_job(self):
   for job in Job.objects.all():
     job.delete()
   wm_jobs = WorkflowmaxJob.objects.all(datetime.now() - timedelta(days=365), datetime.now() + timedelta(days=365))
   for wm_job in wm_jobs:
     job = Job()
     job.wm_import(wm_job)
开发者ID:pombredanne,项目名称:xscheduling,代码行数:7,代码来源:wm_import.py

示例7: test_get_jobs_ordered_by_title

    def test_get_jobs_ordered_by_title(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")

        j2 = Job(job_title = "Systems Administrator",
                start_date = "2012-9-1",
                end_date = "2012-10-26",
                description = "A systems administrator job")

        j3 = Job(job_title = "Project Manager",
                start_date = "2012-1-2",
                end_date = "2012-2-2",
                description = "A management job")

        j1.save()
        j2.save()
        j3.save()       
                    
        #test typical case
        job_list = get_jobs_ordered_by_title()
        self.assertIsNotNone(job_list)
        self.assertNotEqual(job_list, False)
        self.assertEqual(len(job_list), 3)
        self.assertIn(j1, job_list)
        self.assertIn(j2, job_list)
        self.assertIn(j3, job_list)

        #test order
        self.assertEqual(job_list[0].job_title, j3.job_title)
        self.assertEqual(job_list[1].job_title, j1.job_title)
        self.assertEqual(job_list[2].job_title, j2.job_title)
开发者ID:Nerdylicious,项目名称:vms-pre-integration,代码行数:34,代码来源:tests.py

示例8: get_shifts_ordered_by_date

    def get_shifts_ordered_by_date(self):

        e1 = Event(name = "Open Source Event",
                start_date = "2012-10-22",
                end_date = "2012-10-23")

        e1.save()

        j1 = Job(name = "Software Developer",
            start_date = "2012-10-22",
            end_date = "2012-10-23",
            description = "A software job",
            event = e1)

        j1.save()

        s1 = Shift(date = "2012-1-10",
            start_time = "9:00",
            end_time = "3:00",
            max_volunteers = 1,
            job = j1)

        s2 = Shift(date = "2012-6-25",
            start_time = "10:00",
            end_time = "4:00",
            max_volunteers = 2,
            job = j1)

        s3 = Shift(date = "2012-12-9",
            start_time = "12:00",
            end_time = "6:00",
            max_volunteers = 4,
            job = j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical case
        shift_list = get_shifts_ordered_by_date(j1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        #test order
        self.assertEqual(shift_list[0].date, s1.date)
        self.assertEqual(shift_list[1].date, s2.date)
        self.assertEqual(shift_list[2].date, s3.date)
开发者ID:Ads7,项目名称:vms,代码行数:51,代码来源:test_unit.py

示例9: create_job_with_details

def create_job_with_details(job):
    """
    Creates and returns job with passed name and dates
    """

    j1 = Job(
        name=job[0],
        start_date=job[1],
        end_date=job[2],
        description=job[3],
        event=job[4])

    j1.save()
    return j1
开发者ID:systers,项目名称:vms,代码行数:14,代码来源:utils.py

示例10: get_shifts_by_date

    def get_shifts_by_date(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")
        
        j1.save()

        s1 = Shift(date = "2012-1-10",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 1,
                    job = j1)

        s2 = Shift(date = "2012-6-25",
                    location = "Infinite Loop",
                    start_time = "10:00",
                    end_time = "4:00",
                    max_volunteers = 2,
                    slots_remaining = 2,
                    job = j1)

        s3 = Shift(date = "2012-12-9",
                    location = "Loopy Loop Road",
                    start_time = "12:00",
                    end_time = "6:00",
                    max_volunteers = 4,
                    slots_remaining = 4,
                    job = j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical case
        shift_list = get_shifts_by_date(j1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        #test order
        self.assertEqual(shift_list[0].date, s1.date)
        self.assertEqual(shift_list[1].date, s2.date)
        self.assertEqual(shift_list[2].date, s3.date)
开发者ID:yaseppochi,项目名称:vms,代码行数:50,代码来源:tests.py

示例11: test_get_shift_by_id

    def test_get_shift_by_id(self):

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j1)

        s1.save()
        s2.save()
        s3.save()

        # test typical cases
        self.assertIsNotNone(get_shift_by_id(s1.id))
        self.assertIsNotNone(get_shift_by_id(s2.id))
        self.assertIsNotNone(get_shift_by_id(s3.id))

        self.assertEqual(get_shift_by_id(s1.id), s1)
        self.assertEqual(get_shift_by_id(s2.id), s2)
        self.assertEqual(get_shift_by_id(s3.id), s3)

        # test non-existant cases
        self.assertIsNone(get_shift_by_id(100))
        self.assertIsNone(get_shift_by_id(200))
        self.assertIsNone(get_shift_by_id(300))
        self.assertIsNone(get_shift_by_id(400))

        self.assertNotEqual(get_shift_by_id(100), s1)
        self.assertNotEqual(get_shift_by_id(100), s2)
        self.assertNotEqual(get_shift_by_id(100), s3)
        self.assertNotEqual(get_shift_by_id(200), s1)
        self.assertNotEqual(get_shift_by_id(200), s2)
        self.assertNotEqual(get_shift_by_id(200), s3)
        self.assertNotEqual(get_shift_by_id(300), s1)
        self.assertNotEqual(get_shift_by_id(300), s2)
        self.assertNotEqual(get_shift_by_id(300), s3)
开发者ID:ahmedsabie,项目名称:vms,代码行数:50,代码来源:tests.py

示例12: index

def index(request):
    if request.user.is_superuser:
        record_list = Record.objects.all()
        
        show_operator = True
    elif len(Job.objects(users=str(request.user))) != 0:
        record_list = []
        job_list = [job.name for job in Job.objects(users=str(request.user)).values_list('builders')]
        
        for record in Record.objects.all():
            if record.job in job_list:
                record_list.append(record)
                
        show_operator = True
    else:
        record_list = Record.objects.filter(user=str(request.user))
        show_operator = False
    
    job_list = []
    operator_list = []
    result_list = []
    
    for record in record_list:
        record.start_time = (datetime.utcfromtimestamp(int(record.start_time)) + timedelta(hours=8)).\
            strftime('%Y-%m-%d %H:%M:%S')
        job_list.append(record.job)
        operator_list.append(record.user)
        result_list.append(record.result)
        
        if record.finish_time != 0:
            record.finish_time = (datetime.utcfromtimestamp(int(record.finish_time)) + timedelta(hours=8)).\
                strftime('%Y-%m-%d %H:%M:%S')
        else:
            record.finish_time = ''
    
    job_list = sorted(set(job_list))
    operator_list = sorted(set(operator_list))
    result_list = sorted(set(result_list))
    
    context = {
        'record_list': record_list[::-1],
        'job_list': job_list,
        'operator_list': operator_list,
        'result_list': result_list,
        'user': request.user,
        'show_operator': show_operator,
    }

    return render(request, 'history/index.html', context)
开发者ID:stage37,项目名称:deploybot,代码行数:49,代码来源:views.py

示例13: test_get_job_by_id

    def test_get_job_by_id(self):

        e1 = Event(name = "Software Conference",
                start_date = "2012-10-22",
                end_date = "2012-10-25")

        e1.save()

        j1 = Job(name = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job",
                event = e1)

        j2 = Job(name = "Systems Administrator",
                start_date = "2012-9-1",
                end_date = "2012-10-26",
                description = "A systems administrator job",
                event = e1)

        j3 = Job(name = "Project Manager",
                start_date = "2012-1-2",
                end_date = "2012-2-2",
                description = "A management job",
                event = e1)

        j1.save()
        j2.save()
        j3.save()

        #test typical cases
        self.assertIsNotNone(get_job_by_id(j1.id))
        self.assertIsNotNone(get_job_by_id(j2.id))
        self.assertIsNotNone(get_job_by_id(j3.id))

        self.assertEqual(get_job_by_id(j1.id), j1)
        self.assertEqual(get_job_by_id(j2.id), j2)
        self.assertEqual(get_job_by_id(j3.id), j3)

        #test non-existant cases
        self.assertIsNone(get_job_by_id(100))
        self.assertIsNone(get_job_by_id(200))
        self.assertIsNone(get_job_by_id(300))
        self.assertIsNone(get_job_by_id(400))

        self.assertNotEqual(get_job_by_id(100), j1)
        self.assertNotEqual(get_job_by_id(100), j2)
        self.assertNotEqual(get_job_by_id(100), j3)
        self.assertNotEqual(get_job_by_id(200), j1)
        self.assertNotEqual(get_job_by_id(200), j2)
        self.assertNotEqual(get_job_by_id(200), j3)
        self.assertNotEqual(get_job_by_id(300), j1)
        self.assertNotEqual(get_job_by_id(300), j2)
        self.assertNotEqual(get_job_by_id(300), j3)
开发者ID:Ads7,项目名称:vms,代码行数:54,代码来源:tests.py

示例14: ReadTest

class ReadTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.username = '[email protected]'
        self.email = '[email protected]'
        self.passwd = 'passwd'
        self.title = 'Test'
        self.area = 'DESIGN'
        self.description = 'Testing...'
        user = User.objects.create_user(self.username, self.email, self.passwd)
        self.project = Project(author=user)
        self.project.save()
        self.job = Job(project=self.project, title=self.title, area=self.area,
                       description=self.description)
        self.job.save()
        self.client.login(username=self.username, password=self.passwd)

    def test_login_required(self):
        self.client.logout()
        response = self.client.get(READ_URL % self.job.id)
        self.assertRedirects(response, LOGIN_URL + '?next=' + READ_URL % self.job.id)

    def test_get(self):
        response = self.client.get(READ_URL % self.job.id)
        self.assertEqual(response.status_code, 200)

    def test_invalid_id(self):
        response = self.client.get(READ_URL % '2')
        self.assertEqual(response.status_code, 404)

    def test_deactivated_project(self):
        self.project.is_active = False
        self.project.save()
        response = self.client.get(READ_URL % self.job.id)
        self.assertEqual(response.status_code, 404)

    def test_deactivated_project_author(self):
        username = '[email protected]'
        email = '[email protected]'
        passwd = 'abc'
        user = User.objects.create_user(username, email, passwd)
        self.client.logout()
        self.client.login(username=username, password=passwd)
        self.project.author.is_active = False
        self.project.author.save()
        response = self.client.get(READ_URL % self.job.id)
        self.assertEqual(response.status_code, 404)
开发者ID:rodrigoalveslima,项目名称:runn,代码行数:47,代码来源:tests.py

示例15: import_jobs

def import_jobs(request):
  context_vars = dict()
  context_vars['header'] = capfirst(_('import jobs from workflowmax'))
  context_vars['comment'] = capfirst(_('this will destroy all your local jobs, please confirm your decision.'))
  if request.method == "POST":
    try:
      for job in Job.objects.all():
        job.delete()
      wm_jobs = WorkflowmaxJob.objects.all(datetime.now() - timedelta(days=365), datetime.now() + timedelta(days=365))
  #    wm_jobs = WorkflowmaxJob.objects.current()
      for wm_job in wm_jobs:
        job = Job()
        job.wm_import(wm_job)
      messages.success(request, capfirst(_('jobs were imported successfully')), fail_silently=True)
      return HttpResponseRedirect(reverse('job-list'))
    except NoInitialData, e:
      context_vars['error'] = capfirst(e)
开发者ID:pombredanne,项目名称:xscheduling,代码行数:17,代码来源:views.py


注:本文中的job.models.Job类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。