def test_absolute_path(self, atacseq_piface_data, path_config_file, tmpdir, pipe_path, expected_path_base, atac_pipe_name): """ Absolute path regardless of variables works as pipeline path. """ exp_path = os.path.join(tmpdir.strpath, expected_path_base, atac_pipe_name) piface = ProtocolInterface(path_config_file) _, obs_path, _ = piface.finalize_pipeline_key_and_paths(atac_pipe_name) assert exp_path == obs_path
def test_warns_about_nonexistent_pipeline_script_path( self, atacseq_piface_data, path_config_file, tmpdir, pipe_path, atac_pipe_name): """ Nonexistent, resolved pipeline script path generates warning. """ name_log_file = "temp-test-log.txt" path_log_file = os.path.join(tmpdir.strpath, name_log_file) temp_hdlr = logging.FileHandler(path_log_file, mode='w') fmt = logging.Formatter(DEV_LOGGING_FMT) temp_hdlr.setFormatter(fmt) temp_hdlr.setLevel(logging.WARN) models._LOGGER.handlers.append(temp_hdlr) pi = ProtocolInterface(path_config_file) pi.finalize_pipeline_key_and_paths(atac_pipe_name) with open(path_log_file, 'r') as logfile: loglines = logfile.readlines() assert 1 == len(loglines) logmsg = loglines[0] assert "WARN" in logmsg and pipe_path in logmsg
def test_non_dot_relpath_becomes_absolute(self, atacseq_piface_data, path_config_file, tmpdir, pipe_path, atac_pipe_name): """ Relative pipeline path is made absolute when requested by key. """ # TODO: constant-ify "path" and "ATACSeq.py", as well as possibly "pipelines" # and "protocol_mapping" section names of PipelineInterface exp_path = os.path.join(tmpdir.strpath, pipe_path, atac_pipe_name) piface = ProtocolInterface(path_config_file) _, obs_path, _ = piface.finalize_pipeline_key_and_paths(atac_pipe_name) assert exp_path == obs_path
def test_no_path(self, atacseq_piface_data, path_config_file, atac_pipe_name): """ Without explicit path, pipeline is assumed parallel to config. """ piface = ProtocolInterface(path_config_file) # The pipeline is assumed to live alongside its configuration file. config_dirpath = os.path.dirname(path_config_file) expected_pipe_path = os.path.join(config_dirpath, atac_pipe_name) _, full_pipe_path, _ = \ piface.finalize_pipeline_key_and_paths(atac_pipe_name) assert expected_pipe_path == full_pipe_path
def test_relpath_with_dot_becomes_absolute(self, tmpdir, atac_pipe_name, atacseq_piface_data): """ Leading dot drops from relative path, and it's made absolute. """ path_parts = ["relpath", "to", "pipelines", atac_pipe_name] sans_dot_path = os.path.join(*path_parts) pipe_path = os.path.join(".", sans_dot_path) atacseq_piface_data[atac_pipe_name]["path"] = pipe_path exp_path = os.path.join(tmpdir.strpath, sans_dot_path) path_config_file = _write_config_data( protomap={ATAC_PROTOCOL_NAME: atac_pipe_name}, conf_data=atacseq_piface_data, dirpath=tmpdir.strpath) piface = ProtocolInterface(path_config_file) _, obs_path, _ = piface.finalize_pipeline_key_and_paths(atac_pipe_name) # Dot may remain in path, so assert equality of absolute paths. assert os.path.abspath(exp_path) == os.path.abspath(obs_path)