def test_PipeContainer_repr(self): """Test the PipeContainer.__repr__() method.""" # Add a few objects. self.data_pipe.x = 10 self.data_pipe.chi2 = PipeContainer() # Test that __repr__() returns a string. self.assert_(type(self.data_pipe.__repr__()), str)
def add(self, pipe_name, pipe_type, bundle=None, switch=True): """Method for adding a new data pipe container to the dictionary. This method should be used rather than importing the PipeContainer class and using the statement 'D[pipe] = PipeContainer()', where D is the relax data storage object and pipe is the name of the data pipe. @param pipe_name: The name of the new data pipe. @type pipe_name: str @param pipe_type: The data pipe type. @type pipe_type: str @keyword bundle: The optional data pipe bundle to associate the data pipe with. @type bundle: str or None @keyword switch: A flag which if True will cause the new data pipe to be set to the current data pipe. @type switch: bool """ # Test if the pipe already exists. if pipe_name in self.instance: raise RelaxPipeError(pipe_name) # Create a new container. self[pipe_name] = PipeContainer() # Add the data pipe type string to the container. self[pipe_name].pipe_type = pipe_type # The pipe bundle. if bundle: # A new bundle. if bundle not in self.pipe_bundles: self.pipe_bundles[bundle] = [] # Add the pipe to the bundle. self.pipe_bundles[bundle].append(pipe_name) # Change the current data pipe. if switch: # Set the current data pipe. self.instance.current_pipe = pipe_name builtins.cdp = self[pipe_name] # Signal the switch. status.observers.pipe_alteration.notify()
def setUp(self): """Create a data pipe structure for testing all the object methods.""" # The initial empty structure. self.data_pipe = PipeContainer()