def test_data_file_location_twice(tmp_path): c = Cache(tmp_path) _ = c.data_file_location('123-456', 'junk1.root') p2 = c.data_file_location('123-456', 'junk2.root') assert not p2.exists() p2.touch() assert p2.exists()
def test_data_file_location(tmp_path): c = Cache(tmp_path) p = c.data_file_location('123-456', 'junk.root') assert not p.exists() p.touch() assert p.exists() assert str(p).startswith(str(tmp_path))
def test_data_file_location_long_path(tmp_path): c = Cache(tmp_path) letters = string.ascii_lowercase file_significant_name = 'junk.root' long_file_name = ''.join(random.choice(letters) for i in range(230)) p = c.data_file_location('123-456', long_file_name + file_significant_name) assert (len(p.name) == 235 - len(p.parent.name)) assert p.name.endswith(file_significant_name)
def test_data_file_bad_file(tmp_path): 'Check a very long bad filename to make sure it is santized' c = Cache(tmp_path) p = c.data_file_location( '123-456', 'root:::dcache-atlas-xrootd-wan.desy.de:1094::pnfs:desy.de:atlas' ':dq2:atlaslocalgroupdisk:rucio:mc15_13TeV:8a:f1:DAOD_STDM3.05630052' '._000001.pool.root.198fbd841d0a28cb0d9dfa6340c890273-1.part.minio') assert not p.exists() # If the follow fails, on windows, it could be because very-long-pathnames are not # enabled. p.touch() assert p.exists()