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 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 and_there_is_a_refused_loan_request_of_value_value_for_account_account_number(step, desired_value, account_number):
    # preparing the context
    # puts the process in the refusal path
    world.an_individual_credit_operation = Process("Individual Customer Credit Operation")
    template = LoanProcess()
    configurator = StateMachineConfigurator(template)
    configurator.configure(world.an_individual_credit_operation)
    world.an_individual_credit_operation.create_loan_request()
    world.an_individual_credit_operation.analyst_select_request()
    # directly creating a loan request
    world.credit_analyst.create_loan_request(world.account, int(desired_value))
    # forces the loan request approval and its transfer to the output_area
    world.credit_analyst.decorated.input_area[world.account.number].approved = False
    world.credit_analyst.decorated.transfer(world.account.number, "input", "output")
    world.credit_analyst.decorated.output_area | should | contain(world.account.number)
示例#4
0
def and_there_is_a_refused_loan_request_of_value_value_for_account_account_number(step, desired_value, account_number):
    #preparing the context
    #puts the process in the refusal path
    world.an_individual_credit_operation = Process('Individual Customer Credit Operation')
    template = LoanProcess()
    configurator = StateMachineConfigurator(template)
    configurator.configure(world.an_individual_credit_operation)
    world.an_individual_credit_operation.create_loan_request()
    world.an_individual_credit_operation.analyst_select_request()
    #directly creating a loan request
    world.credit_analyst.create_loan_request(world.account, int(desired_value))
    #forces the loan request approval and its transfer to the output_area
    world.credit_analyst.decorated.input_area[world.account.number].approved = False
    world.credit_analyst.decorated.transfer(world.account.number, 'input', 'output')
    world.credit_analyst.decorated.output_area |should| contain(world.account.number)
class StateMachineConfiguratorSpec(unittest.TestCase):
    '''An object configured by StateMachineConfigurator'''

    def setUp(self):
        self.door_wannabe = DoorWannabe()
        self.door = Door()
        self.configurator = StateMachineConfigurator(self.door)
        self.configurator.configure(self.door_wannabe)

    def it_responds_to_state_machine_events(self):
        self.door_wannabe |should| respond_to('open')
        self.door_wannabe |should| respond_to('crack')
        self.door_wannabe |should| respond_to('close')

    def it_changes_its_state_like_according_to_the_templating_machine(self):
        self.door_wannabe.open()
        self.door_wannabe.current_state() |should| equal_to('open')
        self.door_wannabe.crack |should| throw(InvalidTransition)
        self.door_wannabe.close()
        self.door_wannabe.current_state() |should| equal_to('closed')

    def it_runs_guard_when_an_event_occurs(self):
        self.door.locked = True
        self.door_wannabe.open |should| throw(GuardNotSatisfied)

    def it_runs_enter_and_exit_actions_at_state_change(self):
        self.door_wannabe.open()
        self.door.pass_light |should| be(True)
        self.door_wannabe.close()
        self.door.pass_light |should| be(False)

    def it_runs_event_actions(self):
        self.door |should_not| be_destroyed
        self.door_wannabe.crack()
        self.door |should| be_destroyed

    def it_can_get_rid_of_state_machine_stuff(self):
        self.configurator.deconfigure(self.door_wannabe)
        self.door_wannabe |should_not| respond_to('open')
        self.door_wannabe |should_not| respond_to('crack')
        self.door_wannabe |should_not| respond_to('close')

    def it_runs_action_from_a_reference_on_another_object(self):
        anyone = type('object', (), {})()
        anyone.transition = self.door.crack
        anyone.transition('own3d')
        self.door.boom_param |should| equal_to('own3d')
        self.door.current_state |should| equal_to('broken')
 def setUp(self):
     self.door_wannabe = DoorWannabe()
     self.door = Door()
     self.configurator = StateMachineConfigurator(self.door)
     self.configurator.configure(self.door_wannabe)
 def setUp(self):
     self.process = Process()
     template = LoanProcess()
     configurator = StateMachineConfigurator(template)
     configurator.configure(self.process)
 def setUp(self):
     self.process = Process()
     template = LoanProcess()
     configurator = StateMachineConfigurator(template)
     configurator.configure(self.process)