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')
コード例 #2
0
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 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()
コード例 #4
0
 def it_decorates(self):
     a_decorator = FakeDecorator()
     a_person = Person()
     a_decorator.decorate(a_person)
     a_person.decorators | should | contain(
         "Fake Decorator for testing purposes")
     FakeDecorator.decoration_rules = ['xxxxx']
     (RuleManager.get_instance().check_decoration_rules, a_decorator,
      a_person) | should | throw(AttributeError)
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)
コード例 #6
0
 def it_check_decoration_rules(self):
     a_person = Person()
     a_decorator = SomeDecorator()
     passed, approved_rules, refused_rules = RuleManager.get_instance().check_decoration_rules(SomeDecorator, a_person)
     passed |should| be(True)
     approved_rules |should| contain('''Associated object should be instance of Person''')
     refused_rules |should| be(None)
     SomeDecorator.decoration_rules = ['xxxxx']
     (RuleManager.get_instance().check_decoration_rules, SomeDecorator, a_person) |should| throw(AttributeError)
     #tear down
     SomeDecorator.decoration_rules = ['should_be_instance_of_person']
コード例 #7
0
 def it_check_association_with_loan_request(self):
     a_client_decorator = ClientDecorator()
     a_client = Person()
     a_client_decorator.decorate(a_client)
     #set the rule base
     RuleManager.rule_base = BankSystemRuleBase()
     #
     (Loan, 'I am not a loan request') | should | throw(AssociationError)
     a_credit_analyst_decorator = CreditAnalystDecorator('12345-6')
     an_account = BankAccountDecorator(a_client, '1234567-8')
     a_loan_request = LoanRequest(an_account, 7000,
                                  a_credit_analyst_decorator)
     (Loan, a_loan_request) | should_not | throw(AssociationError)
コード例 #8
0
 def it_check_associations_with_bank_account_and_credit_analyst(self):
     a_client = Person()
     a_client_decorator = ClientDecorator()
     a_client_decorator.decorate(a_client)
     an_account = BankAccountDecorator(a_client, '12345-6')
     #set the rule base
     RuleManager.rule_base = BankSystemRuleBase()
     #
     an_account = BankAccountDecorator(a_client, '12345-6')
     an_analyst = CreditAnalystDecorator('abcde-f')
     (LoanRequest, 'I am not an account', 123,
      an_analyst) | should | throw(AssociationError)
     (LoanRequest, an_account, 123,
      'I am not an analyst') | should | throw(AssociationError)
     (LoanRequest, an_account, 123,
      an_analyst) | should_not | throw(AssociationError)
コード例 #9
0
 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)
コード例 #10
0
 def setUp(self):
     self.a_credit_analyst_decorator = CreditAnalystDecorator('12345-6')
     #test doubles won't work given type checking rules, using classic
     self.a_person = Person()
     self.an_account = BankAccountDecorator('1234567-8')
コード例 #11
0
 def setUp(self):
     self.a_person = Person()
     self.a_transformation = Transformation(self.a_person, self.a_person)
コード例 #12
0
 def it_checks_a_rule(self):
     a_person = Person()
     RuleManager.get_instance().check_rule('should_be_instance_of_person', a_person) |should| be(True)
     RuleManager.get_instance().check_rule('should_be_instance_of_machine', a_person) |should| be(False)
     (RuleManager.get_instance().check_rule, 'wrong rule...', a_person) |should| throw(AttributeError)
コード例 #13
0
 def setUp(self):
     self.a_person = Person()
     self.rule_checker = RuleChecker()
コード例 #14
0
 def it_checks_source_and_destination(self):
     a_node = Person()
     non_node = "I am not a Node"
     (Movement, a_node, a_node) | should_not | throw(ContractError)
     (Movement, non_node, a_node) | should | throw(ContractError)
     (Movement, a_node, non_node) | should | throw(ContractError)
コード例 #15
0
 def setUp(self):
     self.an_employee_decorator = EmployeeDecorator()
     self.an_attendant_decorator = AttendantDecorator()
     self.an_attendant = Person()
コード例 #16
0
 def self_decorate(self):
     self.a_person = Person()
     self.decorate(self.a_person)
コード例 #17
0
def given_i_am_a_registered_credit_analyst(step):
    world.a_person = Person()
    an_employee_decorator = EmployeeDecorator()
    an_employee_decorator.decorate(world.a_person)
    world.credit_analyst = CreditAnalystDecorator('09876-5')
    world.credit_analyst.decorate(world.a_person)
コード例 #18
0
 def setUp(self):
     self.an_employee_decorator = EmployeeDecorator()
     #test doubles won't work given type checking rules, using classic
     self.a_person = Person()
コード例 #19
0
 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)
コード例 #20
0
 def setUp(self):
     #@operator was created to typify Node/Person and Node/Machine business
     #decorators' methods, however, it is used directly on a person object here
     #to make it easier to understand its use.
     self.a_person = Person()
コード例 #21
0
 def setUp(self):
     self.an_client_decorator = ClientDecorator()
     self.an_client = Person()
コード例 #22
0
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)


#############################################################