def test_jobs(self):
        script = self.translate_script
        from ..backend import utils
        job = utils.create_wooey_job(script_version_pk=script.pk, data={'job_name': 'abc', 'sequence': 'aaa', 'out': 'abc'})
        job = job.submit_to_celery()
        old_pk = job.pk
        new_job = job.submit_to_celery(resubmit=True)
        self.assertNotEqual(old_pk, new_job.pk)
        # test rerunning, our output should be removed
        from ..models import UserFile
        old_output = sorted([i.pk for i in UserFile.objects.filter(job=new_job)])
        # the pk will not change here since we are using rerun=True
        new_job.submit_to_celery(rerun=True)
        # check that we overwrite our output
        new_output = sorted([i.pk for i in UserFile.objects.filter(job=new_job)])
        # Django 1.6 has a bug where they are reusing pk numbers
        if version.DJ17 >= version.DJANGO_VERSION:
            self.assertNotEqual(old_output, new_output)
        self.assertEqual(len(old_output), len(new_output))
        # check the old entries are gone
        if version.DJANGO_VERSION >= version.DJ17:
            # Django 1.6 has a bug where they are reusing pk numbers, so once again we cannot use this check
            self.assertEqual([], list(UserFile.objects.filter(pk__in=old_output)))

        file_previews = utils.get_file_previews(job)
        for group, files in file_previews.items():
            for fileinfo in files:
                # for testing, we use the local url
                response = Client().get(self.get_local_url(fileinfo))
                self.assertEqual(response.status_code, 200)

        # check our download links are ok
        # upload the file first to our storage engine so this works in tests
        local_storage = utils.get_storage(local=True)
        fasta_path = local_storage.save('fasta.fasta', open(os.path.join(config.WOOEY_TEST_DATA, 'fasta.fasta')))
        fasta_file = local_storage.open(fasta_path)
        job = utils.create_wooey_job(script_version_pk=script.pk,
                                        data={
                                            'fasta': fasta_file,
                                            'out': 'abc',
                                            'job_name': 'abc'
                                        }
                                     )

        # check our upload link is ok
        file_previews = utils.get_file_previews(job)
        for group, files in file_previews.items():
            for fileinfo in files:
                response = Client().get(self.get_local_url(fileinfo))
                self.assertEqual(response.status_code, 200)
dataset/ETHPy150Open wooey/Wooey/wooey/tests/test_models.py/TestJob.test_jobs/swapped operands of `>=`