コード例 #1
0
def test_check_content(ingestcheck, client, tmpdirsec, case):
    """Dump the content and check that we get the reference dump file back.
    """
    require_icat_version("4.6.0", "Issue icatproject/icat.server#155")
    backend, filetype = case
    refdump = backends[backend]['refdump']
    fileext = backends[backend]['fileext']
    dump = os.path.join(tmpdirsec, "dump" + fileext)
    fdump = os.path.join(tmpdirsec, "dump-filter" + fileext)
    reffdump = os.path.join(tmpdirsec, "dump-filter-ref" + fileext)
    filter_file(refdump, reffdump, *backends[backend]['filter'])
    if filetype == 'FILE':
        icatdump(client, dump, backend)
    elif filetype == 'MEMORY':
        if 'b' in icat.dumpfile.Backends[backend][0].mode:
            stream = io.BytesIO()
            icatdump(client, stream, backend)
            icatdata = stream.getvalue()
            stream.close()
        else:
            stream = io.StringIO()
            icatdump(client, stream, backend)
            icatdata = stream.getvalue().encode('ascii')
            stream.close()
        with open(dump, "wb") as f:
            f.write(icatdata)
    else:
        raise RuntimeError("Invalid file type %s" % filetype)
    filter_file(dump, fdump, *backends[backend]['filter'])
    assert filecmp.cmp(reffdump, fdump), "content of ICAT was not as expected"
コード例 #2
0
def test_check_content(standardConfig, tmpdirsec):
    """Dump the resulting content and compare with a reference dump.
    """
    dump = os.path.join(tmpdirsec.dir, "dump.yaml")
    fdump = os.path.join(tmpdirsec.dir, "dump-filter.yaml")
    reffdump = os.path.join(tmpdirsec.dir, "dump-filter-ref.yaml")
    filter_file(refdump, reffdump, *yaml_filter)
    args = standardConfig.cmdargs + ["-f", "YAML", "-o", dump]
    callscript("icatdump.py", args)
    filter_file(dump, fdump, *yaml_filter)
    assert filecmp.cmp(reffdump, fdump), "content of ICAT was not as expected"
コード例 #3
0
def test_check_content(standardConfig, tmpdirsec):
    """Dump the resulting content and compare with a reference dump.
    """
    dump = os.path.join(tmpdirsec.dir, "dump.yaml")
    fdump = os.path.join(tmpdirsec.dir, "dump-filter.yaml")
    reffdump = os.path.join(tmpdirsec.dir, "dump-filter-ref.yaml")
    filter_file(refdump, reffdump, *yaml_filter)
    args = standardConfig.cmdargs + ["-f", "YAML", "-o", dump]
    callscript("icatdump.py", args)
    filter_file(dump, fdump, *yaml_filter)
    assert filecmp.cmp(reffdump, fdump), "content of ICAT was not as expected"
コード例 #4
0
def test_check_content(standardCmdArgs, tmpdirsec):
    """Dump the resulting content and compare with a reference dump.
    """
    require_icat_version("4.6.0", "Issue icatproject/icat.server#155")
    dump = os.path.join(tmpdirsec, "dump.yaml")
    fdump = os.path.join(tmpdirsec, "dump-filter.yaml")
    reffdump = os.path.join(tmpdirsec, "dump-filter-ref.yaml")
    filter_file(refdump, reffdump, *yaml_filter)
    args = standardCmdArgs + ["-f", "YAML", "-o", dump]
    callscript("icatdump.py", args)
    filter_file(dump, fdump, *yaml_filter)
    assert filecmp.cmp(reffdump, fdump), "content of ICAT was not as expected"
コード例 #5
0
def test_check_content_xml(standardConfig, tmpdirsec, backend):
    """Dump the content and check that we get the reference dump file back.
    """
    refdump = backends[backend]['refdump']
    fileext = backends[backend]['fileext']
    dump = os.path.join(tmpdirsec.dir, "dump" + fileext)
    fdump = os.path.join(tmpdirsec.dir, "dump-filter" + fileext)
    reffdump = os.path.join(tmpdirsec.dir, "dump-filter-ref" + fileext)
    filter_file(refdump, reffdump, *backends[backend]['filter'])
    args = standardConfig.cmdargs + ["-f", backend, "-o", dump]
    callscript("icatdump.py", args)
    filter_file(dump, fdump, *backends[backend]['filter'])
    assert filecmp.cmp(reffdump, fdump), "content of ICAT was not as expected"
コード例 #6
0
def test_check_summary_user_yaml(tmpdirsec, user):
    """Check the number of objects from a user's point of view.

    This checks which objects a given user may see and thus whether
    the (read) access rules work as expected.
    """
    summary = os.path.join(tmpdirsec.dir, "summary.%s" % user)
    ref = refsummary[user]
    reff = os.path.join(tmpdirsec.dir, "summary-filter-ref.%s" % user)
    filter_file(ref, reff, *summary_filter)
    conf = getConfig(confSection=user)
    with open(summary, "wt") as out:
        callscript("icatsummary.py", conf.cmdargs, stdout=out)
    assert filecmp.cmp(reff, summary), "ICAT content was not as expected"
コード例 #7
0
def test_check_content(ingestcheck, standardCmdArgs, tmpdirsec, case):
    """Dump the content and check that we get the reference dump file back.
    """
    require_icat_version("4.6.0", "Issue icatproject/icat.server#155")
    backend, filetype = case
    refdump = backends[backend]['refdump']
    fileext = backends[backend]['fileext']
    dump = os.path.join(tmpdirsec, "dump" + fileext)
    fdump = os.path.join(tmpdirsec, "dump-filter" + fileext)
    reffdump = os.path.join(tmpdirsec, "dump-filter-ref" + fileext)
    filter_file(refdump, reffdump, *backends[backend]['filter'])
    if filetype == 'FILE':
        args = standardCmdArgs + ["-f", backend, "-o", dump]
        callscript("icatdump.py", args)
    elif filetype == 'STDINOUT':
        args = standardCmdArgs + ["-f", backend]
        with open(dump, "wt") as outfile:
            callscript("icatdump.py", args, stdout=outfile)
    else:
        raise RuntimeError("Invalid file type %s" % filetype)
    filter_file(dump, fdump, *backends[backend]['filter'])
    assert filecmp.cmp(reffdump, fdump), "content of ICAT was not as expected"