17"""Tests for lal.utils.cache
19See utils_cache_verify.py for more tests of the same module
24from pathlib
import Path
28import igwn_segments
as segments
37 """Test suite for `lal.utils.CacheEntry`.
39 CacheEntry = lal_utils.CacheEntry
41 @pytest.mark.parametrize(("args", "segs"), (
44 (
"A",
"TEST", segments.segment(0, 1),
"test.gwf"),
45 {
'A': [segments.segment(0, 1)]},
49 (
"-",
"-", segments.segment(2, 10),
"test.gwf"),
50 {
None: [segments.segment(2, 10)]},
54 (
"H1,L1",
"TEST", segments.segment(5, 10),
"test.gwf"),
56 'H1': [segments.segment(5, 10)],
57 'L1': [segments.segment(5, 10)],
62 """Test that `CacheEntry.segmentlistdict` works.
65 assert a.segmentlistdict == segs
68 """Test that `CacheEntry` FSPath protocol works.
70 a = self.CacheEntry("A",
"TEST", segments.segment(0, 1),
"/path/to/test.gwf")
71 assert str(Path(a)) == a.path
72 assert os.path.basename(a) ==
"test.gwf"
77 from glue.lal
import Cache
as GlueCache
78 except ImportError
as exc:
80 GlueCache.entry_class = lal_utils.CacheEntry
86 gcache = GlueCache.from_urls(files, coltype=LIGOTimeGPS)
88 lcache = lal_utils.lalcache_from_gluecache(gcache)
91 if os.path.isfile(fp):
93 assert lcache.length == len(gcache)
94 assert lcache.list.url == (
95 "file://localhost{}".format(os.path.abspath(files[0]))
99if __name__ ==
'__main__':
100 args = sys.argv[1:]
or [
"-v",
"-rs",
"--junit-xml=junit-utils-cache.xml"]
101 sys.exit(pytest.main(args=[__file__] + args))
Test suite for lal.utils.CacheEntry.
def test_segmentlistdict(self, args, segs)
Test that CacheEntry.segmentlistdict works.
def test_fspath(self)
Test that CacheEntry FSPath protocol works.
def test_lalcache_from_gluecache()