Beispiel #1
0
    def test_check_chm_job_all_tasks_complete_with_submit(self):
        temp_dir = tempfile.mkdtemp()
        try:
            out = create_successful_job(temp_dir)
            pargs = checkchmjob._parse_arguments('hi', [out, '--submit'])
            pargs.program = 'foo'
            pargs.version = '1.0.0'
            img_tile = os.path.join(out, CHMJobCreator.RUN_DIR,
                                    CHMJobCreator.TILES_DIR, 'foo.png',
                                    '001.foo.png')
            size = 800, 800
            myimg = Image.new('L', size)
            myimg.save(img_tile, 'PNG')

            probmap = os.path.join(out, CHMJobCreator.RUN_DIR,
                                   CHMJobCreator.PROBMAPS_DIR, 'foo.png')
            myimg.save(probmap)

            val = checkchmjob._check_chm_job(pargs)
            self.assertEqual(val, 0)

            cfac = CHMConfigFromConfigFactory(out)
            chmconfig = cfac.get_chmconfig()

            path = chmconfig.get_batchedjob_config_file_path()
            self.assertEqual(os.path.isfile(path), False)

            mpath = chmconfig.get_batched_mergejob_config_file_path()
            self.assertEqual(os.path.isfile(mpath), False)

        finally:
            shutil.rmtree(temp_dir)
Beispiel #2
0
    def test_check_chm_job_invalid_cluster(self):
        temp_dir = tempfile.mkdtemp()
        try:
            out = create_successful_job(temp_dir)

            cfac = CHMConfigFromConfigFactory(out)

            # alter cluster name to be an invalid one
            #
            chmconfig = cfac.get_chmconfig()
            con = chmconfig.get_config()
            con.set(CHMJobCreator.CONFIG_DEFAULT, CHMJobCreator.CONFIG_CLUSTER,
                    'doesnotexist')
            f = open(chmconfig.get_job_config(), 'w')
            con.write(f)
            f.flush()
            f.close()
            #

            pargs = checkchmjob._parse_arguments('hi', [out, '--submit'])
            pargs.program = 'foo'
            pargs.version = '1.0.0'
            img_tile = os.path.join(out, CHMJobCreator.RUN_DIR,
                                    CHMJobCreator.TILES_DIR, 'foo.png',
                                    '001.foo.png')
            size = 800, 800
            myimg = Image.new('L', size)
            myimg.save(img_tile, 'PNG')
            val = checkchmjob._check_chm_job(pargs)

            self.assertEqual(val, 2)
        finally:
            shutil.rmtree(temp_dir)
Beispiel #3
0
 def test_check_chm_job_success(self):
     temp_dir = tempfile.mkdtemp()
     try:
         out = create_successful_job(temp_dir)
         pargs = checkchmjob._parse_arguments('hi', [out])
         pargs.program = 'foo'
         pargs.version = '1.0.0'
         val = checkchmjob._check_chm_job(pargs)
         self.assertEqual(val, 0)
     finally:
         shutil.rmtree(temp_dir)
Beispiel #4
0
 def test_check_chm_job_no_jobs_to_run(self):
     temp_dir = tempfile.mkdtemp()
     try:
         out = create_successful_job(temp_dir)
         pargs = checkchmjob._parse_arguments('hi', [out])
         pargs.program = 'foo'
         pargs.version = '1.0.0'
         img_tile = os.path.join(out, CHMJobCreator.RUN_DIR,
                                 CHMJobCreator.TILES_DIR, 'foo.png',
                                 '001.foo.png')
         size = 800, 800
         myimg = Image.new('L', size)
         myimg.save(img_tile, 'PNG')
         val = checkchmjob._check_chm_job(pargs)
         self.assertEqual(val, 0)
     finally:
         shutil.rmtree(temp_dir)
Beispiel #5
0
    def test_check_chm_job_one_chm_job_to_run(self):
        temp_dir = tempfile.mkdtemp()
        try:
            out = create_successful_job(temp_dir)
            pargs = checkchmjob._parse_arguments('hi', [out, '--submit'])
            pargs.program = 'foo'
            pargs.version = '1.0.0'

            val = checkchmjob._check_chm_job(pargs)
            self.assertEqual(val, 0)

            cfac = CHMConfigFromConfigFactory(out)
            chmconfig = cfac.get_chmconfig()

            path = chmconfig.get_batchedjob_config_file_path()
            self.assertTrue(os.path.isfile(path))

        finally:
            shutil.rmtree(temp_dir)
Beispiel #6
0
 def test_parse_arguments(self):
     pargs = checkchmjob._parse_arguments('hi', ['1'])
     self.assertEqual(pargs.jobdir, '1')