11 """Tests for :func:`basf2.set_module_parameters`""" 
   18     """Test fixture to check setting of parameters for modules in a path by name""" 
   21         """Setup a path with a few EventInfoSetter modules with special names""" 
   23         self.
m1m1 = basf2.register_module(
"EventInfoSetter")
 
   24         self.
m1m1.set_name(
"evt1")
 
   26         self.
m2m2 = basf2.register_module(
"EventInfoSetter")
 
   27         self.
m2m2.set_name(
"evt2")
 
   29         self.
m3m3 = basf2.register_module(
"EventInfoSetter")
 
   30         self.
m3m3.set_name(
"evt1")
 
   32         self.
pathpath = basf2.create_path()
 
   35         self.
pathpath.add_module(self.
m1m1)
 
   36         self.
pathpath.add_module(self.
m2m2)
 
   40         """Check if the parameters of a module are set explicitly to a given value 
   42         module: basf2.Module instance 
   43         params: named parameters of to check for 
   45         for p 
in module.available_params():
 
   47                 self.assertTrue(p.setInSteering)
 
   48                 self.assertEqual(p.values, params[p.name])
 
   51         """Check that all parameters of a given module are not set explicitely""" 
   52         for p 
in module.available_params():
 
   53             self.assertFalse(p.setInSteering)
 
   56         """Check setting the parameters for one module and that it does not affect the other modules""" 
   58         basf2.set_module_parameters(self.
pathpath, 
"evt1", evtNumList=[1, 2, 3])
 
   62         basf2.set_module_parameters(self.
pathpath, 
"evt2", evtNumList=[4])
 
   68         """Check that it also works if more than one module with the name exists""" 
   69         self.
pathpath.add_module(self.
m3m3)
 
   70         basf2.set_module_parameters(self.
pathpath, 
"evt1", evtNumList=[1, 2, 3])
 
   76         """Make sure that not supplying any parameters gives a ValueError""" 
   77         with self.assertRaises(ValueError):
 
   78             basf2.set_module_parameters(self.
pathpath, 
"evt1")
 
   81         """Make sure that not finding any module of the given name raises a KeyError""" 
   82         with self.assertRaises(KeyError):
 
   83             basf2.set_module_parameters(self.
pathpath, 
"evt3", evtNumList=[0])
 
   86         """Make sure that being unable to set the parameter raises a RuntimeError""" 
   87         with self.assertRaises(RuntimeError):
 
   88             basf2.set_module_parameters(self.
pathpath, 
"evt1", foo=
"bar")
 
   91         """check that modules in a condition sub path are not affected by default""" 
   93         basf2.set_module_parameters(self.
pathpath, 
"evt1", evtNumList=[1, 2, 3])
 
   99         """check that modules in a condition sub path are affected in recursive mode""" 
  101         basf2.set_module_parameters(self.
pathpath, 
"evt1", evtNumList=[1, 2, 3], recursive=
True)
 
  107         """check that modules in a for_each sub path are not affected by default""" 
  108         self.
pathpath.for_each(
"foo", 
"foos", self.
subpathsubpath)
 
  109         basf2.set_module_parameters(self.
pathpath, 
"evt1", evtNumList=[1, 2, 3])
 
  115         """check that modules in a for_each sub path are affected in recursive mode""" 
  116         self.
pathpath.for_each(
"foo", 
"foos", self.
subpathsubpath)
 
  117         basf2.set_module_parameters(self.
pathpath, 
"evt1", evtNumList=[1, 2, 3], recursive=
True)
 
  123         """check that it also works with a conditions and a for_each sub path in recursive mode""" 
  124         sub2 = basf2.create_path()
 
  125         m4 = sub2.add_module(
"EventInfoSetter")
 
  128         self.
pathpath.for_each(
"foo", 
"foos", sub2)
 
  129         basf2.set_module_parameters(self.
pathpath, 
"evt1", evtNumList=[1, 2, 3], recursive=
True)
 
  136 if __name__ == 
'__main__':
 
def check_unset(self, module)
def test_condition_recursive(self)
def test_undefined_param(self)
subpath
secondary test path
def test_subevent_recursive(self)
def test_condition_subevent(self)
def check_parameters(self, module, **params)