@@ -509,17 +509,31 @@ def test_percent_escape(test_data_dir, tmpdir, helpers):
509509 f_path = test_data_dir / "read_crate" / "with space.txt"
510510 f1 = crate .add_file (f_path )
511511 assert f1 .id == "with%20space.txt"
512+ assert f1 .source .is_file ()
513+ assert str (f1 .source ) == str (f_path )
512514 f2 = crate .add_file (f_path , dest_path = "subdir/with space.txt" )
513515 assert f2 .id == "subdir/with%20space.txt"
514- f3 = crate .add_file (test_data_dir / "read_crate" / "without%20space.txt" )
516+ assert f2 .source .is_file ()
517+ assert str (f2 .source ) == str (f_path )
518+ f3_path = test_data_dir / "read_crate" / "without%20space.txt"
519+ f3 = crate .add_file (f3_path )
515520 assert f3 .id == "without%2520space.txt"
521+ assert f3 .source .is_file ()
522+ assert str (f3 .source ) == str (f3_path )
516523 d_path = test_data_dir / "read_crate" / "a b"
517524 d1 = crate .add_dataset (d_path )
518525 assert d1 .id == "a%20b/"
526+ assert d1 .source .is_dir ()
527+ assert str (d1 .source ) == str (d_path )
519528 d2 = crate .add_dataset (d_path , dest_path = "subdir/a b" )
520529 assert d2 .id == "subdir/a%20b/"
521- d3 = crate .add_dataset (test_data_dir / "read_crate" / "j%20k" )
530+ assert d2 .source .is_dir ()
531+ assert str (d2 .source ) == str (d_path )
532+ d3_path = test_data_dir / "read_crate" / "j%20k"
533+ d3 = crate .add_dataset (d3_path )
522534 assert d3 .id == "j%2520k/"
535+ assert d3 .source .is_dir ()
536+ assert str (d3 .source ) == str (d3_path )
523537 out_path = tmpdir / "ro_crate_out"
524538 crate .write (out_path )
525539 json_entities = helpers .read_json_entities (out_path )
@@ -553,6 +567,19 @@ def test_percent_escape(test_data_dir, tmpdir, helpers):
553567 assert (unpack_path / "a b" / "c d.txt" ).is_file ()
554568 assert (unpack_path / "subdir" / "a b" / "c d.txt" ).is_file ()
555569 assert (unpack_path / "j%20k" / "l%20m.txt" ).is_file ()
570+ rcrate = ROCrate (out_path )
571+ rf1 = rcrate .get ("with%20space.txt" )
572+ assert str (rf1 .source ) == str (out_path / "with space.txt" )
573+ rf2 = rcrate .get ("subdir/with%20space.txt" )
574+ assert str (rf2 .source ) == str (out_path / "subdir/with space.txt" )
575+ rf3 = rcrate .get ("without%2520space.txt" )
576+ assert str (rf3 .source ) == str (out_path / "without%20space.txt" )
577+ df1 = rcrate .get ("a%20b/" )
578+ assert str (df1 .source ) == str (out_path / "a b/" )
579+ df2 = rcrate .get ("subdir/a%20b/" )
580+ assert str (df2 .source ) == str (out_path / "subdir/a b/" )
581+ df3 = rcrate .get ("j%2520k/" )
582+ assert str (df3 .source ) == str (out_path / "j%20k/" )
556583
557584
558585def test_stream_empty_file (test_data_dir , tmpdir ):
0 commit comments