def setUp(self): self.a_client = Node() self.the_company = Node() self.a_process = Process(self.the_company, self.a_client) self.a_processing_unit = Node() self.a_movement = Movement(self.a_processing_unit, self.a_processing_unit)
def configure_activity_logger(self, source, destination, activity, method): '''Configures an activity (activity, transition, state's action...)''' logger = Movement() logger.set_source(source) logger.set_destination(destination) logger.activity = activity logger.activity_associated_method = method self.insert_movement(activity.__name__, logger) return logger
def it_inserts_a_movement(self): #should not work non_movement = "I am not a Movement" (self.a_process.insert_movement, 'Ops!',non_movement) |should| throw(AssociationError) #test doubles won't work given type checking rules a_movement = Movement() self.a_process.insert_movement('A movement', a_movement) self.a_process.movements |should| contain('A movement')
def configure_activity_logger(self, source, destination, activity, method): '''Configures an activity (activity, transition, state's action...)''' logger = Movement() logger.set_source(source) logger.set_destination(destination) logger.activity = activity logger.activity_associated_method = method self.insert_movement(activity.__name__,logger) return logger
def __init__(self, source, destination): Movement.__init__(self, source, destination)
def __init__(self, name=None): Movement.__init__(self, name) self.movements = {}
def __init__(self, name=None): Movement.__init__(self,name) self.movements = {}
def setUp(self): self.a_node = Node() self.movement = Movement()
class MovementSpec(unittest.TestCase): def setUp(self): self.a_node = Node() self.movement = Movement() def it_checks_source_and_destination(self): non_node = "I am not a Node" (self.movement.set_source, self.a_node) |should_not| throw(AssociationError) (self.movement.set_destination, self.a_node) |should_not| throw(AssociationError) (self.movement.set_source, non_node) |should| throw(AssociationError) (self.movement.set_destination, non_node) |should| throw(AssociationError) def it_typifies_itself(self): another_node = Node() self.movement.set_source(self.a_node) #a transportation from a_node to Null self.movement.is_transportation() |should| be(True) self.movement.set_destination(self.a_node) #a transformation inside a_node self.movement.is_transformation() |should| be(True) self.movement.set_destination(another_node) #a transportation from a_node to another_node self.movement.is_transportation() |should| be(True)
def __init__(self, source, destination): Movement.__init__(self, source, destination) #composition self.movements = {} #aggregation self.nodes = {}
class MovementSpec(unittest.TestCase): def setUp(self): self.a_node = Node() self.movement = Movement() def it_checks_source_and_destination(self): non_node = "I am not a Node" (self.movement.set_source, self.a_node) | should_not | throw(AssociationError) (self.movement.set_destination, self.a_node) | should_not | throw(AssociationError) (self.movement.set_source, non_node) | should | throw(AssociationError) (self.movement.set_destination, non_node) | should | throw(AssociationError) def it_typifies_itself(self): another_node = Node() self.movement.set_source(self.a_node) #a transportation from a_node to Null self.movement.is_transportation() | should | be(True) self.movement.set_destination(self.a_node) #a transformation inside a_node self.movement.is_transformation() | should | be(True) self.movement.set_destination(another_node) #a transportation from a_node to another_node self.movement.is_transportation() | should | be(True)