Belle II Software
release-08-01-10
test_caf_utils.py
1
8
import
unittest
9
from
unittest
import
TestCase
10
11
from
caf.utils
import
topological_sort
12
from
caf.utils
import
get_iov_from_file
13
from
caf.utils
import
IoV
14
15
16
class
TestUtils_topological_sort
(TestCase):
17
"""
18
Set of tests for the topological sort function
19
"""
20
21
def
test_order
(self):
22
"""
23
Checks that the resulting order is correct for a basic test
24
"""
25
dependencies = {}
26
dependencies[
'c'
] = [
'a'
,
'b'
]
27
dependencies[
'b'
] = [
'a'
]
28
dependencies[
'a'
] = []
29
order = topological_sort(dependencies)
30
self.assertEqual(order, [
'c'
,
'b'
,
'a'
])
31
32
def
test_cyclic
(self):
33
"""
34
Tests that cyclic dependency returns empty list
35
"""
36
dependencies = {}
37
dependencies[
'c'
] = [
'a'
]
38
dependencies[
'a'
] = [
'b'
]
39
dependencies[
'b'
] = [
'c'
]
40
order = topological_sort(dependencies)
41
self.assertFalse(order)
42
43
44
class
TestUtils_getiov
(TestCase):
45
"""
46
Test getting IOVs
47
"""
48
49
def
test_get_iov_from_file
(self):
50
"""
51
test get_iov_from_file()
52
"""
53
from
basf2
import
find_file
54
path = find_file(
'framework/tests/root_input.root'
)
55
iov = get_iov_from_file(path)
56
self.assertTrue(IoV(0, 1, 0, 1).contains(iov))
57
58
59
def
main
():
60
unittest.main()
61
62
63
if
__name__ ==
'__main__'
:
64
main
()
test_caf_utils.TestUtils_getiov
Definition:
test_caf_utils.py:44
test_caf_utils.TestUtils_getiov.test_get_iov_from_file
def test_get_iov_from_file(self)
Definition:
test_caf_utils.py:49
test_caf_utils.TestUtils_topological_sort
Definition:
test_caf_utils.py:16
test_caf_utils.TestUtils_topological_sort.test_cyclic
def test_cyclic(self)
Definition:
test_caf_utils.py:32
test_caf_utils.TestUtils_topological_sort.test_order
def test_order(self)
Definition:
test_caf_utils.py:21
main
Definition:
main.py:1
main
int main(int argc, char **argv)
Run all tests.
Definition:
test_main.cc:91
calibration
tests
test_caf_utils.py
Generated on Mon Sep 23 2024 14:00:53 for Belle II Software by
1.9.1