コード例 #1
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")
コード例 #2
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')
コード例 #3
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)
コード例 #4
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)