def then_a_new_loan_request_with_the_account_number_and_desired_value_is_created( step, account_number, desired_value): #Processes are nodes that use the company as the source node, and the client as destination world.the_company = Machine() world.a_client = Person() #now the business process starts to be assembled world.an_individual_credit_operation = Process(world.the_company, world.a_client) world.loan_request_creation = Transformation( world.credit_analyst.decorated, world.credit_analyst.decorated) world.loan_request_creation.set_action( world.credit_analyst.create_loan_request) world.loan_request_creation.action | should | equal_to( world.credit_analyst.create_loan_request) #associates the transformation to the process world.an_individual_credit_operation.insert_movement( 'loan request creation', world.loan_request_creation) world.an_individual_credit_operation.movements | should | contain( 'loan request creation') #finally it runs the transformation... world.an_individual_credit_operation.movements[ 'loan request creation'].perform(world.account, desired_value) #checks if the loan request is stored in the Node's input_area world.credit_analyst.decorated.input_area | should | contain( account_number)
def then_a_new_loan_request_with_the_account_number_and_desired_value_is_created( step, account_number, desired_value): #Processes are nodes that use the company as the source node, and the client as destination world.the_company = Machine() world.a_client = Person() #now the business process starts to be assembled world.an_individual_credit_operation = Process( 'Individual Customer Credit Operation') world.an_individual_credit_operation.set_source(world.the_company) world.an_individual_credit_operation.set_destination(world.a_client) #configures the process using a template state machine template = LoanProcess() configurator = StateMachineConfigurator(template) configurator.configure(world.an_individual_credit_operation) #configures the loan request creation the_movement = world.an_individual_credit_operation.configure_activity_logger( world.credit_analyst.decorated, world.credit_analyst.decorated, world.an_individual_credit_operation.create_loan_request, CreditAnalystDecorator.create_loan_request) world.an_individual_credit_operation.movements | should | contain( the_movement.activity.__name__) #runs the loan request creation the_movement.context = world.an_individual_credit_operation.run_activity( the_movement, world.credit_analyst, world.account, desired_value) world.an_individual_credit_operation.current_state() | should | equal_to( 'request_created')
def setUp(self): self.a_client_decorator = ClientDecorator() self.a_client = Person() self.a_client_decorator.decorate(self.a_client) self.a_bank_account_decorator = BankAccountDecorator(self.a_client, '1234 5 - 6') #test doubles won't work given type checking rules, using classic self.a_machine = Machine()
def and_an_individual_customer_with_account_number_account_number_asks_for_a_personal_loan( step, account_number): world.a_machine = Machine() a_client = Person() a_client_decorator = ClientDecorator() a_client_decorator.decorate(a_client) world.account = BankAccountDecorator(a_client, account_number) world.account.average_credit = 2501 world.account.decorate(world.a_machine)
def it_creates_a_loan(self): an_employee_decorator = EmployeeDecorator() an_employee_decorator.decorate(self.a_person) loan_request = LoanRequest(self.an_account, 7000, self.a_credit_analyst_decorator) self.a_credit_analyst_decorator.decorate(self.a_person) self.a_credit_analyst_decorator.decorated.output_area[ self.an_account.number] = loan_request #creates a machine to be decorated by the account - will need to check its processing_area a_machine = Machine() self.an_account.decorate(a_machine) #creates the loan self.a_credit_analyst_decorator.create_loan(loan_request) #given that I am using datetime to generate the key, I cannot access the newly #created loan through its key self.a_credit_analyst_decorator.decorated.output_area.values( ) | should | have_at_least(1).loan
def it_discount_a_check(self): #Discounting a check, it should work! a_machine = Machine() a_client = Person() a_client_decorator = ClientDecorator() a_client_decorator.decorate(a_client) a_bank_account_decorator = BankAccountDecorator(a_client, "1234-5") a_bank_account_decorator.decorate(a_machine) a_bank_account_decorator.deposit(100) a_bank_account_decorator.average_credit | should | equal_to(100) a_check = Check(id_="123", account_number="1234-5", value=10) self.an_attendant_decorator.discount_check(a_check) a_bank_account_decorator.average_credit | should | equal_to(90) #It should fail! other_bank_account_decorator = BankAccountDecorator(a_client, "1235-5") other_bank_account_decorator.average_credit = 100 other_bank_account_decorator.decorate(a_machine) a_check = Check(id_="123", account_number="1235-5", value=110) (self.an_attendant_decorator.discount_check, a_check) | should | throw(InsuficientFunds) other_bank_account_decorator.average_credit | should | equal_to(100)
from domain.supportive.association_error import AssociationError from domain.supportive.contract_matchers import be_decorated_by from domain.node.machine import Machine from domain.supportive.contract_error import ContractError from bank_system.resources.loan_request import LoanRequest from bank_system.resources.loan import Loan from bank_system.rules.bank_system_rule_base import BankSystemRuleBase from domain.supportive.rule_manager import RuleManager from domain.resource.operation import operation from should_dsl import should, ShouldNotSatisfied from domain.node.node import Node from domain.resource.operation import operation from django.contrib.auth.models import User import jsonpickle a_machine = Machine() a_person = Person() ################################################# DECORATOR: BANK ACCOUNT ############################################################## # A classe ClientName é para a atribuição automática do nome do cliente na sua conta class ClientName(User): class Meta: proxy = True def __unicode__(self): return '%s %s' % (self.first_name, self.last_name)
def setUp(self): self.a_bank_account_decorator = BankAccountDecorator('12345-6') #test doubles won't work given type checking rules, using classic self.a_machine = Machine()
def setUp(self): self.a_resource = Resource() self.a_person = Person() self.a_machine = Machine() self.a_transportation = Transportation(self.a_person, self.a_machine)