Skip to content

Commit

Permalink
Fix warnings in develop-aplus tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelGusse authored and ihalaij1 committed May 28, 2024
1 parent 21fa00d commit 1604329
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
1 change: 0 additions & 1 deletion aplus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@
]
TIME_ZONE = 'EET'
USE_I18N = True
USE_L10N = True
USE_TZ = True
FORMAT_MODULE_PATH = 'aplus'
LOCALE_PATHS = (
Expand Down
4 changes: 2 additions & 2 deletions course/sis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"code": "123456",
"id": "123",
"instance": "summer-2022",
"starting_time": "2022-06-01",
"ending_time": "2022-08-20",
"starting_time": "2022-06-01T00:00:00+03:00",
"ending_time": "2022-08-20T00:00:00+03:00",
"teachers": [ "teacher-A", "testTeacher" ],
"participants": [ "123TEST", "333333", "555555" ],
},
Expand Down
5 changes: 3 additions & 2 deletions external_services/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ def verify_oauth_body_hash_and_signature(request, req_body_hash, lti_exercise=No

# check the OAuth timestamp. Do not allow old requests in order to prevent replay attacks.
try:
timestamp = datetime.datetime.utcfromtimestamp(int(req_oauth_params_dict.get('oauth_timestamp')))
timestamp = datetime.datetime.fromtimestamp(int(req_oauth_params_dict.get('oauth_timestamp')),
datetime.timezone.utc)
# oauth_timestamp: seconds since January 1, 1970 00:00:00 GMT
except ValueError:
return False, 'oauth_timestamp is missing or has an invalid format'

now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc)
delta = datetime.timedelta(seconds=OAuthNonceCache.CACHE_TIMEOUT_SECONDS)
if not (now - delta < timestamp and timestamp < now + delta): # pylint: disable=chained-comparison
return False, 'oauth_timestamp has expired'
Expand Down
3 changes: 3 additions & 0 deletions lib/cache/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ def t2():


class TestCached(CachedAbstract):

__test__ = False # Prevents this class from being picked up by pytest

def __init__(self, func):
self._fake_func = func
super().__init__()
Expand Down
1 change: 1 addition & 0 deletions lib/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class TestGlobal(RequestGlobal):
__test__ = False # Prevents this class from being picked up by pytest
test = None
def init(self):
self.test = "test"
Expand Down
9 changes: 9 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ DJANGO_SETTINGS_MODULE = aplus.settings
env =
APLUS_BASE_URL=http://localhost
APLUS_LOCAL_SETTINGS=aplus/local_settings.test.py

filterwarnings =
ignore::DeprecationWarning:format_cef._cef.base.*
ignore::DeprecationWarning:bootstrapform.meta.*
ignore::DeprecationWarning:model_utils.*
ignore::DeprecationWarning:importlib._bootstrap.*
ignore::DeprecationWarning:reportlab.lib.rl_safe_eval.*
ignore::Warning:django_settingsdict.*
ignore::Warning:django.db.models.options.*

0 comments on commit 1604329

Please sign in to comment.