Exemplo n.º 1
0
    def process_args(self):
        MODULE = 'new_ingest_benchmark'
        SUITE = 'benchmark'

        self.INPUT_DIR = dbutil.input_directory(MODULE, SUITE)
        self.OUTPUT_DIR = dbutil.output_directory(MODULE, SUITE)
        self.EXPECTED_DIR = dbutil.expected_directory(MODULE, SUITE)
        #define three modes of execution
        mode_desc_dict = {0: 'Initialise benchmark data in the expected directory',
                          1: 'Do not do ingestion. Compare existing ingestion ' \
                          'in\n %s\n with benchmark\n %s\n' \
                          %(self.OUTPUT_DIR, self.EXPECTED_DIR),
                          2: 'Compare  from this run with ' \
                          'expected benchmark database exiting if ' \
                          'they are different',
                          3: 'Compare databases and also compare tiles, even if ' \
                          'the databases are different'}
        if len(sys.argv) < 2:
            mode = -1
        else:
            try:
                mode = int(sys.argv[1])
            except ValueError:
                mode = -1
        msg = ''
        if mode not in [0, 1, 2, 3]:
            msg =  'Please specify a mode as follows:\n'
            for mode_num, desc in mode_desc_dict.items():
                msg = msg + 'python test_landsat_tiler.py %d:\t%s\n' %(mode_num, desc)
        return mode, msg
Exemplo n.º 2
0
    def test_input_directory(self):
        "Test test input directory finder/creator."

        dummy_version = dbutil.random_name("version")
        input_path = os.path.join(dbutil.TEST_RESOURCES_ROOT, dummy_version, "input", "module", "suite")
        try:
            path = dbutil.input_directory("module", "suite", version=dummy_version)
            self.check_directory(path, input_path)
        finally:
            os.removedirs(path)
Exemplo n.º 3
0
    def test_update_config_file(self):
        "Test config file update utility."

        input_dir = dbutil.input_directory(self.MODULE, self.SUITE)
        output_dir = dbutil.output_directory(self.MODULE, self.SUITE)
        expected_dir = dbutil.expected_directory(self.MODULE, self.SUITE)

        dbname = "TEST_TEST_TEST"
        config_file_name = "test_datacube.conf"

        output_path = dbutil.update_config_file(dbname, input_dir, output_dir, config_file_name)

        expected_path = os.path.join(expected_dir, config_file_name)
        if not os.path.isfile(expected_path):
            self.skipTest("Expected config file not found.")
        else:
            try:
                subprocess.check_output(["diff", output_path, expected_path])
            except subprocess.CalledProcessError as err:
                self.fail("Config file does not match expected result:\n" + err.output)
Exemplo n.º 4
0
    def test_update_config_file2(self):
        "Test config file update utility, version 2."

        input_dir = dbutil.input_directory(self.MODULE, self.SUITE)
        output_dir = dbutil.output_directory(self.MODULE, self.SUITE)
        expected_dir = dbutil.expected_directory(self.MODULE, self.SUITE)

        updates = {"dbname": "TEST_DBNAME", "temp_dir": "TEST_TEMP_DIR", "tile_root": "TEST_TILE_ROOT"}
        config_file_name = "test_datacube.conf"
        output_file_name = "test2_datacube.conf"

        output_path = dbutil.update_config_file2(updates, input_dir, output_dir, config_file_name, output_file_name)

        expected_path = os.path.join(expected_dir, output_file_name)
        if not os.path.isfile(expected_path):
            self.skipTest("Expected config file not found.")
        else:
            try:
                subprocess.check_output(["diff", output_path, expected_path])
            except subprocess.CalledProcessError as err:
                self.fail("Config file does not match expected result:\n" + err.output)