コード例 #1
0
ファイル: node_spec.py プロジェクト: nsi-iff/eispatterns
class NodeSpec(unittest.TestCase):

    def setUp(self):
        self.a_node = Node()
        self.a_resource = Resource()

    def it_receives_a_resource(self):
        #should not work
        non_resource = "I am not a Resource"
        (self.a_node.receive_resource, non_resource,'anything') |should| throw(ContractError)
        #test doubles won't work given type checking rules, using classic
        self.a_node.receive_resource('resource key', self.a_resource)
        self.a_node.input_area |should| contain('resource key')

    def it_transfers_a_resource(self):
        self.a_node.receive_resource('resource key', self.a_resource)
        #from input to processing
        self.a_node.transfer('resource key', 'input', 'processing')
         #one way of testing
        self.a_node.processing_area |should| contain('resource key')
         #another way of testing
        self.a_node.processing_area['resource key'] |should| be(self.a_resource)
        #from processing to output
        self.a_node.transfer('resource key', 'processing', 'output')
        self.a_node.output_area |should| contain('resource key')
        #from output to log
        self.a_node.transfer('resource key', 'output', 'log')
        self.a_node.log_area |should| contain('resource key')
コード例 #2
0
 def it_configures_and_runs_a_process(self):
     self.a_node = Node()
     self.another_node = Node()
     self.a_decorator = FakeDecorator()
     #process was restarted by setUp()
     the_movement = self.process.configure_activity_logger(
         self.a_node, self.another_node, self.process.create_loan_request,
         FakeDecorator.do_something)
     #starts running
     the_movement.context = self.process.run_activity(
         the_movement, self.a_decorator, 10)
     the_movement.context['result'] | should | equal_to(
         "this is an operation's return value:10")
     self.process.current_state() | should | equal_to('request_created')
     #configures and runs the template's refusal path
     #should go wrong
     the_movement = self.process.configure_activity_logger(
         self.a_node, self.another_node, self.process.loan_refused,
         FakeDecorator.do_something)
     (self.process.run_activity, the_movement, self.a_decorator,
      10) | should | throw(InvalidTransition)
     #now doing the right thing
     the_movement = self.process.configure_activity_logger(
         self.a_node, self.another_node,
         self.process.analyst_select_request, FakeDecorator.do_something)
     the_movement.context = self.process.run_activity(
         the_movement, self.a_decorator, 10)
     self.process.current_state() | should | equal_to('request_analyzed')
     the_movement = self.process.configure_activity_logger(
         self.a_node, self.another_node, self.process.loan_refused,
         FakeDecorator.do_something)
     the_movement.context = self.process.run_activity(
         the_movement, self.a_decorator, 15)
     self.process.current_state() | should | equal_to('refusal_letter_sent')
コード例 #3
0
ファイル: process_spec.py プロジェクト: nsi-iff/eispatterns
 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)
コード例 #4
0
ファイル: node_spec.py プロジェクト: ratem/eispatterns
 def it_moves_a_resource_between_two_nodes(self):
     another_node = Node()
     self.a_node.output_area["resource"] = self.a_resource
     self.a_node.output_area["non_resource"] = "I am not a Resource"
     # should not work
     (Node.move_resource, "wrong key", self.a_node, another_node) | should | throw(KeyError)
     (Node.move_resource, "non_resource", self.a_node, another_node) | should | throw(ContractError)
     # should work
     Node.move_resource("resource", self.a_node, another_node)
     another_node.input_area | should | include("resource")
コード例 #5
0
 def it_moves_a_resource_between_two_nodes(self):
     another_node = Node()
     self.a_node.output_area['resource'] = self.a_resource
     self.a_node.output_area['non_resource'] = "I am not a Resource"
     #should not work
     (Node.move_resource, 'wrong key', self.a_node,
      another_node) | should | throw(KeyError)
     (Node.move_resource, 'non_resource', self.a_node,
      another_node) | should | throw(ContractError)
     #should work
     Node.move_resource('resource', self.a_node, another_node)
     another_node.input_area | should | include('resource')
コード例 #6
0
 def move_loan_to_account(self, loan_key, account):
     ''' moves the approved loan to the account '''
     try:
         loan = self.decorated.output_area[loan_key]
         loan |should| be_instance_of(Loan)
     except KeyError:
         raise KeyError("Loan with key %s not found in Analyst's output area" % loan_key)
     except ShouldNotSatisfied:
         raise ContractError('Loan instance expected, instead %s passed' % type(loan))
     try:
         Node.move_resource(loan_key, self.decorated, account.decorated)
     except ShouldNotSatisfied:
         raise ContractError('Bank Account instance expected, instead %s passed' % type(account))
     account.register_credit(loan.loan_request.value)
