def test_insert(self):
        jobtype = JobType()
        jobtype.name = "foo"
        jobtype.description = "this is a job type"
        jobtype_version = JobTypeVersion()
        jobtype_version.jobtype = jobtype
        jobtype_version.version = 1
        jobtype_version.classname = "Foobar"
        jobtype_version.code = ("""
            class Foobar(JobType):
                pass""").encode("utf-8")
        db.session.add(jobtype_version)

        job = Job()
        job.title = "Test Job"
        job.jobtype_version = jobtype_version

        task = Task(state=WorkState.DONE,
                    priority=404,
                    frame=1,
                    last_error="foobar",
                    job=job)
        db.session.add(task)
        db.session.commit()
        task_id = task.id
        db.session.remove()
        searched = Task.query.filter_by(id=task_id).first()
        self.assertIsNotNone(searched)
        self.assertEqual(searched.state, WorkState.DONE)
        self.assertEqual(searched.priority, 404)
        self.assertEqual(searched.attempts, 0)
        self.assertEqual(searched.frame, 1)
    def test_insert(self):
        # A job can not be created without a jobtype, create one first
        jobtype = JobType()
        jobtype.name = "foo"
        jobtype.description = "this is a job type"
        jobtype_version = JobTypeVersion()
        jobtype_version.jobtype = jobtype
        jobtype_version.version = 1
        jobtype_version.classname = "Foobar"
        jobtype_version.code = ("""
            class Foobar(JobType):
                pass""").encode("utf-8")
        db.session.add(jobtype_version)

        queue = JobQueue()
        queue.name = "FooQueue"

        job = Job()
        job.title = "Test Job"
        job.jobtype_version = jobtype_version
        job.queue = queue

        tag = Tag()
        tag.jobs = [job]
        tag.tag = "foo456"
        db.session.add_all([tag, job])
        db.session.commit()
        model_id = tag.id
        job_id = job.id
        db.session.remove()
        result = Tag.query.filter_by(id=model_id).first()
        self.assertEqual(result.tag, "foo456")
        self.assertEqual(result.jobs[0].id, job_id)
예제 #3
0
    def test_insert(self):
        jobtype = JobType()
        jobtype.name = "foo"
        jobtype.description = "this is a job type"
        jobtype_version = JobTypeVersion()
        jobtype_version.jobtype = jobtype
        jobtype_version.version = 1
        jobtype_version.classname = "Foobar"
        jobtype_version.code = ("""
            class Foobar(JobType):
                pass""").encode("utf-8")
        db.session.add(jobtype_version)

        job = Job()
        job.title = "Test Job"
        job.jobtype_version = jobtype_version

        task = Task(
            state=WorkState.DONE,
            priority=404,
            frame=1,
            last_error="foobar",
            job=job)
        db.session.add(task)
        db.session.commit()
        task_id = task.id
        db.session.remove()
        searched = Task.query.filter_by(id=task_id).first()
        self.assertIsNotNone(searched)
        self.assertEqual(searched.state, WorkState.DONE)
        self.assertEqual(searched.priority, 404)
        self.assertEqual(searched.attempts, 0)
        self.assertEqual(searched.frame, 1)
    def test_insert(self):
        # A job can not be created without a jobtype, create one first
        jobtype = JobType()
        jobtype.name = "foo"
        jobtype.description = "this is a job type"
        jobtype_version = JobTypeVersion()
        jobtype_version.jobtype = jobtype
        jobtype_version.version = 1
        jobtype_version.classname = "Foobar"
        jobtype_version.code = ("""
            class Foobar(JobType):
                pass""").encode("utf-8")
        db.session.add(jobtype_version)

        queue = JobQueue()
        queue.name = "FooQueue"

        job = Job()
        job.title = "Test Job"
        job.jobtype_version = jobtype_version
        job.queue = queue

        # Software requirement needs a software first
        software = Software()
        software.software = "foo"
        requirement = JobSoftwareRequirement()
        requirement.job = job
        requirement.software = software
        db.session.add(job)
        db.session.commit()
        job_id = job.id
        requirement_id = requirement.id
        requirement2 = JobSoftwareRequirement.query.\
            filter_by(id=requirement_id).first()
        self.assertEqual(requirement.job.id, job_id)
        self.assertEqual(requirement2.software.software, "foo")
        self.assertEqual(requirement2.min_version, None)
        self.assertEqual(requirement2.max_version, None)
    def test_clear_last_error(self):
        jobtype = JobType()
        jobtype.name = "foo"
        jobtype.description = "this is a job type"
        jobtype_version = JobTypeVersion()
        jobtype_version.jobtype = jobtype
        jobtype_version.version = 1
        jobtype_version.classname = "Foobar"
        jobtype_version.code = ("""
            class Foobar(JobType):
                pass""").encode("utf-8")
        db.session.add(jobtype_version)

        job = Job()
        job.title = "Test Job"
        job.jobtype_version = jobtype_version

        task = Task(frame=1, job=job, last_error="foobar")
        db.session.add(task)
        db.session.commit()
        db.session.add(task)
        task.state = WorkState.DONE
        self.assertIsNone(task.last_error)
예제 #6
0
    def test_clear_last_error(self):
        jobtype = JobType()
        jobtype.name = "foo"
        jobtype.description = "this is a job type"
        jobtype_version = JobTypeVersion()
        jobtype_version.jobtype = jobtype
        jobtype_version.version = 1
        jobtype_version.classname = "Foobar"
        jobtype_version.code = ("""
            class Foobar(JobType):
                pass""").encode("utf-8")
        db.session.add(jobtype_version)

        job = Job()
        job.title = "Test Job"
        job.jobtype_version = jobtype_version

        task = Task(frame=1, job=job, last_error="foobar")
        db.session.add(task)
        db.session.commit()
        db.session.add(task)
        task.state = WorkState.DONE
        self.assertIsNone(task.last_error)