and test that joined_before_premium_release property works as expected
This commit is contained in:
Se Yeon Kim 2021-10-14 12:56:01 -05:00
Родитель 91da317598
Коммит ae6377c7f2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3F96D66EFEF597CC
4 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -32,3 +32,4 @@ PREMIUM_ENABLED=False
PREMIUM_PROD_ID=prod_IyCWnXUbkYjDgL
PREMIUM_PRICE_ID=price_1IMG7KKb9q6OnNsL15Hsn1HE
SUBSCRIPTIONS_WITH_UNLIMITED="monitor-unlimited,mozilla-one,guardian_vpn"
PREMIUM_RELEASE_DATE='2021-10-27 17:00:00+00:00'

Просмотреть файл

@ -158,9 +158,9 @@ class Profile(models.Model):
return sum(blocked['num_blocked'] for blocked in relay_addresses_blocked)
@property
def created_before_premium_release(self):
def joined_before_premium_release(self):
date_created = self.user.date_joined
return date_created < datetime(2021, 10, 27, 18, 00)
return date_created < datetime.fromisoformat(settings.PREMIUM_RELEASE_DATE)
def add_subdomain(self, subdomain):
if not self.has_premium:

Просмотреть файл

@ -511,6 +511,24 @@ class ProfileTest(TestCase):
profile = Profile.objects.get(user=social_account.user)
assert profile.display_name == None
@override_settings(PREMIUM_RELEASE_DATE='2021-10-27 17:00:00+00:00')
def test_user_joined_before_premium_release_returns_True(self):
user = baker.make(
User,
date_joined=datetime.now(timezone.utc)
)
profile = Profile.objects.get(user=user)
assert profile.joined_before_premium_release
@override_settings(PREMIUM_RELEASE_DATE='2021-10-27 17:00:00+00:00')
def test_user_joined_before_premium_release_returns_False(self):
user = baker.make(
User,
date_joined=datetime.fromisoformat('2021-10-28 17:00:00+00:00')
)
profile = Profile.objects.get(user=user)
assert profile.joined_before_premium_release is False
class DomainAddressTest(TestCase):
def setUp(self):

Просмотреть файл

@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import ipaddress
import os
from datetime import datetime, timezone
from decouple import config
import markus
@ -242,6 +243,7 @@ PREMIUM_PRICE_ID = config('PREMIUM_PRICE_ID', '', cast=str)
SUBSCRIPTIONS_WITH_UNLIMITED = config(
'SUBSCRIPTIONS_WITH_UNLIMITED', default=''
)
PREMIUM_RELEASE_DATE = config('PREMIUM_RELEASE_DATE', str(datetime.now(timezone.utc)), cast=str)
DOMAIN_REGISTRATION_MODAL = config('DOMAIN_REGISTRATION_MODAL', False, cast=bool)