コード例 #7
0
 def move_loan_to_account(self, loan_key, account):
     """ moves the approved loan to the account """
     try:
         loan = self.decorated.output_area[loan_key]
         loan | should | be_instance_of(Loan)
     except KeyError:
         raise KeyError("Loan with key %s not found in Analyst's output area" % loan_key)
     except ShouldNotSatisfied:
         raise ContractError("Loan instance expected, instead %s passed" % type(loan))
     try:
         Node.move_resource(loan_key, self.decorated, account.decorated)
     except ShouldNotSatisfied:
         raise ContractError("Bank Account instance expected, instead %s passed" % type(account))
     account.register_credit(loan.loan_request.value)
コード例 #8
0
 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)
コード例 #9
0
ファイル: node_spec.py プロジェクト: ratem/eispatterns
class NodeSpec(unittest.TestCase):
    def setUp(self):
        self.a_node = Node()
        self.a_resource = Resource()

    def it_transfers_a_resource(self):
        self.a_node.input_area["resource key"] = self.a_resource
        # from input to processing
        self.a_node.transfer("resource key", "input", "processing")
        # one way of testing
        self.a_node.processing_area | should | contain("resource key")
        # another way of testing
        self.a_node.processing_area["resource key"] | should | be(self.a_resource)
        # from processing to output
        self.a_node.transfer("resource key", "processing", "output")
        self.a_node.output_area | should | contain("resource key")
        # from output to log
        self.a_node.transfer("resource key", "output", "log")
        self.a_node.log_area | should | contain("resource key")

    def it_moves_a_resource_between_two_nodes(self):
        another_node = Node()
        self.a_node.output_area["resource"] = self.a_resource
        self.a_node.output_area["non_resource"] = "I am not a Resource"
        # should not work
        (Node.move_resource, "wrong key", self.a_node, another_node) | should | throw(KeyError)
        (Node.move_resource, "non_resource", self.a_node, another_node) | should | throw(ContractError)
        # should work
        Node.move_resource("resource", self.a_node, another_node)
        another_node.input_area | should | include("resource")
コード例 #10
0
class NodeSpec(unittest.TestCase):
    def setUp(self):
        self.a_node = Node()
        self.a_resource = Resource()

    def it_transfers_a_resource(self):
        self.a_node.input_area['resource key'] = self.a_resource
        #from input to processing
        self.a_node.transfer('resource key', 'input', 'processing')
        #one way of testing
        self.a_node.processing_area | should | contain('resource key')
        #another way of testing
        self.a_node.processing_area['resource key'] | should | be(
            self.a_resource)
        #from processing to output
        self.a_node.transfer('resource key', 'processing', 'output')
        self.a_node.output_area | should | contain('resource key')
        #from output to log
        self.a_node.transfer('resource key', 'output', 'log')
        self.a_node.log_area | should | contain('resource key')

    def it_moves_a_resource_between_two_nodes(self):
        another_node = Node()
        self.a_node.output_area['resource'] = self.a_resource
        self.a_node.output_area['non_resource'] = "I am not a Resource"
        #should not work
        (Node.move_resource, 'wrong key', self.a_node,
         another_node) | should | throw(KeyError)
        (Node.move_resource, 'non_resource', self.a_node,
         another_node) | should | throw(ContractError)
        #should work
        Node.move_resource('resource', self.a_node, another_node)
        another_node.input_area | should | include('resource')
コード例 #11
0
ファイル: organization.py プロジェクト: nsi-iff/eispatterns
 def __init__(self):
     Node.__init__(self)
     self.nodes = []
コード例 #12
0
 def setUp(self):
     self.a_client = Node()
     self.the_company = Node()
     self.a_process = Process()
     self.a_process.set_source(self.the_company)
     self.a_process.set_destination(self.a_client)
コード例 #13
0
 def setUp(self):
     self.a_node = Node()
     self.a_resource = Resource()
コード例 #14
0
ファイル: person.py プロジェクト: nsi-iff/eispatterns
 def __init__(self):
     Node.__init__(self)
     self.name = None
     self.contact_information = None
コード例 #15
0
 def setUp(self):
     self.a_node = Node()
     self.movement = Movement()
コード例 #16
0
ファイル: person.py プロジェクト: ratem/eispatterns
 def __init__(self):
     Node.__init__(self)
     self.name = None
     self.contact_information = None
コード例 #17
0
ファイル: node_spec.py プロジェクト: ratem/eispatterns
 def setUp(self):
     self.a_node = Node()
     self.a_resource = Resource()
コード例 #18
0
ファイル: organization.py プロジェクト: elielsr/eispatterns
 def __init__(self):
     Node.__init__(self)
     self.nodes = []
コード例 #19
0
 def __init__(self):
     Node.__init__(self)