def test_manifest_write():
    with tempfile.TemporaryDirectory() as tmpd:
        manifest = Manifest(
            os.path.join(test_data, 'file_set_good', 'files_good.tsv'))
        manifest.validate()
        (tsv_file, json_file) = manifest.write(
            tmpd)  # output new manifest in tsv and json.
def test_manifest_existing_bad_uuid():
    with tempfile.TemporaryDirectory() as tmpd:
        manifest = Manifest(os.path.join(test_data, 'with_bad_uuid.tsv'))
        manifest.validate()
def test_manifest_existing_uuid():
    with tempfile.TemporaryDirectory() as tmpd:
        manifest = Manifest(os.path.join(test_data, 'with_uuid.tsv'))
        manifest.validate()
        assert manifest.get_uuid() == '05218fd0-79e5-4214-92d5-e133cd16a798'
def test_manifest_uuid():
    with tempfile.TemporaryDirectory() as tmpd:
        manifest = Manifest(
            os.path.join(test_data, 'file_set_good', 'files_good.tsv'))
        manifest.validate()
        assert manifest.get_uuid()
def test_manifest_bad_filetype():
    infile = os.path.join(data_dir, 'SimplifiedManifest_v1.0.xls')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_missing_required():
    infile = os.path.join(data_dir, 'SimplifiedManifest_v1.0.tsv')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_paired_extn_mismatch():
    infile = os.path.join(test_data, 'pairedExtnMismatch.tsv')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_file_set_good():
    infile = os.path.join(test_data, 'file_set_good', 'files_good.tsv')
    manifest = Manifest(infile)
    manifest.validate(True)
    as_json = json.dumps(manifest.for_json())
def test_manifest_body_head_order():
    infile = os.path.join(test_data, 'bodyHeadOrder.tsv')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_extn_file2():
    infile = os.path.join(test_data, 'invalidExtnFile2.tsv')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_dup_files_diff_row():
    infile = os.path.join(test_data, 'dupFilesDiffRow.tsv')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_dup_files_same_row():
    infile = os.path.join(test_data, 'dupFilesSameRow.tsv')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_period_body_val():
    infile = os.path.join(test_data, 'periodBodyVal.tsv')
    manifest = Manifest(infile)
    manifest.validate()
def test_manifest_absent_body_val():
    infile = os.path.join(test_data, 'absentBodyVal.tsv')
    manifest = Manifest(infile)
    manifest.validate()
示例#15
0
    '-i',
    '--input',
    dest='input',
    metavar='FILE',
    help='Input manifest in tsv formats',
    required=True,
    type=lambda s: cliutil.extn_check(parser, ('tsv'), s, readable=True))
parser.add_argument('-o',
                    '--output',
                    dest='output',
                    metavar='DIR',
                    help='Output manifest to this area, two files (tsv, json)',
                    required=True)
parser.add_argument('-c',
                    '--checkfiles',
                    dest='checkfiles',
                    action='store_true',
                    help='When present check file exist and are non-zero size')

args = parser.parse_args()

try:
    manifest = Manifest(args.input)
    manifest.validate()
    (tsv_file, json_file) = manifest.write(
        args.output)  # output new manifest in tsv and json.
    print("Created files:\n\t%s\n\t%s" % (tsv_file, json_file))
except ValidationError as ve:
    print("ERROR: " + str(ve), file=sys.stderr)
    exit(1)