Example #1
0
    def test_validate_config_nopipelines(self):
        input_data = """
            {"number_of_example_samples": 1,
            "pipeline": "catsup-kraken2",
            "upload":
            {
            "s3":
            {
                "bucket": "s3://mmm-sp3-alpha",
                "s3cmd-config": "/tmp/catsup/.s3cfg-catsup"
            }}}
            """

        input_dict = json.loads(input_data)
        expected_results = False
        result = validate.validate_config(input_dict)
        self.assertEqual(expected_results, result)
Example #2
0
def read_cfg(cfg_file, cfg_file_example):
    if not pathlib.Path(cfg_file).exists():
        if pathlib.Path(cfg_file_example).exists():
            print(f"{cfg_file} not found. Copying from {cfg_file_example}")
            shutil.copyfile(cfg_file_example, cfg_file)
            print(
                f"Please edit {cfg_file} to make it work with your environment"
            )
            sys.exit(0)
        else:
            logging.error(
                f"Couldn't find config file ({cfg_file}) or config file example ({cfg_file_example})"
            )
            sys.exit(1)
    global cfg
    with open(cfg_file) as f:
        cfg = json.loads(f.read())
        if not validate.validate_config(cfg):
            logging.error(f"Config file ({cfg_file}) is not valid.")
            sys.exit(1)
Example #3
0
    def test_validate_config_fullconfig(self):
        input_data = """
                {"number_of_example_samples": 1,
                "pipeline": "catsup-kraken2",
                "pipelines": {
                "catsup-kraken2":
                {
                    "script": "/tmp/catsup/catsup-kraken2.nf",
                    "image": "/tmp/catsup/fatos.img",
                    "human_ref": "/tmp/catsup/human_ref"
                }},
                "upload":
                {
                "s3":
                {
                    "bucket": "s3://mmm-sp3-alpha",
                    "s3cmd-config": "/tmp/catsup/.s3cfg-catsup"
                }}}
                """

        input_dict = json.loads(input_data)
        expected_results = True
        result = validate.validate_config(input_dict)
        self.assertEqual(expected_results, result)
Example #4
0
    def test_validate_config_noconfig(self):
        input_data = '{}'
        expected_results = False

        result = validate.validate_config(input_data)
        self.assertEqual(expected_results, result)