Exemplo n.º 1
0
 def bioodo_aggregation_fixture(request, tmpdir_factory):
     # NB: fmtdict is a dictionary, potentially pointing to
     # multiple output files; if so the multiple files must be put
     # in the same directory
     module, command, version, end, fmtdict = request.param
     params = {'version': version, 'end': end}
     keys = kwargs.get("keys", fmtdict.keys())
     outputs = [fmtdict[k].format(**params)
                for k in keys] * len(range(repeat))
     # Add applications/module prefix
     sources = [os.path.join("applications", module, output)
                for output in outputs]
     # Extract source basenames
     dests = [os.path.basename(src) for src in outputs]
     # Generate a unique test output directory
     fdir = os.path.join(module, str(version), command, end)
     # Make a temporary directory using unique test directory name
     pdir = factories.safe_mktemp(tmpdir_factory, fdir)
     # Symlink pytest_ngsfixtures files to temporary directory; the
     # safe_symlink function automagically uses pytest_ngsfixtures
     # installation directory to infer location of src
     count = 0
     for src, dst in zip(sources, dests):
         rdir = pdir.mkdir(str(count))
         factories.safe_symlink(rdir, src, dst)
         count += 1
     return module, command, version, end, pdir
def data(request, tmpdir_factory):
    """Generate fixture for rule"""
    app, rule = request.param
    if request.function.__name__ == "test_run":
        d = ruleinfo.parse_rule(rule)
        d['app'] = app
        logger.info("Setting up fixture for {}".format(d['name']))

        fixture_dir = os.path.join(app, d['name'])
        fixture = factories.safe_mktemp(tmpdir_factory, fixture_dir)

        inputmap = set_inputmap(d)
        wildcards = utils.get_wildcards(inputmap, d['wildcard_constraints'])
        try:
            output = set_output(d, wildcards)
        except:
            output = None
        for wc, src in inputmap:
            if src:
                if isinstance(src, str):
                    p = factories.safe_symlink(fixture, src, basename(src))
                else:
                    for s in src:
                        p = factories.safe_symlink(fixture, s, basename(s))
    else:
        output = None
        fixture_dir = os.path.join(app, os.path.splitext(basename(rule))[0])
        fixture = factories.safe_mktemp(tmpdir_factory, fixture_dir)
    if request.config.option.ngs_show_fixture:
        logger.info("fixture directory: {}".format(str(fixture)))
    return app, rule, output, fixture
Exemplo n.º 3
0
def test_safe_symlink(tmpdir_factory, bam):
    p = tmpdir_factory.mktemp("safe_symlink")
    # Test using string as input without capturing return
    safe_symlink(p, bamfile, "bar/foo.bar")
    assert str(p).endswith("safe_symlink0")
    # Test using string as input
    l = safe_symlink(p, bamfile, "foo/foo.bar")
    assert str(l).endswith("foo/foo.bar")
    assert l.realpath() == bamfile_realpath
    # Test using localpath as input
    l = safe_symlink(p, bam, "foo.bar")
    assert l.realpath() == bam.realpath()
    assert str(l).endswith("foo.bar")
Exemplo n.º 4
0
def ao(request, tmpdir_factory):
    app, command, version, end, fmtdict = request.param
    params = {'version': version, 'end': end}
    outputs = [fmt.format(**params) for fmt in fmtdict.values()]
    sources = [os.path.join("applications", app, output) for output in outputs]
    dests = [os.path.basename(src) for src in sources]
    fdir = os.path.join(app, str(version), command, end)
    pdir = safe_mktemp(tmpdir_factory, fdir)
    for src, dst in zip(sources, dests):
        p = safe_symlink(pdir, src, dst)
    return pdir
Exemplo n.º 5
0
 def bioodo_fixture(request, tmpdir_factory):
     # NB: fmtdict is a dictionary, potentially pointing to
     # multiple output files
     module, command, version, end, fmtdict = request.param
     params = {'version': version, 'end': end}
     # Generate pytest_ngsfixtures application output names relative to
     # applications/module directory
     outputs = [fmt.format(**params) for fmt in fmtdict.values()]
     # Add applications/module prefix
     sources = [os.path.join("applications", module, output)
                for output in outputs]
     # Extract source basenames
     dests = [os.path.basename(src) for src in sources]
     # Generate a unique test output directory name
     fdir = os.path.join(module, str(version), command, end)
     # Make a temporary directory using unique test directory name
     pdir = factories.safe_mktemp(tmpdir_factory, fdir)
     # Symlink pytest_ngsfixtures files to temporary directory; the
     # safe_symlink function automagically uses pytest_ngsfixtures
     # installation directory to infer location of src
     for src, dst in zip(sources, dests):
         factories.safe_symlink(pdir, src, dst)
     return module, command, version, end, pdir