예제 #1
0
    def test_make_default_ach_user(self):
        """Makes a user ach account the default."""

        user = self.client.users.create({})

        FundingSources.get_user_ach_funding_source(user)
        source = FundingSources.get_user_ach_funding_source(user)

        default = self.client.funding_sources(source.token).make_default()

        verify_payment_card_response_model(self, default,
                                           {'is_default_account': True})
    def test_ach_find_success_user(self):
        """Tests successful find of an user ach funding source."""

        funding_source = FundingSources.get_user_ach_funding_source()

        found = self.client.funding_sources.ach.find(funding_source.token)

        verify_ach_response_model(self, found, funding_source.__dict__)
    def test_funding_sources_list_for_user_two(self):
        """Tests when two funding sources are returned."""

        ach_one = FundingSources.get_user_ach_funding_source(self.user)
        ach_two = FundingSources.get_user_ach_funding_source(self.user)

        results = self.client.funding_sources.list_for_user(self.user.token)

        self.assertEqual(len(results), 2,
                         'Unexpected number of funding sources returned')

        verify_one = FundingSources.get_funding_source_verify(ach_one)
        verify_two = FundingSources.get_funding_source_verify(ach_two)

        if results[0].token == ach_one.token:
            verify_funding_account_response_model(self, results[0], verify_one)
            verify_funding_account_response_model(self, results[1], verify_two)
        else:
            verify_funding_account_response_model(self, results[1], verify_one)
            verify_funding_account_response_model(self, results[0], verify_two)
    def test_funding_sources_list_for_user_one(self):
        """Tests when one funding source is returned."""

        ach = FundingSources.get_user_ach_funding_source(self.user)

        results = self.client.funding_sources.list_for_user(self.user.token)

        self.assertEqual(len(results), 1,
                         'Unexpected number of funding sources returned')

        verify = FundingSources.get_funding_source_verify(ach)

        verify_funding_account_response_model(self, results[0], verify)
    def test_ach_verification_amounts_user(self):
        """Retrieves the verification amounts for a user funding source."""

        funding_source = FundingSources.get_user_ach_funding_source()

        amounts = self.client.funding_sources.ach(
            funding_source.token).verification_amounts()

        with self.subTest(
                'First verification amount not within expected range'):
            self.assertTrue(0 < amounts.verify_amount1 < 1)

        with self.subTest(
                'Second verification amount not within expected range'):
            self.assertTrue(0 < amounts.verify_amount2 < 1)
    def test_ach_save_fail(self):
        """Tries to verify the ach account with incorrect verification amounts."""

        funding_source = FundingSources.get_user_ach_funding_source()

        amounts = self.client.funding_sources.ach(
            funding_source.token).verification_amounts()

        ach_verification = {
            "verify_amount1": amounts.verify_amount1 + 0.01,
            "verify_amount2": amounts.verify_amount2 + 0.01
        }

        with self.assertRaises(MarqetaError):
            self.client.funding_sources.ach.save(funding_source.token,
                                                 ach_verification)
    def test_ach_save_success(self):
        """Verifies the ach account with the correct verification amounts."""

        funding_source = FundingSources.get_user_ach_funding_source()

        amounts = self.client.funding_sources.ach(
            funding_source.token).verification_amounts()

        ach_verification = {
            "verify_amount1": amounts.verify_amount1,
            "verify_amount2": amounts.verify_amount2
        }

        result = self.client.funding_sources.ach.save(funding_source.token,
                                                      ach_verification)

        verify = self.get_funding_source_verify(funding_source)

        verify['verification_status'] = 'ACH_VERIFIED'
        verify['active'] = True

        verify_ach_response_model(self, result, verify)