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 
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 
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()
Definition: main.py:1
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91