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()
class BankAccountDecoratorSpec(unittest.TestCase):

    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 it_decorates_a_machine(self):
        #should work
        self.a_bank_account_decorator.decorate(self.a_machine)
        self.a_bank_account_decorator.decorated |should| be(self.a_machine)
        self.a_bank_account_decorator.decorated |should| have(1).decorators

    def it_registers_a_credit(self):
        self.a_bank_account_decorator.balance = 100
        self.a_bank_account_decorator.register_credit(50)
        self.a_bank_account_decorator.balance |should| equal_to(150)

    def it_sends_a_message_to_the_account_holder(self):
        message = 'This is a message'
        self.a_bank_account_decorator.send_message_to_account_holder(message) |should| equal_to(message)

    def it_check_the_client(self):
        #should work
        self.a_client |should| have(1).decorators
        self.a_bank_account_decorator.client |should| be(self.a_client)

    def it_realize_a_banking(self):
        self.a_bank_account_decorator.decorate(self.a_machine)
        self.a_bank_account_decorator.deposit(100)
        self.a_bank_account_decorator.draw(25)
        self.a_bank_account_decorator.average_credit |should| be(75)
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 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 setUp(self):
     # set the rule base
     RuleManager.rule_base = BankSystemRuleBase()
     #
     self.a_credit_analyst_decorator = CreditAnalystDecorator("12345-6")
     # test doubles won't work given type checking rules, using classic
     self.a_person = Person()
     self.a_client = Person()
     a_client_decorator = ClientDecorator()
     a_client_decorator.decorate(self.a_client)
     self.an_account = BankAccountDecorator(self.a_client, "1234567-8")
 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)
Beispiel #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)
 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)
class ClientDecoratorsSpec(unittest.TestCase):
    def setUp(self):
        self.an_client_decorator = ClientDecorator()
        self.an_client = Person()

    def it_decorates_a_person(self):
        #should work
        self.an_client_decorator.decorate(self.an_client)
        self.an_client_decorator.decorated | should | be(self.an_client)
        self.an_client | should | have(1).decorators

    def it_generates_a_register(self):
        self.an_client_decorator.generate_register('1234 5 - 6')
        self.an_client_decorator.register | should | equal_to('1234 5 - 6')
class ClientDecoratorsSpec(unittest.TestCase):

    def setUp(self):
        self.an_client_decorator = ClientDecorator()
        self.an_client = Person()

    def it_decorates_a_person(self):
        #should work
        self.an_client_decorator.decorate(self.an_client)
        self.an_client_decorator.decorated |should| be(self.an_client)
        self.an_client |should| have(1).decorators

    def it_generates_a_register(self):
        self.an_client_decorator.generate_register('1234 5 - 6')
        self.an_client_decorator.register |should| equal_to('1234 5 - 6')
 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)
 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)
 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)
 def setUp(self):
     self.an_client_decorator = ClientDecorator()
     self.an_client = Person()
 def setUp(self):
     self.an_client_decorator = ClientDecorator()
     self.an_client = Person()