Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 90 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ pytest-xdist==3.8.0 \
pytest-forked==1.6.0 \
--hash=sha256:4dafd46a9a600f65d822b8f605133ecf5b3e1941ebb3588e943b4e3eb71a5a3f \
--hash=sha256:810958f66a91afb1a1e2ae83089d8dc1cd2437ac96b12963042fbb9fb4d16af0
freezegun==1.5.3 \
--hash=sha256:1ce20ee4be61349ba52c3af64f5eaba8d08ff51acfcf1b3ea671f03e54c818f1 \
--hash=sha256:d7c6204e33a50affd7c7aa284f4f92e04e96f72d63313b89ceaaf60d9c64bc5e
responses==0.25.8 \
--hash=sha256:0c710af92def29c8352ceadff0c3fe340ace27cf5af1bbe46fb71275bcd2831c \
--hash=sha256:9374d047a575c8f781b94454db5cab590b6029505f488d12899ddb10a4af1cf4
Expand Down Expand Up @@ -350,3 +347,93 @@ networkx==3.5 \
pydot==4.0.1 \
--hash=sha256:869c0efadd2708c0be1f916eb669f3d664ca684bc57ffb7ecc08e70d5e93fee6 \
--hash=sha256:c2148f681c4a33e08bf0e26a9e5f8e4099a82e0e2a068098f32ce86577364ad5
time-machine==2.19.0 \
--hash=sha256:00bee4bb950ac6a08d62af78e4da0cf2b4fc2abf0de2320d0431bf610db06e7c \
--hash=sha256:011954d951230a9f1079f22b39ed1a3a9abb50ee297dfb8c557c46351659d94d \
--hash=sha256:011d7859089263204dc5fdf83dce7388f986fe833c9381d6106b4edfda2ebd3e \
--hash=sha256:0390a1ea9fa7e9d772a39b7c61b34fdcca80eb9ffac339cc0441c6c714c81470 \
--hash=sha256:0b529e262df3b9c449f427385f4d98250828c879168c2e00eec844439f40b370 \
--hash=sha256:0fe81bae55b7aefc2c2a34eb552aa82e6c61a86b3353a3c70df79b9698cb02ca \
--hash=sha256:13ed8b34430f1de79905877f5600adffa626793ab4546a70a99fb72c6a3350d8 \
--hash=sha256:149072aff8e3690e14f4916103d898ea0d5d9c95531b6aa0995251c299533f7b \
--hash=sha256:16f5d81f650c0a4d117ab08036dc30b5f8b262e11a4a0becc458e7f1c011b228 \
--hash=sha256:206fcd6c9a6f00cac83db446ad1effc530a8cec244d2780af62db3a2d0a9871b \
--hash=sha256:2415b7495ec4364c8067071e964fbadfe746dd4cdb43983f2f0bd6ebed13315c \
--hash=sha256:2851825b524a988ee459c37c1c26bdfaa7eff78194efb2b562ea497a6f375b0a \
--hash=sha256:29e84b8682645b16eb6f9e8ec11c35324ad091841a11cf4fc3fc7f6119094c89 \
--hash=sha256:2eaa1c675d500dc3ccae19e9fb1feff84458a68c132bbea47a80cc3dd2df7072 \
--hash=sha256:304315023999cd401ff02698870932b893369e1cfeb2248d09f6490507a92e97 \
--hash=sha256:31cb43c8fd2d961f31bed0ff4e0026964d2b35e5de9e0fabbfecf756906d3612 \
--hash=sha256:39733ef844e2984620ec9382a42d00cccc4757d75a5dd572be8c2572e86e50b9 \
--hash=sha256:3ae0a8b869574301ec5637e32c270c7384cca5cd6e230f07af9d29271a7fa293 \
--hash=sha256:426aba552f7af9604adad9ef570c859af7c1081d878db78089fac159cd911b0a \
--hash=sha256:46f1c945934ce3d6b4f388b8e581fce7f87ec891ea90d7128e19520e434f96f0 \
--hash=sha256:4a11f1c0e0d06023dc01614c964e256138913551d3ae6dca5148f79081156336 \
--hash=sha256:4bb5bd43b1bdfac3007b920b51d8e761f024ed465cfeec63ac4296922a4ec428 \
--hash=sha256:536bd1ac31ab06a1522e7bf287602188f502dc19d122b1502c4f60b1e8efac79 \
--hash=sha256:554e4317de90e2f7605ff80d153c8bb56b38c0d0c0279feb17e799521e987b8c \
--hash=sha256:56f26ab9f0201c453d18fe76bb7d1cf05fe58c1b9d9cb0c7d243d05132e01292 \
--hash=sha256:57a235a6307c54df50e69f1906e2f199e47da91bde4b886ee05aff57fe4b6bf6 \
--hash=sha256:5e172866753e6041d3b29f3037dc47c20525176a494a71bbd0998dfdc4f11f2f \
--hash=sha256:5ee91664880434d98e41585c3446dac7180ec408c786347451ddfca110d19296 \
--hash=sha256:60c46ab527bf2fa144b530f639cc9e12803524c9e1f111dc8c8f493bb6586eeb \
--hash=sha256:645699616ec14e147094f601e6ab9553ff6cea37fad9c42720a6d7ed04bcd5dc \
--hash=sha256:6567a5ec5538ed550539ac29be11b3cb36af1f9894e2a72940cba0292cc7c3c9 \
--hash=sha256:67772c7197a3a712d1b970ed545c6e98db73524bd90e245fd3c8fa7ad7630768 \
--hash=sha256:68d32b09ecfd7fef59255c091e8e7c24dd117f882c4880b5c7ab8c5c32a98f89 \
--hash=sha256:6ba0303e9cc9f7f947e344f501e26bedfb68fab521e3c2729d370f4f332d2d55 \
--hash=sha256:6c806cf3c1185baa1d807b7f51bed0db7a6506832c961d5d1b4c94c775749bc0 \
--hash=sha256:714c40b2c90d1c57cc403382d5a9cf16e504cb525bfe9650095317da3c3d62b5 \
--hash=sha256:7253791b8d7e7399fbeed7a8193cb01bc004242864306288797056badbdaf80b \
--hash=sha256:72bf66cd19e27ffd26516b9cbe676d50c2e0b026153289765dfe0cf406708128 \
--hash=sha256:72dbd4cbc3d96dec9dd281ddfbb513982102776b63e4e039f83afb244802a9e5 \
--hash=sha256:77f9bb0b86758d1f2d9352642c874946ad5815df53ef4ca22eb9d532179fe50d \
--hash=sha256:7837ef3fd5911eb9b480909bb93d922737b6bdecea99dfcedb0a03807de9b2d3 \
--hash=sha256:7887e85275c4975fe54df03dcdd5f38bd36be973adc68a8c77e17441c3b443d6 \
--hash=sha256:7c5065a8b3f2bbb449422c66ef71d114d3f909c276a6469642ecfffb6a0fcd29 \
--hash=sha256:7e1c4e578cdd69b3531d8dd3fbcb92a0cd879dadb912ee37af99c3a9e3c0d285 \
--hash=sha256:82e9ffe8dfff07b0d810a2ad015a82cd78c6a237f6c7cf185fa7f747a3256f8a \
--hash=sha256:85bb7ed440fccf6f6d0c8f7d68d849e7c3d1f771d5e0b2cdf871fa6561da569f \
--hash=sha256:8e20a6d8d6e23174bd7e931e134d9610b136db460b249d07e84ecdad029ec352 \
--hash=sha256:8e9c6363893e7f52c226afbebb23e825259222d100e67dfd24c8a6d35f1a1907 \
--hash=sha256:9199246e31cdc810e5d89cb71d09144c4d745960fdb0824da4994d152aca3303 \
--hash=sha256:9247c4bb9bbd3ff584ef4efbdec8efd9f37aa08bcfc4728bde1e489c2cb445bd \
--hash=sha256:95afc9bc65228b27be80c2756799c20b8eb97c4ef382a9b762b6d7888bc84099 \
--hash=sha256:9765d4f003f263ea8bfd90d2d15447ca4b3dfa181922cf6cf808923b02ac180a \
--hash=sha256:9f02199490906582302ce09edd32394fb393271674c75d7aa76c7a3245f16003 \
--hash=sha256:a3b12028af1cdc09ccd595be2168b7b26f206c1e190090b048598fbe278beb8e \
--hash=sha256:a3b8981f9c663b0906b05ab4d0ca211fae4b63b47c6ec26de5374fe56c836162 \
--hash=sha256:a430e4d0e0556f021a9c78e9b9f68e5e8910bdace4aa34ed4d1a73e239ed9384 \
--hash=sha256:a62fd1ab380012c86f4c042010418ed45eb31604f4bf4453e17c9fa60bc56a29 \
--hash=sha256:b0f83308b29c7872006803f2e77318874eb84d0654f2afe0e48e3822e7a2e39b \
--hash=sha256:b25ec853a4530a5800731257f93206b12cbdee85ede964ebf8011b66086a7914 \
--hash=sha256:b30039dfd89855c12138095bee39c540b4633cbc3684580d684ef67a99a91587 \
--hash=sha256:b32daa965d13237536ea3afaa5ad61ade2b2d9314bc3a20196a0d2e1d7b57c6a \
--hash=sha256:b5169018ef47206997b46086ce01881cd3a4666fd2998c9d76a87858ca3e49e9 \
--hash=sha256:bdf481a75afc6bff3e520db594501975b652f7def21cd1de6aa971d35ba644e6 \
--hash=sha256:bf33016a1403c123373ffaeff25e26e69d63bf2c63b6163932efed94160db7ef \
--hash=sha256:c261f073086cf081d1443cbf7684148c662659d3d139d06b772bfe3fe7cc71a6 \
--hash=sha256:c85cf437dc3c07429456d8d6670ac90ecbd8241dcd0fbf03e8db2800576f91ff \
--hash=sha256:cc29a50a0257d8750b08056b66d7225daab47606832dea1a69e8b017323bf511 \
--hash=sha256:cd93996970e11c382b04d4937c3cd0b0167adeef14725ece35aae88d8a01733c \
--hash=sha256:ce0be294c209928563fcce1c587963e60ec803436cf1e181acd5bc1e425d554b \
--hash=sha256:d821c60efc08a97cc11e5482798e6fd5eba5c0f22a02db246b50895dbdc0de41 \
--hash=sha256:d8bb00b30ec9fe56d01e9812df1ffe39f331437cef9bfaebcc81c83f7f8f8ee2 \
--hash=sha256:d9238897e8ef54acdf59f5dff16f59ca0720e7c02d820c56b4397c11db5d3eb9 \
--hash=sha256:dbfc6b90c10f288594e1bf89a728a98cc0030791fd73541bbdc6b090aff83143 \
--hash=sha256:e17e3e089ac95f9a145ce07ff615e3c85674f7de36f2d92aaf588493a23ffb4b \
--hash=sha256:e1af66550fa4685434f00002808a525f176f1f92746646c0019bb86fbff48b27 \
--hash=sha256:e312c7d5d6bfffb96c6a7b39ff29e3046de100d7efaa3c01552654cfbd08f14c \
--hash=sha256:e35726c7ba625f844c13b1fc0d4f81f394eefaee1d3a094a9093251521f2ef15 \
--hash=sha256:e69e0b0f694728a00e72891ef8dd00c7542952cb1c87237db594b6b27d504a96 \
--hash=sha256:e77a414e9597988af53b2b2e67242c9d2f409769df0d264b6d06fda8ca3360d4 \
--hash=sha256:e84909af950e2448f4e2562ea5759c946248c99ab380d2b47d79b62bd76fa236 \
--hash=sha256:ed3732b83a893d1c7b8cabde762968b4dc5680ee0d305b3ecca9bb516f4e3862 \
--hash=sha256:f3589fee1ed0ab6ee424a55b0ea1ec694c4ba64cc26895bcd7d99f3d1bc6a28a \
--hash=sha256:f379c6f8a6575a8284592179cf528ce89373f060301323edcc44f1fa1d37be12 \
--hash=sha256:f583bbd0aa8ab4a7c45a684bf636d9e042d466e30bcbae1d13e7541e2cbe7207 \
--hash=sha256:f70f68379bd6f542ae6775cce9a4fa3dcc20bf7959c42eaef871c14469e18097 \
--hash=sha256:f8db99f6334432e9ffbf00c215caf2ae9773f17cec08304d77e9e90febc3507b \
--hash=sha256:fb051aec7b3b6e96a200d911c225901e6133ff3da11e470e24111a53bbc13637 \
--hash=sha256:fb4897c7a5120a4fd03f0670f332d83b7e55645886cd8864a71944c4c2e5b35b \
--hash=sha256:fe59909d95a2ef5e01ce3354fdea3908404c2932c2069f00f66dff6f27e9363e
6 changes: 3 additions & 3 deletions src/olympia/abuse/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import pytest
import responses
import time_machine
from celery.exceptions import Retry
from freezegun import freeze_time

