Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

corporate: Add BillingUserCounts dataclass for billable user counts.

Lauryn Menardb6acada0505f
diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py
index b47c19f5e13..82f305ca09c 100644
--- a/analytics/tests/test_counts.py
+++ b/analytics/tests/test_counts.py
@@ -35,6 +35,7 @@ from analytics.models import (
UserCount,
installation_epoch,
)
+from corporate.lib.stripe import BillingUserCounts
from zerver.actions.create_realm import do_create_realm
from zerver.actions.create_user import (
do_activate_mirror_dummy_user,
@@ -1487,8 +1488,8 @@ class TestLoggingCountStats(AnalyticsTestCase):
mock.patch("zilencer.views.send_android_push_notification", return_value=1),
mock.patch("zilencer.views.send_apple_push_notification", return_value=1),
mock.patch(
- "corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteServerBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zilencer.views", level="INFO"),
):
@@ -1550,8 +1551,8 @@ class TestLoggingCountStats(AnalyticsTestCase):
mock.patch("zilencer.views.send_android_push_notification", return_value=1),
mock.patch("zilencer.views.send_apple_push_notification", return_value=1),
mock.patch(
- "corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteServerBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zilencer.views", level="INFO"),
):
@@ -1612,8 +1613,8 @@ class TestLoggingCountStats(AnalyticsTestCase):
mock.patch("zilencer.views.send_android_push_notification", return_value=1),
mock.patch("zilencer.views.send_apple_push_notification", return_value=1),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zilencer.views", level="INFO"),
):
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index bb13cf17358..f63f09e97ea 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -553,6 +553,12 @@ class EventStatusRequest:
stripe_invoice_id: str | None
+@dataclass
+class BillingUserCounts:
+ workplace_users: int
+ non_workplace_users: int
+
+
class SupportType(Enum):
approve_sponsorship = 1
update_sponsorship_status = 2
@@ -715,7 +721,9 @@ class BillingSession(ABC):
pass
@abstractmethod
- def current_count_for_billed_licenses(self, event_time: datetime | None = None) -> int:
+ def current_counts_for_billed_users(
+ self, event_time: datetime | None = None
+ ) -> BillingUserCounts:
pass
@abstractmethod
@@ -1762,7 +1770,7 @@ class BillingSession(ABC):
return self.create_stripe_invoice_and_charge(updated_metadata)
def stale_seat_count_check(self, request_seat_count: int, tier: int) -> int:
- current_seat_count = self.current_count_for_billed_licenses()
+ current_seat_count = self.current_counts_for_billed_users().workplace_users
minimum_seat_count = self.min_licenses_for_plan(tier)
if request_seat_count == minimum_seat_count and current_seat_count < minimum_seat_count:
# Continue to use the minimum licenses for the plan tier.
@@ -2291,7 +2299,7 @@ class BillingSession(ABC):
if plan.automanage_licenses:
return
- if self.current_count_for_billed_licenses() > renewal_license_count:
+ if self.current_counts_for_billed_users().workplace_users > renewal_license_count:
raise BillingError(
f"Customer has not manually updated plan for current license count: {plan.customer!s}"
)
@@ -2565,7 +2573,7 @@ class BillingSession(ABC):
licenses_at_next_renewal = last_ledger_entry.licenses_at_next_renewal
assert licenses_at_next_renewal is not None
min_licenses_for_plan = self.min_licenses_for_plan(plan.tier)
- seat_count = self.current_count_for_billed_licenses()
+ seat_count = self.current_counts_for_billed_users().workplace_users
using_min_licenses_for_plan = (
min_licenses_for_plan == licenses_at_next_renewal
and licenses_at_next_renewal > seat_count
@@ -2843,7 +2851,7 @@ class BillingSession(ABC):
if setup_payment_by_invoice:
initial_upgrade_request.manual_license_management = True
- seat_count = self.current_count_for_billed_licenses()
+ seat_count = self.current_counts_for_billed_users().workplace_users
using_min_licenses_for_plan = min_licenses_for_plan > seat_count
if using_min_licenses_for_plan:
seat_count = min_licenses_for_plan
@@ -3114,7 +3122,7 @@ class BillingSession(ABC):
validate_licenses(
plan.charge_automatically,
licenses,
- self.current_count_for_billed_licenses(),
+ self.current_counts_for_billed_users().workplace_users,
plan.customer.exempt_from_license_number_check,
self.min_licenses_for_plan(plan.tier),
)
@@ -3150,7 +3158,7 @@ class BillingSession(ABC):
validate_licenses(
plan.charge_automatically,
licenses_at_next_renewal,
- self.current_count_for_billed_licenses(),
+ self.current_counts_for_billed_users().workplace_users,
plan.customer.exempt_from_license_number_check,
self.min_licenses_for_plan(plan.tier, is_plan_free_trial_with_invoice_payment),
)
@@ -3877,7 +3885,7 @@ class BillingSession(ABC):
) -> None:
if licenses is not None:
if not plan.customer.exempt_from_license_number_check:
- assert self.current_count_for_billed_licenses() <= licenses
+ assert self.current_counts_for_billed_users().workplace_users <= licenses
assert licenses > plan.licenses()
LicenseLedger.objects.create(
plan=plan,
@@ -3911,7 +3919,7 @@ class BillingSession(ABC):
if licenses is not None and customer.exempt_from_license_number_check:
return licenses
- current_licenses_count = self.current_count_for_billed_licenses(event_time)
+ current_licenses_count = self.current_counts_for_billed_users(event_time).workplace_users
min_licenses_for_plan = self.min_licenses_for_plan(tier)
if customer.exempt_from_license_number_check: # nocoverage
billed_licenses = current_licenses_count
@@ -4218,8 +4226,11 @@ class RealmBillingSession(BillingSession):
return self.user.delivery_email
@override
- def current_count_for_billed_licenses(self, event_time: datetime | None = None) -> int:
- return get_latest_seat_count(self.realm)
+ def current_counts_for_billed_users(
+ self, event_time: datetime | None = None
+ ) -> BillingUserCounts:
+ workplace_users = get_latest_seat_count(self.realm)
+ return BillingUserCounts(workplace_users, non_workplace_users=0)
@override
def get_audit_log_event(self, event_type: BillingSessionEventType) -> int:
@@ -4579,13 +4590,18 @@ class RemoteRealmBillingSession(BillingSession):
return self.remote_billing_user.email
@override
- def current_count_for_billed_licenses(self, event_time: datetime | None = None) -> int:
+ def current_counts_for_billed_users(
+ self, event_time: datetime | None = None
+ ) -> BillingUserCounts:
if has_stale_audit_log(self.remote_realm.server):
raise MissingDataError
remote_realm_counts = get_remote_realm_guest_and_non_guest_count(
self.remote_realm, event_time
)
- return remote_realm_counts.non_guest_user_count + remote_realm_counts.guest_user_count
+ workplace_users = (
+ remote_realm_counts.non_guest_user_count + remote_realm_counts.guest_user_count
+ )
+ return BillingUserCounts(workplace_users, non_workplace_users=0)
def missing_data_error_page(self, request: HttpRequest) -> HttpResponse: # nocoverage
# The RemoteRealm error page code path should not really be
@@ -5022,13 +5038,18 @@ class RemoteServerBillingSession(BillingSession):
return self.remote_billing_user.email
@override
- def current_count_for_billed_licenses(self, event_time: datetime | None = None) -> int:
+ def current_counts_for_billed_users(
+ self, event_time: datetime | None = None
+ ) -> BillingUserCounts:
if has_stale_audit_log(self.remote_server):
raise MissingDataError
remote_server_counts = get_remote_server_guest_and_non_guest_count(
self.remote_server.id, event_time
)
- return remote_server_counts.non_guest_user_count + remote_server_counts.guest_user_count
+ workplace_users = (
+ remote_server_counts.non_guest_user_count + remote_server_counts.guest_user_count
+ )
+ return BillingUserCounts(workplace_users, non_workplace_users=0)
def missing_data_error_page(self, request: HttpRequest) -> HttpResponse: # nocoverage
# The remedy for a RemoteZulipServer login is usually
@@ -5981,7 +6002,9 @@ def get_push_status_for_remote_request(
user_count: int | None = None
if current_plan is None:
try:
- user_count = user_count_billing_session.current_count_for_billed_licenses()
+ user_count = (
+ user_count_billing_session.current_counts_for_billed_users().workplace_users
+ )
except MissingDataError:
return PushNotificationsEnabledStatus(
can_push=False,
@@ -6014,7 +6037,7 @@ def get_push_status_for_remote_request(
)
try:
- user_count = user_count_billing_session.current_count_for_billed_licenses()
+ user_count = user_count_billing_session.current_counts_for_billed_users().workplace_users
except MissingDataError:
user_count = None
diff --git a/corporate/lib/support.py b/corporate/lib/support.py
index 196f3a216e9..405b1791203 100644
--- a/corporate/lib/support.py
+++ b/corporate/lib/support.py
@@ -329,7 +329,9 @@ def get_plan_data_for_support_view(
plan_data.licenses_used = None
elif user_count is None:
try:
- plan_data.licenses_used = billing_session.current_count_for_billed_licenses()
+ plan_data.licenses_used = (
+ billing_session.current_counts_for_billed_users().workplace_users
+ )
except MissingDataError: # nocoverage
plan_data.warning += USER_DATA_STALE_WARNING
plan_data.licenses_used = None
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 0c2cdb3c804..ceb0697726d 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -37,6 +37,7 @@ from corporate.lib.stripe import (
BillingError,
BillingSessionAuditLogEventError,
BillingSessionEventType,
+ BillingUserCounts,
InitialUpgradeRequest,
InvalidBillingScheduleError,
InvalidTierError,
@@ -6186,8 +6187,8 @@ class BillingHelpersTest(ZulipTestCase):
billing_session.configure_fixed_price_plan(1200, None)
self.assertEqual(remote_realm.plan_type, RemoteRealm.PLAN_TYPE_SELF_MANAGED)
with mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=60,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(60, 0),
):
billing_session.initialize_prepaid_fixed_price_plan(
plan_tier=CustomerPlan.TIER_SELF_HOSTED_BASIC,
@@ -6269,8 +6270,8 @@ class BillingHelpersTest(ZulipTestCase):
billing_session.configure_fixed_price_plan(1200, None)
self.assertEqual(remote_server.plan_type, RemoteRealm.PLAN_TYPE_SELF_MANAGED)
with mock.patch(
- "corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
- return_value=60,
+ "corporate.lib.stripe.RemoteServerBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(60, 0),
):
billing_session.initialize_prepaid_fixed_price_plan(
plan_tier=CustomerPlan.TIER_SELF_HOSTED_BASIC,
@@ -7095,7 +7096,7 @@ class TestRealmBillingSession(StripeTestCase):
class TestRemoteRealmBillingSession(StripeTestCase):
- def test_current_count_for_billed_licenses(self) -> None:
+ def test_current_counts_for_billed_users(self) -> None:
server_uuid = str(uuid.uuid4())
remote_server = RemoteZulipServer.objects.create(
uuid=server_uuid,
@@ -7115,13 +7116,13 @@ class TestRemoteRealmBillingSession(StripeTestCase):
# remote server never uploaded statistics. 'last_audit_log_update' is None.
with self.assertRaises(MissingDataError):
- billing_session.current_count_for_billed_licenses()
+ billing_session.current_counts_for_billed_users()
# Available statistics is stale.
remote_server.last_audit_log_update = timezone_now() - timedelta(days=5)
remote_server.save()
with self.assertRaises(MissingDataError):
- billing_session.current_count_for_billed_licenses()
+ billing_session.current_counts_for_billed_users()
# Available statistics is not stale.
event_time = timezone_now() - timedelta(days=1)
@@ -7165,7 +7166,9 @@ class TestRemoteRealmBillingSession(StripeTestCase):
remote_server.last_audit_log_update = timezone_now() - timedelta(days=1)
remote_server.save()
- self.assertEqual(billing_session.current_count_for_billed_licenses(), 70)
+ current_billed_user_counts = billing_session.current_counts_for_billed_users()
+ self.assertEqual(current_billed_user_counts.workplace_users, 70)
+ self.assertEqual(current_billed_user_counts.non_workplace_users, 0)
class TestRemoteServerBillingSession(StripeTestCase):
diff --git a/zerver/tests/test_e2ee_push_notifications.py b/zerver/tests/test_e2ee_push_notifications.py
index 8d4dc9240d3..b4e561337c5 100644
--- a/zerver/tests/test_e2ee_push_notifications.py
+++ b/zerver/tests/test_e2ee_push_notifications.py
@@ -11,6 +11,7 @@ from firebase_admin.messaging import UnregisteredError
from typing_extensions import override
from analytics.models import RealmCount
+from corporate.lib.stripe import BillingUserCounts
from zerver.actions.user_groups import check_add_user_group
from zerver.lib.avatar import absolute_avatar_url
from zerver.lib.devices import b64encode_token_id_int
@@ -465,8 +466,8 @@ class SendPushNotificationTest(E2EEPushNotificationTestCase):
self.mock_fcm() as mock_fcm_messaging,
self.mock_apns() as send_notification,
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as zerver_logger,
self.assertLogs("zilencer.lib.push_notifications", level="INFO") as zilencer_logger,
@@ -612,8 +613,8 @@ class SendPushNotificationTest(E2EEPushNotificationTestCase):
with (
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=100,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(100, 0),
),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as zerver_logger,
):
@@ -900,8 +901,8 @@ class RemovePushNotificationTest(E2EEPushNotificationTestCase):
self.mock_fcm() as mock_fcm_messaging,
self.mock_apns() as send_notification,
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as zerver_logger,
self.assertLogs("zilencer.lib.push_notifications", level="INFO"),
@@ -1137,8 +1138,8 @@ class SendTestPushNotificationTest(E2EEPushNotificationTestCase):
self.mock_fcm() as mock_fcm_messaging,
self.mock_apns() as send_notification,
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zilencer.lib.push_notifications", level="INFO"),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as zerver_logger,
@@ -1258,7 +1259,7 @@ class SendTestPushNotificationTest(E2EEPushNotificationTestCase):
registered_device_android.delete()
with mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
):
assert_error_response("No active registered push device", 400)
diff --git a/zerver/tests/test_handle_push_notification.py b/zerver/tests/test_handle_push_notification.py
index ed90ef8e278..567f2bb023c 100644
--- a/zerver/tests/test_handle_push_notification.py
+++ b/zerver/tests/test_handle_push_notification.py
@@ -10,6 +10,7 @@ from requests.models import PreparedRequest
from typing_extensions import override
from analytics.models import RealmCount
+from corporate.lib.stripe import BillingUserCounts
from zerver.actions.message_delete import do_delete_messages
from zerver.actions.message_edit import check_update_message
from zerver.actions.user_groups import add_subgroups_to_user_group, check_add_user_group
@@ -80,8 +81,8 @@ class HandlePushNotificationTest(PushNotificationTestCase):
),
self.mock_apns() as (_apns_context, send_notification),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as pn_logger,
self.assertLogs("zilencer.views", level="INFO") as views_logger,
@@ -176,8 +177,8 @@ class HandlePushNotificationTest(PushNotificationTestCase):
}
with (
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=100,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(100, 0),
) as mock_current_count,
self.assertLogs("zerver.lib.push_notifications", level="INFO") as pn_logger,
self.assertLogs("zilencer.views", level="INFO"),
@@ -201,7 +202,7 @@ class HandlePushNotificationTest(PushNotificationTestCase):
# This will put us within the allowed number of users to use push notifications
# for free, so the server will accept our next request.
- mock_current_count.return_value = 5
+ mock_current_count.return_value = BillingUserCounts(5, 0)
new_message_id = self.send_personal_message(
self.example_user("othello"), self.user_profile
@@ -248,8 +249,8 @@ class HandlePushNotificationTest(PushNotificationTestCase):
),
self.mock_apns() as (_apns_context, send_notification),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as pn_logger,
self.assertLogs("zilencer.views", level="INFO") as views_logger,
diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py
index a572bf5d260..141c9e42188 100644
--- a/zerver/tests/test_push_notifications.py
+++ b/zerver/tests/test_push_notifications.py
@@ -22,6 +22,7 @@ from requests.exceptions import ConnectionError
from typing_extensions import override
from analytics.models import RealmCount
+from corporate.lib.stripe import BillingUserCounts
from zerver.actions.message_flags import do_mark_stream_messages_as_read, do_update_message_flags
from zerver.actions.user_groups import check_add_user_group
from zerver.actions.user_settings import do_regenerate_api_key
@@ -595,8 +596,8 @@ class PushBouncerNotificationTest(BouncerTestCase):
mock.patch("zilencer.views.send_android_push_notification", return_value=1),
mock.patch("zilencer.views.send_apple_push_notification", return_value=1),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
self.assertLogs("zilencer.views", level="INFO"),
):
@@ -670,8 +671,8 @@ class PushBouncerNotificationTest(BouncerTestCase):
) as android_push,
mock.patch("zilencer.views.send_apple_push_notification", return_value=1) as apple_push,
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
time_machine.travel(time_sent, tick=False),
self.assertLogs("zilencer.views", level="INFO") as logger,
diff --git a/zerver/tests/test_zilencer_analytics.py b/zerver/tests/test_zilencer_analytics.py
index 79698a675d7..d710950bfe8 100644
--- a/zerver/tests/test_zilencer_analytics.py
+++ b/zerver/tests/test_zilencer_analytics.py
@@ -16,7 +16,7 @@ from typing_extensions import override
from analytics.lib.counts import CountStat, LoggingCountStat
from analytics.models import InstallationCount, RealmCount, UserCount
-from corporate.lib.stripe import RemoteRealmBillingSession
+from corporate.lib.stripe import BillingUserCounts, RemoteRealmBillingSession
from corporate.models.plans import CustomerPlan
from version import ZULIP_VERSION
from zerver.actions.create_realm import do_create_realm
@@ -1054,8 +1054,8 @@ class AnalyticsBouncerTest(BouncerTestCase):
"corporate.lib.stripe.RemoteRealmBillingSession.get_customer", return_value=None
) as m,
mock.patch(
- "corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteServerBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
):
send_server_data_to_push_bouncer(consider_usage_statistics=False)
@@ -1070,8 +1070,8 @@ class AnalyticsBouncerTest(BouncerTestCase):
"corporate.lib.stripe.RemoteRealmBillingSession.get_customer", return_value=None
) as m,
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=11,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(11, 0),
),
):
send_server_data_to_push_bouncer(consider_usage_statistics=False)
@@ -1104,8 +1104,8 @@ class AnalyticsBouncerTest(BouncerTestCase):
),
mock.patch("corporate.lib.stripe.get_current_plan_by_customer", return_value=None) as m,
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=11,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(11, 0),
),
):
send_server_data_to_push_bouncer(consider_usage_statistics=False)
@@ -1126,7 +1126,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
),
mock.patch("corporate.lib.stripe.get_current_plan_by_customer", return_value=None),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses"
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users"
) as m,
):
send_server_data_to_push_bouncer(consider_usage_statistics=False)
@@ -1154,8 +1154,8 @@ class AnalyticsBouncerTest(BouncerTestCase):
return_value=dummy_customer_plan,
),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=11,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(11, 0),
),
mock.patch(
"corporate.lib.stripe.RemoteRealmBillingSession.get_next_billing_cycle",
@@ -1187,7 +1187,7 @@ class AnalyticsBouncerTest(BouncerTestCase):
return_value=dummy_customer_plan,
),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
side_effect=MissingDataError,
),
mock.patch(
@@ -1220,8 +1220,8 @@ class AnalyticsBouncerTest(BouncerTestCase):
return_value=dummy_customer_plan,
),
mock.patch(
- "corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
- return_value=10,
+ "corporate.lib.stripe.RemoteRealmBillingSession.current_counts_for_billed_users",
+ return_value=BillingUserCounts(10, 0),
),
):
send_server_data_to_push_bouncer(consider_usage_statistics=False)