Exemple #1
0
    def test_create_codingjob_batches(self):
        a = amcattest.create_test_set(10)

        cj = CodingJob()
        cj.project = a.project
        cj.name = "foo"
        cj.unitschema = amcattest.create_test_schema(project=a.project)
        cj.articleschema = amcattest.create_test_schema(isarticleschema=True, project=a.project)
        cj.coder = amcattest.create_test_user()
        cj.insertuser = amcattest.create_test_user()

        arts = a.articles.all().values_list("id", flat=True)

        cjs = create_codingjob_batches(cj, arts, 2)
        self.assertEqual(5, len(cjs))

        cjs = create_codingjob_batches(cj, arts, 3)
        self.assertEqual(4, len(cjs))
Exemple #2
0
    def _run(self, job_size, articleset, name, project, **args):
        article_ids = articleset.articles.all().values_list("id", flat=True)
        job = self.bound_form.save(commit=False)
        
        if not job_size:
            job.articleset = ArticleSet.create_set(project=project, name=name, articles=article_ids, favourite=False)
            job.save()
            return job

        return create_codingjob_batches(job, article_ids, job_size)
Exemple #3
0
    def test_create_codingjob_batches(self):
        a = amcattest.create_test_set(10)

        cj = CodingJob()
        cj.project = a.project
        cj.name = "foo"
        cj.unitschema = amcattest.create_test_schema(project=a.project)
        cj.articleschema = amcattest.create_test_schema(isarticleschema=True,
                                                        project=a.project)
        cj.coder = amcattest.create_test_user()
        cj.insertuser = amcattest.create_test_user()

        arts = a.articles.all().values_list("id", flat=True)

        cjs = create_codingjob_batches(cj, arts, 2)
        self.assertEqual(5, len(cjs))

        cjs = create_codingjob_batches(cj, arts, 3)
        self.assertEqual(4, len(cjs))
Exemple #4
0
    def _run(self, job_size, articleset, name, project, **args):
        article_ids = articleset.articles.all().values_list("id", flat=True)
        job = self.bound_form.save(commit=False)

        if not job_size:
            job.articleset = ArticleSet.create_set(project=project,
                                                   name=name,
                                                   articles=article_ids,
                                                   favourite=False)
            job.save()
            return job

        return create_codingjob_batches(job, article_ids, job_size)