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