コード例 #1
0
    def test__attach_objects_post_save_hook(
        self, fileupload_retrieve_mock, account_retrieve_mock
    ):
        fake_account = deepcopy(FAKE_ACCOUNT)
        fake_account["settings"]["branding"]["icon"] = None
        account_retrieve_mock.return_value = fake_account

        Account.sync_from_stripe_data(fake_account)

        fileupload_retrieve_mock.assert_called_with(
            id=fake_account["settings"]["branding"]["logo"],
            api_key=djstripe_settings.STRIPE_SECRET_KEY,
            expand=[],
            stripe_account=fake_account["id"],
        )
コード例 #2
0
    def test_livemode_populates_correctly_for_testmode(
        self, fileupload_retrieve_mock, account_retrieve_mock, _account, is_platform
    ):
        fake_account = _account
        fake_account["settings"]["branding"]["icon"] = None
        account_retrieve_mock.return_value = fake_account

        platform_account = FAKE_PLATFORM_ACCOUNT.create()

        # Account.get_or_retrieve_for_api_key is called and since the passed in api_key doesn't have an owner acount,
        # key is refreshed and the current mocked _account is assigned as the owner account.
        # This essentially turns all these cases into Platform Account cases.
        # And that is why Account.get_or_retrieve_for_api_key is patched
        with patch.object(
            Account, "get_or_retrieve_for_api_key", return_value=platform_account
        ):

            account = Account.sync_from_stripe_data(
                fake_account, api_key=djstripe_settings.STRIPE_SECRET_KEY
            )
            assert account.djstripe_owner_account == platform_account

            if is_platform is True:
                assert account.livemode is None
            else:
                assert account.livemode is False
コード例 #3
0
    def test_get_stripe_dashboard_url(
        self, fileupload_retrieve_mock, account_retrieve_mock
    ):
        fake_account = deepcopy(FAKE_ACCOUNT)
        account = Account.sync_from_stripe_data(fake_account)

        self.assertEqual(
            account.get_stripe_dashboard_url(),
            f"https://dashboard.stripe.com/{account.id}/"
            f"{'test/' if not account.livemode else ''}dashboard",
        )
コード例 #4
0
    def test__str__null_settings_null_business_profile(
        self,
        fileupload_retrieve_mock,
        account_retrieve_mock,
    ):
        """Test that __str__ doesn't crash when settings and business_profile are NULL."""
        fake_account = deepcopy(FAKE_ACCOUNT)
        fake_account["settings"] = None
        fake_account["business_profile"] = None
        account_retrieve_mock.return_value = fake_account

        account = Account.sync_from_stripe_data(fake_account)
        assert str(account) == "<id=acct_1032D82eZvKYlo2C>"
コード例 #5
0
    def test_sync_from_stripe_data(
        self, fileupload_retrieve_mock, account_retrieve_mock
    ):
        fake_account = deepcopy(FAKE_ACCOUNT)
        account = Account.sync_from_stripe_data(fake_account)

        self.assertGreater(len(account.business_profile), 0)
        self.assertGreater(len(account.settings), 0)

        self.assertEqual(account.branding_icon.id, FAKE_FILEUPLOAD_ICON["id"])
        self.assertEqual(account.branding_logo.id, FAKE_FILEUPLOAD_LOGO["id"])

        self.assertEqual(account.settings["branding"]["icon"], account.branding_icon.id)
        self.assertEqual(account.settings["branding"]["logo"], account.branding_logo.id)

        self.assertNotEqual(account.branding_logo.id, account.branding_icon.id)

        self.assert_fks(account, expected_blank_fks={})

        self.assertEqual(account.business_url, "https://djstripe.com")
コード例 #6
0
 def test_branding_icon(self, fileupload_retrieve_mock, account_retrieve_mock):
     fake_account = deepcopy(FAKE_ACCOUNT)
     account = Account.sync_from_stripe_data(fake_account)
     self.assertEqual(
         fake_account["settings"]["branding"]["icon"], account.branding_icon.id
     )
コード例 #7
0
 def test_business_url(self, fileupload_retrieve_mock, account_retrieve_mock):
     fake_account = deepcopy(FAKE_ACCOUNT)
     account = Account.sync_from_stripe_data(fake_account)
     self.assertEqual(fake_account["business_profile"]["url"], account.business_url)
コード例 #8
0
 def test__find_owner_account(self, fileupload_retrieve_mock, account_retrieve_mock):
     fake_account = deepcopy(FAKE_ACCOUNT)
     account = Account.sync_from_stripe_data(fake_account)
     self.assertEqual(account.djstripe_owner_account.id, FAKE_PLATFORM_ACCOUNT["id"])
コード例 #9
0
 def test__find_owner_account(self, fileupload_retrieve_mock, account_retrieve_mock):
     fake_account = deepcopy(FAKE_ACCOUNT)
     account = Account.sync_from_stripe_data(fake_account)
     self.assertEqual(None, Account._find_owner_account(account))