def test_charge_with_token_should_return_false_exception_message_tuple_when_facades_generic_error_raised(
            self, create_customer):
        # setup
        adapter = MembershipStripeAdapter(self.membership)
        message = u'amessage'
        create_customer.side_effect = StripeFacade.GenericError(message)

        # action
        returned_value = adapter.charge_with_token(self.card_token)

        # assert
        self.assertTupleEqual((False, message,), returned_value)
    def test_charge_with_token_should_return_false_exception_message_tuple_when_facades_generic_error_raised(
            self, create_customer):
        # setup
        adapter = MembershipStripeAdapter(self.membership)
        message = u'amessage'
        create_customer.side_effect = StripeFacade.GenericError(message)

        # action
        returned_value = adapter.charge_with_token(self.card_token)

        # assert
        self.assertTupleEqual((
            False,
            message,
        ), returned_value)
    def test_charge_with_token_should_call_create_customer_when_memeberships_customer_id_is_none_the_call_charge_and_commit_changes_returning_true_none_tuple(
            self, create_customer, charge, commit_changes):
        # setup
        adapter = MembershipStripeAdapter(self.membership)

        # action
        returned_value = adapter.charge_with_token(self.card_token)

        # assert
        self.assertTupleEqual((self.card_token,), create_customer.call_args[0])
        self.assertTupleEqual((create_customer.return_value,),
            charge.call_args[0])
        self.assertTupleEqual((create_customer.return_value,),
            commit_changes.call_args[0])
        self.assertTupleEqual((True, None,), returned_value)
    def test_charge_with_token_should_call_create_customer_when_memeberships_customer_id_is_none_the_call_charge_and_commit_changes_returning_true_none_tuple(
            self, create_customer, charge, commit_changes):
        # setup
        adapter = MembershipStripeAdapter(self.membership)

        # action
        returned_value = adapter.charge_with_token(self.card_token)

        # assert
        self.assertTupleEqual((self.card_token, ),
                              create_customer.call_args[0])
        self.assertTupleEqual((create_customer.return_value, ),
                              charge.call_args[0])
        self.assertTupleEqual((create_customer.return_value, ),
                              commit_changes.call_args[0])
        self.assertTupleEqual((
            True,
            None,
        ), returned_value)