stripe tests: Add back out-of-realm users.

This fixes a minor regression in a very recent
commit.

In 7ad5bea3e6 I was
a little too aggressive about deactivating users.
We do want a few users who are outside the realm,
just to prevent regressions where we fail to filter
on realm.  The likelihood of such regressions are
fairly low, but it would certainly be an ugly bug.
This commit is contained in:
Steve Howell 2020-05-18 23:59:15 +00:00 committed by showell
parent c70eb8b772
commit d526b08ea9
1 changed files with 9 additions and 2 deletions

View File

@ -241,8 +241,8 @@ class StripeTestCase(ZulipTestCase):
self.example_email('default_bot'), # bot
]
# Deactivate all users that aren't in our whitelist.
UserProfile.objects.exclude(email__in=active_emails).update(is_active=False)
# Deactivate all users in our realm that aren't in our whitelist.
UserProfile.objects.filter(realm_id=realm.id).exclude(email__in=active_emails).update(is_active=False)
# sanity check our 8 expected users are active
self.assertEqual(
@ -250,6 +250,13 @@ class StripeTestCase(ZulipTestCase):
8
)
# Make sure we have active users outside our realm (to make
# sure relevant queries restrict on realm).
self.assertEqual(
UserProfile.objects.exclude(realm=realm).filter(is_active=True).count(),
10
)
# Our seat count excludes our guest user and bot, and
# we want this to be predictable for certain tests with
# arithmetic calculations.