from olympia import amo
from olympia.activity.models import ActivityLog
Expand Down Expand Up @@ -194,7 +194,7 @@ def _high_abuse_reports_setup(field):
return not_flagged, flagged


@freeze_time('2023-06-26 11:00')
@time_machine.travel('2023-06-26 11:00', tick=False)
@pytest.mark.django_db
def test_flag_high_abuse_reports_addons_according_to_review_tier():
set_config(amo.config_keys.EXTRA_REVIEW_TARGET_PER_DAY, '1')
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_flag_high_abuse_reports_addons_according_to_review_tier():
]


@freeze_time('2023-06-26 11:00')
@time_machine.travel('2023-06-26 11:00', tick=False)
@pytest.mark.django_db
def test_block_high_abuse_reports_addons_according_to_review_tier():
not_blocked, blocked = _high_abuse_reports_setup(
Expand Down
16 changes: 8 additions & 8 deletions src/olympia/abuse/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.urls import reverse
from django.utils.encoding import force_bytes

from freezegun import freeze_time
import time_machine
from pyquery import PyQuery as pq
from rest_framework.test import APIRequestFactory
from waffle.testutils import override_switch
Expand Down Expand Up @@ -3188,7 +3188,7 @@ def test_throttling_initial_email_form(self):
action=DECISION_ACTIONS.AMO_BAN_USER, addon=None, user=target
)
self.abuse_report.update(guid=None, user=target)
with freeze_time() as frozen_time:
with time_machine.travel(datetime.now(), tick=False) as frozen_time:
for _x in range(0, 20):
self._add_fake_throttling_action(
view_class=AbuseAppealEmailForm,
Expand All @@ -3209,7 +3209,7 @@ def test_throttling_initial_email_form(self):
assert doc('ul.errorlist').text() == expected_error_message

# Advance 23 hours, still blocked for that IP.
frozen_time.tick(delta=timedelta(hours=21))
frozen_time.shift(delta=timedelta(hours=21))
assert (
expected_error_message
in response.context_data['appeal_email_form'].non_field_errors()
Expand All @@ -3218,7 +3218,7 @@ def test_throttling_initial_email_form(self):
assert doc('ul.errorlist').text() == expected_error_message

# Advance one day to be able to submit again with the same IP.
frozen_time.tick(delta=timedelta(hours=24, seconds=1))
frozen_time.shift(delta=timedelta(hours=24, seconds=1))
response = self.client.post(
self.author_appeal_url,
{'email': target.email},
Expand All @@ -3243,7 +3243,7 @@ def test_throttling_doesnt_reveal_validation_state_fields(self):
action=DECISION_ACTIONS.AMO_BAN_USER, addon=None, user=target
)
self.abuse_report.update(guid=None, user=target)
with freeze_time():
with time_machine.travel(datetime.now(), tick=False):
for _x in range(0, 20):
self._add_fake_throttling_action(
view_class=AbuseAppealEmailForm,
Expand Down Expand Up @@ -3274,7 +3274,7 @@ def test_throttling_appeal_form(self):
user = user_factory()
self.addon.authors.add(user)
self.client.force_login(user)
with freeze_time() as frozen_time:
with time_machine.travel(datetime.now(), tick=False) as frozen_time:
for _x in range(0, 20):
self._add_fake_throttling_action(
view_class=AbuseAppealForm,
Expand All @@ -3296,7 +3296,7 @@ def test_throttling_appeal_form(self):
assert not doc('#appeal-thank-you')

# Advance 23 hours, still blocked for that IP.
frozen_time.tick(delta=timedelta(hours=23))
frozen_time.shift(delta=timedelta(hours=23))
assert (
expected_error_message
in response.context_data['appeal_form'].non_field_errors()
Expand All @@ -3306,7 +3306,7 @@ def test_throttling_appeal_form(self):
assert not doc('#appeal-thank-you')

# Advance one day to be able to submit again with the same IP.
frozen_time.tick(delta=timedelta(hours=24, seconds=1))
frozen_time.shift(delta=timedelta(hours=24, seconds=1))
response = self.client.post(
self.author_appeal_url,
{'reason': 'I dont like this'},
Expand Down
8 changes: 4 additions & 4 deletions src/olympia/accounts/tests/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.test.utils import override_settings

import pytest
from freezegun import freeze_time
import time_machine

from olympia.accounts import verify
from olympia.amo.tests import TestCase
Expand Down Expand Up @@ -278,7 +278,7 @@ def test_session_access_token_expiry_okay(self):
self.get_fxa_token_mock.assert_not_called()
assert request.session['fxa_access_token_expiry'] == tomorrow

@freeze_time()
@time_machine.travel(datetime.now(), tick=False)
def test_refresh_success(self):
request = self.get_request()

Expand All @@ -299,7 +299,7 @@ def test_refresh_success(self):
== (self.get_fxa_token_mock.return_value['access_token_expiry'])
)

@freeze_time()
@time_machine.travel(datetime.now(), tick=False)
def test_refresh_fail(self):
yesterday = (datetime.now() - timedelta(days=1)).timestamp()
request = self.get_request(yesterday)
Expand All @@ -313,7 +313,7 @@ def test_refresh_fail(self):
# i.e. it's still expired
assert request.session['fxa_access_token_expiry'] == yesterday

@freeze_time()
@time_machine.travel(datetime.now(), tick=False)
def test_refresh_token_missing(self):
request = self.get_request()
del request.session['fxa_refresh_token']
Expand Down
10 changes: 5 additions & 5 deletions src/olympia/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from django.urls import reverse
from django.utils.encoding import force_str

import freezegun
import jwt
import responses
import time_machine
from rest_framework import exceptions
from rest_framework.settings import api_settings
from rest_framework.test import APIClient, APIRequestFactory
Expand Down Expand Up @@ -2411,7 +2411,7 @@ def test_post(self):
with (
mock.patch(f'{class_path}.get_jwt_payload') as get_jwt_mock,
mock.patch(f'{class_path}.process_event') as process_event_mock,
freezegun.freeze_time(),
time_machine.travel(datetime.now(), tick=False),
):
get_jwt_mock.return_value = self.FXA_EVENT
response = self.client.post(url)
Expand All @@ -2424,7 +2424,7 @@ def test_post(self):

@mock.patch('olympia.accounts.views.primary_email_change_event.delay')
def test_process_event_email_change(self, event_mock):
with freezegun.freeze_time():
with time_machine.travel(datetime.now(), tick=False):
FxaNotificationView().process_event(
self.FXA_ID,
FxaNotificationView.FXA_PROFILE_CHANGE_EVENT,
Expand All @@ -2440,7 +2440,7 @@ def test_process_event_email_change_integration(self):
fxa_id=self.FXA_ID,
email_changed=datetime(2017, 10, 11),
)
with freezegun.freeze_time():
with time_machine.travel(datetime.now(), tick=False):
FxaNotificationView().process_event(
self.FXA_ID,
FxaNotificationView.FXA_PROFILE_CHANGE_EVENT,
Expand All @@ -2453,7 +2453,7 @@ def test_process_event_email_change_integration(self):

@mock.patch('olympia.accounts.views.delete_user_event.delay')
def test_process_event_delete(self, event_mock):
with freezegun.freeze_time():
with time_machine.travel(datetime.now(), tick=False):
FxaNotificationView().process_event(
self.FXA_ID,
FxaNotificationView.FXA_DELETE_EVENT,
Expand Down
8 changes: 4 additions & 4 deletions src/olympia/addons/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.core.management.base import CommandError

import pytest
from freezegun import freeze_time
import time_machine

from olympia import amo
from olympia.abuse.models import AbuseReport
Expand Down Expand Up @@ -61,7 +61,7 @@ def _subtask_wrapper(*args, **kwargs):
original_function.subtask = original_function_subtask


@freeze_time('2019-04-01')
@time_machine.travel('2019-04-01', tick=False)
@pytest.mark.django_db
def test_process_addons_limit_addons():
user_factory(id=settings.TASK_USER_ID)
Expand Down Expand Up @@ -369,7 +369,7 @@ def test_basic(self, bump_addon_version_mock):
file_kw = {'filename': 'webextension.xpi', 'is_signed': True}
user_factory(id=settings.TASK_USER_ID)

with freeze_time('2019-04-01'):
with time_machine.travel('2019-04-01', tick=False):
addon_with_history = addon_factory(file_kw=file_kw)
# Create a few more versions for this add-on to test that we only
# re-sign current versions
Expand All @@ -389,7 +389,7 @@ def test_basic(self, bump_addon_version_mock):
addon_factory(disabled_by_user=True, file_kw=file_kw)

# Don't resign add-ons created after April 4th 2019
with freeze_time('2019-05-01'):
with time_machine.travel('2019-05-01', tick=False):
addon_factory(file_kw=file_kw)
addon_factory(type=amo.ADDON_STATICTHEME, file_kw=file_kw)

Expand Down
8 changes: 4 additions & 4 deletions src/olympia/addons/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings

import pytest
from freezegun import freeze_time
import time_machine
from PIL import Image
from waffle.testutils import override_switch

Expand Down Expand Up @@ -253,7 +253,7 @@ def test_update_addon_hotness():
assert addon2.hotness == 0


@freeze_time('2023-05-15 11:00')
@time_machine.travel('2023-05-15 11:00', tick=False)
@pytest.mark.django_db
def test_flag_high_hotness_according_to_review_tier():
user_factory(pk=settings.TASK_USER_ID)
Expand Down Expand Up @@ -397,7 +397,7 @@ def test_flag_high_hotness_according_to_review_tier():
]


@freeze_time('2023-05-15 11:00')
@time_machine.travel('2023-05-15 11:00', tick=False)
@pytest.mark.django_db
def test_flag_high_hotness_according_to_review_tier_threshold_check(
django_assert_num_queries,
Expand Down Expand Up @@ -452,7 +452,7 @@ def test_flag_high_hotness_according_to_review_tier_threshold_check(
)


@freeze_time('2023-05-15 11:00')
@time_machine.travel('2023-05-15 11:00', tick=False)
@pytest.mark.django_db
def test_flag_high_hotness_according_to_review_tier_threshold_check_negative():
user_factory(pk=settings.TASK_USER_ID)
Expand Down
Loading
Loading