From 4ce9f77a14735115a88e2ac46cb6efb3d3ac9240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Thu, 2 May 2024 10:26:32 +0200 Subject: [PATCH] tests: use time-travel instead of freezegun --- poetry.lock | 163 ++++++++++++++------- pyproject.toml | 4 +- tests/backends/test_models.py | 6 +- tests/core/test_email_confirmation.py | 32 ++-- tests/core/test_registration.py | 6 +- tests/oidc/test_authorization_code_flow.py | 6 +- 6 files changed, 138 insertions(+), 79 deletions(-) diff --git a/poetry.lock b/poetry.lock index b78a53b1..becec383 100644 --- a/poetry.lock +++ b/poetry.lock @@ -83,13 +83,12 @@ cryptography = "*" [[package]] name = "autodoc-pydantic" -version = "2.1.0" +version = "2.2.0" description = "Seamlessly integrate pydantic models in your Sphinx documentation." optional = false -python-versions = ">=3.8,<4.0.0" +python-versions = "<4.0.0,>=3.8.1" files = [ - {file = "autodoc_pydantic-2.1.0-py3-none-any.whl", hash = "sha256:9f1f82ee3667589dfa08b21697be8bbd80b15110e838cd765bb1bf3ce1b0ea8f"}, - {file = "autodoc_pydantic-2.1.0.tar.gz", hash = "sha256:3cf1b973e2f5ff0fbbe9b951c11827b5e32d3409e238f7f5782359426ab8d360"}, + {file = "autodoc_pydantic-2.2.0-py3-none-any.whl", hash = "sha256:8c6a36fbf6ed2700ea9c6d21ea76ad541b621fbdf16b5a80ee04673548af4d95"}, ] [package.dependencies] @@ -98,10 +97,12 @@ pydantic-settings = ">=2.0,<3.0.0" Sphinx = ">=4.0" [package.extras] -dev = ["coverage (>=7,<8)", "flake8 (>=3,<4)", "pytest (>=7,<8)", "sphinx-copybutton (>=0.4,<0.5)", "sphinx-rtd-theme (>=1.0,<2.0)", "sphinx-tabs (>=3,<4)", "sphinxcontrib-mermaid (>=0.7,<0.8)", "tox (>=3,<4)"] -docs = ["sphinx-copybutton (>=0.4,<0.5)", "sphinx-rtd-theme (>=1.0,<2.0)", "sphinx-tabs (>=3,<4)", "sphinxcontrib-mermaid (>=0.7,<0.8)"] -erdantic = ["erdantic (>=0.6,<0.7)"] -test = ["coverage (>=7,<8)", "pytest (>=7,<8)"] +docs = ["myst-parser (>=3.0.0,<4.0.0)", "sphinx-copybutton (>=0.5.0,<0.6.0)", "sphinx-rtd-theme (>=2.0.0,<3.0.0)", "sphinx-tabs (>=3,<4)", "sphinxcontrib-mermaid (>=0.9.0,<0.10.0)"] +erdantic = ["erdantic (<2.0)"] +linting = ["ruff (>=0.4.0,<0.5.0)"] +security = ["pip-audit (>=2.7.2,<3.0.0)"] +test = ["coverage (>=7,<8)", "defusedxml (>=0.7.1)", "pytest (>=8.0.0,<9.0.0)", "pytest-sugar (>=1.0.0,<2.0.0)"] +type-checking = ["mypy (>=1.9,<2.0)", "types-docutils (>=0.20,<0.21)", "typing-extensions (>=4.11,<5.0)"] [[package]] name = "babel" @@ -140,13 +141,13 @@ lxml = ["lxml"] [[package]] name = "blinker" -version = "1.7.0" +version = "1.8.1" description = "Fast, simple object-to-object and broadcast signaling" optional = false python-versions = ">=3.8" files = [ - {file = "blinker-1.7.0-py3-none-any.whl", hash = "sha256:c3f865d4d54db7abc53758a01601cf343fe55b84c1de4e3fa910e420b438d5b9"}, - {file = "blinker-1.7.0.tar.gz", hash = "sha256:e6820ff6fa4e4d1d8e2747c2283749c3f547e4fee112b98555cdcdae32996182"}, + {file = "blinker-1.8.1-py3-none-any.whl", hash = "sha256:5f1cdeff423b77c31b89de0565cd03e5275a03028f44b2b15f912632a58cced6"}, + {file = "blinker-1.8.1.tar.gz", hash = "sha256:da44ec748222dcd0105ef975eed946da197d5bdf8bafb6aa92f5bc89da63fa25"}, ] [[package]] @@ -589,13 +590,13 @@ testing = ["hatch", "pre-commit", "pytest", "tox"] [[package]] name = "faker" -version = "24.11.0" +version = "25.0.0" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-24.11.0-py3-none-any.whl", hash = "sha256:adb98e771073a06bdc5d2d6710d8af07ac5da64c8dc2ae3b17bb32319e66fd82"}, - {file = "Faker-24.11.0.tar.gz", hash = "sha256:34b947581c2bced340c39b35f89dbfac4f356932cfff8fe893bde854903f0e6e"}, + {file = "Faker-25.0.0-py3-none-any.whl", hash = "sha256:e23a2b74888885c3d23a9237bacb823041291c03d609a39acb9ebe6c123f3986"}, + {file = "Faker-25.0.0.tar.gz", hash = "sha256:87ef41e24b39a5be66ecd874af86f77eebd26782a2681200e86c5326340a95d3"}, ] [package.dependencies] @@ -603,13 +604,13 @@ python-dateutil = ">=2.4" [[package]] name = "filelock" -version = "3.13.4" +version = "3.14.0" description = "A platform independent file lock." optional = false python-versions = ">=3.8" files = [ - {file = "filelock-3.13.4-py3-none-any.whl", hash = "sha256:404e5e9253aa60ad457cae1be07c0f0ca90a63931200a47d9b6a6af84fd7b45f"}, - {file = "filelock-3.13.4.tar.gz", hash = "sha256:d13f466618bfde72bd2c18255e269f72542c6e70e7bac83a0232d6b1cc5c8cf4"}, + {file = "filelock-3.14.0-py3-none-any.whl", hash = "sha256:43339835842f110ca7ae60f1e1c160714c5a6afd15a2873419ab185334975c0f"}, + {file = "filelock-3.14.0.tar.gz", hash = "sha256:6ea72da3be9b8c82afd3edcf99f2fffbb5076335a5ae4d03248bb5b6c3eae78a"}, ] [package.extras] @@ -709,20 +710,6 @@ wtforms = "*" [package.extras] email = ["email-validator"] -[[package]] -name = "freezegun" -version = "1.5.0" -description = "Let your Python tests travel through time" -optional = false -python-versions = ">=3.7" -files = [ - {file = "freezegun-1.5.0-py3-none-any.whl", hash = "sha256:ec3f4ba030e34eb6cf7e1e257308aee2c60c3d038ff35996d7475760c9ff3719"}, - {file = "freezegun-1.5.0.tar.gz", hash = "sha256:200a64359b363aa3653d8aac289584078386c7c3da77339d257e46a01fb5c77c"}, -] - -[package.dependencies] -python-dateutil = ">=2.7" - [[package]] name = "greenlet" version = "3.0.3" @@ -1569,13 +1556,13 @@ test = ["pytest", "pytest-cov", "requests", "webob", "webtest"] [[package]] name = "pytest" -version = "8.1.1" +version = "8.2.0" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.1.1-py3-none-any.whl", hash = "sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7"}, - {file = "pytest-8.1.1.tar.gz", hash = "sha256:ac978141a75948948817d360297b7aae0fcb9d6ff6bc9ec6d514b85d5a65c044"}, + {file = "pytest-8.2.0-py3-none-any.whl", hash = "sha256:1733f0620f6cda4095bbf0d9ff8022486e91892245bb9e7d5542c018f612f233"}, + {file = "pytest-8.2.0.tar.gz", hash = "sha256:d507d4482197eac0ba2bae2e9babf0672eb333017bcedaa5fb1a3d42c1174b3f"}, ] [package.dependencies] @@ -1583,11 +1570,11 @@ colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=1.4,<2.0" +pluggy = ">=1.5,<2.0" tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-cov" @@ -1683,18 +1670,18 @@ dev = ["flake8", "isort", "mypy", "tox"] [[package]] name = "pytest-xdist" -version = "3.5.0" +version = "3.6.1" description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-xdist-3.5.0.tar.gz", hash = "sha256:cbb36f3d67e0c478baa57fa4edc8843887e0f6cfc42d677530a36d7472b32d8a"}, - {file = "pytest_xdist-3.5.0-py3-none-any.whl", hash = "sha256:d075629c7e00b611df89f490a5063944bee7a4362a5ff11c7cc7824a03dfce24"}, + {file = "pytest_xdist-3.6.1-py3-none-any.whl", hash = "sha256:9ed4adfb68a016610848639bb7e02c9352d5d9f03d04809919e2dafc3be4cca7"}, + {file = "pytest_xdist-3.6.1.tar.gz", hash = "sha256:ead156a4db231eec769737f57668ef58a2084a34b2e55c4a8fa20d861107300d"}, ] [package.dependencies] -execnet = ">=1.1" -pytest = ">=6.2.0" +execnet = ">=2.1" +pytest = ">=7.0.0" [package.extras] psutil = ["psutil (>=3.0)"] @@ -1779,6 +1766,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -1902,13 +1890,13 @@ testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jar [[package]] name = "shibuya" -version = "2024.4.15" +version = "2024.4.27" description = "A clean, responsive, and customizable Sphinx documentation theme with light/dark mode." optional = false python-versions = ">=3.7" files = [ - {file = "shibuya-2024.4.15-py3-none-any.whl", hash = "sha256:31a5eee5b4dfcb318e5c84960eced7ab5091bf95d20c9ac5f77f4c6df1f6c473"}, - {file = "shibuya-2024.4.15.tar.gz", hash = "sha256:e4e1f083ee3feb6d8ac6db1200ee986f845d8d178bd8999652948652635916a9"}, + {file = "shibuya-2024.4.27-py3-none-any.whl", hash = "sha256:b0eaf3ae415eaefb898ca1ad07012c86f6ef12f43aaad73f0d8ef9a13d42bd5e"}, + {file = "shibuya-2024.4.27.tar.gz", hash = "sha256:6c7c83d49ae3f1d56c0d4c4ccddd31f5dab4aed4e6caf8f397f4de5da5af1911"}, ] [package.dependencies] @@ -2049,18 +2037,21 @@ tests = ["pytest"] [[package]] name = "sphinx-sitemap" -version = "2.5.1" +version = "2.6.0" description = "Sitemap generator for Sphinx" optional = false python-versions = "*" files = [ - {file = "sphinx-sitemap-2.5.1.tar.gz", hash = "sha256:984bef068bbdbc26cfae209a8b61392e9681abc9191b477cd30da406e3a60ee5"}, - {file = "sphinx_sitemap-2.5.1-py3-none-any.whl", hash = "sha256:0b7bce2835f287687f75584d7695e4eb8efaec028e5e7b36e9f791de3c344686"}, + {file = "sphinx_sitemap-2.6.0-py3-none-any.whl", hash = "sha256:7478e417d141f99c9af27ccd635f44c03a471a08b20e778a0f9daef7ace1d30b"}, + {file = "sphinx_sitemap-2.6.0.tar.gz", hash = "sha256:5e0c66b9f2e371ede80c659866a9eaad337d46ab02802f9c7e5f7bc5893c28d2"}, ] [package.dependencies] sphinx = ">=1.2" +[package.extras] +dev = ["build", "flake8", "pre-commit", "pytest", "sphinx", "tox"] + [[package]] name = "sphinxcontrib-applehelp" version = "1.0.8" @@ -2287,6 +2278,74 @@ test-all = ["Babel (>=1.3)", "Jinja2 (>=2.3)", "Pygments (>=1.2)", "arrow (>=0.3 timezone = ["python-dateutil"] url = ["furl (>=0.4.1)"] +[[package]] +name = "time-machine" +version = "2.14.1" +description = "Travel through time in your tests." +optional = false +python-versions = ">=3.8" +files = [ + {file = "time-machine-2.14.1.tar.gz", hash = "sha256:57dc7efc1dde4331902d1bdefd34e8ee890a5c28533157e3b14a429c86b39533"}, + {file = "time_machine-2.14.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:528d588d1e8ba83e45319a74acab4be0569eb141113fdf50368045d0a7d79cee"}, + {file = "time_machine-2.14.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06e913d570d7ee3e199e3316f10f10c8046287049141b0a101197712b4eac106"}, + {file = "time_machine-2.14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ddbbba954e9a409e7d66d60df2b6b8daeb897f8338f909a92d9d20e431ec70d1"}, + {file = "time_machine-2.14.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:72a153b085b4aee652d6b3bf9019ca897f1597ba9869b640b06f28736b267182"}, + {file = "time_machine-2.14.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b94274abe24b6a90d8a5c042167a9a7af2d3438b42ac8eb5ede50fbc73c08db"}, + {file = "time_machine-2.14.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:364353858708628655bf9fa4c2825febd679c729d9e1dd424ff86845828bac05"}, + {file = "time_machine-2.14.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:b951b6f4b8a752ab8c441df422e21954a721a0a5276aa3814ce8cf7205aeb6da"}, + {file = "time_machine-2.14.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:be215eb63d74a3d580f7924bb4209c783fabcfb3253073f4dcb3424d57d0f518"}, + {file = "time_machine-2.14.1-cp310-cp310-win32.whl", hash = "sha256:0e120f95c17bf8e0c097fd8863a8eb24054f9b17d9b17c465694be50f8348a3a"}, + {file = "time_machine-2.14.1-cp310-cp310-win_amd64.whl", hash = "sha256:fb467d6c9e9ab615c8cf22d751d34296dacf801be323a57adeb4ff345cf72473"}, + {file = "time_machine-2.14.1-cp310-cp310-win_arm64.whl", hash = "sha256:19db257117739b2dda1d57e149bb715a593313899b3902a7e6d752c5f1d22542"}, + {file = "time_machine-2.14.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:442d42f1b0ef006f03a5a34905829a1d3ac569a5bcda64d29706e6dc60832f94"}, + {file = "time_machine-2.14.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0312b47f220e46f1bbfaded7fc1469882d9c2a27c6daf44e119aea7006b595cc"}, + {file = "time_machine-2.14.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a39dba3033d9c28347d2db16bcb16041bbf4e9032e2b70023686b6f95deac9d"}, + {file = "time_machine-2.14.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e030d2051bb515251d7f6edd9bbcf79b2b47811e2c402aba9c126af713843d26"}, + {file = "time_machine-2.14.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:993ab140eb5678d1ee7f1197f08e4499dc8ea883ad6b8858737de70d509ec5b5"}, + {file = "time_machine-2.14.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:90725f936ad8b123149bc82a46394dd7057e63157ee11ba878164053fa5bd8ad"}, + {file = "time_machine-2.14.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:59a02c3d3b3b29e2dc3a708e775c5d6b951b0024c4013fed883f0d2205305c9e"}, + {file = "time_machine-2.14.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4f00f67d532da82538c4dfbbddc587e70c82664f168c11e1c2915d0c85ec2fc8"}, + {file = "time_machine-2.14.1-cp311-cp311-win32.whl", hash = "sha256:27f735cba4c6352ad7bc53ce2d86b715379261a634e690b79fac329081e26fb6"}, + {file = "time_machine-2.14.1-cp311-cp311-win_amd64.whl", hash = "sha256:ee68597bd3fa5ab94633c8a9d3ebd4032091559610e078381818a732910002bc"}, + {file = "time_machine-2.14.1-cp311-cp311-win_arm64.whl", hash = "sha256:6ced9de5eff1fb37efb12984ab7b63f31f0aeadeedec4be6d0404ec4fa91f2e7"}, + {file = "time_machine-2.14.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:30a4a18357fa6cf089eeefcb37e9549b42523aebb5933894770a8919e6c398e1"}, + {file = "time_machine-2.14.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d45bd60bea85869615b117667f10a821e3b0d3603c47bfd105b45d1f67156fc8"}, + {file = "time_machine-2.14.1-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:39de6d37a14ff8882d4f1cbd50c53268b54e1cf4ef9be2bfe590d10a51ccd314"}, + {file = "time_machine-2.14.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7fd7d188b4f9d358c6bd477daf93b460d9b244a4c296ddd065945f2b6193c2bd"}, + {file = "time_machine-2.14.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:99e6f013e67c4f74a9d8f57e34173b2047f2ad48f764e44c38f3ee5344a38c01"}, + {file = "time_machine-2.14.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a927d87501da8b053a27e80f5d0e1e58fbde4b50d70df2d3853ed67e89a731cf"}, + {file = "time_machine-2.14.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c77a616561dd4c7c442e9eee8cbb915750496e9a5a7fca6bcb11a9860226d2d0"}, + {file = "time_machine-2.14.1-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:e7fa70a6bdca40cc4a8386fd85bc1bae0a23ab11e49604ef853ab3ce92be127f"}, + {file = "time_machine-2.14.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:d63ef00d389fa6d2c76c863af580b3e4a8f0ccc6a9aea8e64590588e37f13c00"}, + {file = "time_machine-2.14.1-cp312-cp312-win32.whl", hash = "sha256:6706eb06487354a5e219cacea709fb3ec44dec3842c6218237d5069fa5f1ad64"}, + {file = "time_machine-2.14.1-cp312-cp312-win_amd64.whl", hash = "sha256:36aa4f17adcd73a6064bf4991a29126cac93521f0690805edb91db837c4e1453"}, + {file = "time_machine-2.14.1-cp312-cp312-win_arm64.whl", hash = "sha256:edea570f3835a036e8860bb8d6eb8d08473c59313db86e36e3b207f796fd7b14"}, + {file = "time_machine-2.14.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:87e80408e6b6670e9ce33f94b1cc6b72b1a9b646f5e19f586908129871f74b40"}, + {file = "time_machine-2.14.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c69c0cb498c86ef843cd15964714e76465cc25d64464da57d5d1318f499de099"}, + {file = "time_machine-2.14.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dc48d3934109b0bdbbdc5e9ce577213f7148a92fed378420ee13453503fe4db9"}, + {file = "time_machine-2.14.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7161cea2ff3244cc6075e365fab89000df70ead63a3da9d473983d580558d2de"}, + {file = "time_machine-2.14.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:39fceeb131e6c07b386de042ce1016be771576e9516124b78e75cbab94ae5041"}, + {file = "time_machine-2.14.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:fe508a6c43fb72fa4f66b50b14684cf58d3db95fed617177ec197a7a90427bae"}, + {file = "time_machine-2.14.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:5f3d5c21884aee10e13b00ef45fab893a43db9d59ec27271573528bd359b0ef5"}, + {file = "time_machine-2.14.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:a75e24e59f58059bbbc50e7f97aa6d126bbc2f603a8a5cd1e884beffcf130d8f"}, + {file = "time_machine-2.14.1-cp38-cp38-win32.whl", hash = "sha256:b0f8ba70fbb71d7fbc6d6adb90bed72a83db15b3318c7af0060467539b2f1b63"}, + {file = "time_machine-2.14.1-cp38-cp38-win_amd64.whl", hash = "sha256:15cf3623a4ba2bb4fce4529295570acd5f6c6b44bcbfd1b8d0756ce56c38fe82"}, + {file = "time_machine-2.14.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:bb3a2518c52aa944989b541e5297b833388eb3fe72d91eb875b21fe771597b04"}, + {file = "time_machine-2.14.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:416d94eab7723c7d8a37fe6b3b1882046fdbf3c31b9abec3cac87cf35dbb8230"}, + {file = "time_machine-2.14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:adfbfa796dd96383400b44681eacc5ab06d3cbfad39c30878e5ead0bfdca808a"}, + {file = "time_machine-2.14.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:31e6e9bff89b7c6e4cbc169ba1d00d6c107b3abc43173b2799352b6995cf7cb2"}, + {file = "time_machine-2.14.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:107caed387438d689180b692e8d84aa1ebe8918790df83dc5e2146e60e5e0859"}, + {file = "time_machine-2.14.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:cab4abf4d1490a7da35db5a321ff8a4d4a2195f4832a792c75b626ffc4a5584c"}, + {file = "time_machine-2.14.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:fd8645b820f7895fdafbc4412d1ce376956e36ad4fd05a43269aa06c3132afc3"}, + {file = "time_machine-2.14.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:dd26039a9ffea2d5ee1309f2ec9b656d4925371c65563822d52e4037a4186eca"}, + {file = "time_machine-2.14.1-cp39-cp39-win32.whl", hash = "sha256:5e19b19d20bfbff8c97949e06e150998cf9d0a676e1641fb90597e59a9d7d5e2"}, + {file = "time_machine-2.14.1-cp39-cp39-win_amd64.whl", hash = "sha256:f5d371a5218318121a6b44c21438258b6408b8bfe7ccccb754cf8eb880505576"}, + {file = "time_machine-2.14.1-cp39-cp39-win_arm64.whl", hash = "sha256:2c774f4b603a36ca2611327c57aa8ce0d5042298da008238ee5234b31ce7b22c"}, +] + +[package.dependencies] +python-dateutil = "*" + [[package]] name = "toml" version = "0.10.2" @@ -2339,13 +2398,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "virtualenv" -version = "20.26.0" +version = "20.26.1" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.26.0-py3-none-any.whl", hash = "sha256:0846377ea76e818daaa3e00a4365c018bc3ac9760cbb3544de542885aad61fb3"}, - {file = "virtualenv-20.26.0.tar.gz", hash = "sha256:ec25a9671a5102c8d2657f62792a27b48f016664c6873f6beed3800008577210"}, + {file = "virtualenv-20.26.1-py3-none-any.whl", hash = "sha256:7aa9982a728ae5892558bff6a2839c00b9ed145523ece2274fad6f414690ae75"}, + {file = "virtualenv-20.26.1.tar.gz", hash = "sha256:604bfdceaeece392802e6ae48e69cec49168b9c5f4a44e483963f9242eb0e78b"}, ] [package.dependencies] @@ -2508,4 +2567,4 @@ sql = ["passlib", "sqlalchemy", "sqlalchemy-json", "sqlalchemy-utils"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "216f9a8bade16e802fe82b8fc340333a6ea4979d22650148993ebd8077f19a4e" +content-hash = "13b52d1e77cba7ca75f40dde77df46511fded851bf40a733f40b1765c14bba03" diff --git a/pyproject.toml b/pyproject.toml index 5f2adf70..4f5410ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,17 +82,17 @@ sphinx-issues = "^4.0.0" coverage = {version = "*", extras=["toml"]} faker = "*" flask-webtest = "*" -freezegun = "*" pre-commit = "*" pyquery = "*" pytest = "^8.0.0" pytest-coverage = "*" pytest-httpserver = "*" +pytest-lazy-fixtures = "^1.0.7" pytest-smtpd = "^0.1.0" pytest-xdist = "^3.3.1" slapd = "*" +time-machine = "^2.14.1" toml = "^0.10.0" -pytest-lazy-fixtures = "^1.0.7" [tool.poetry.group.demo] optional = true diff --git a/tests/backends/test_models.py b/tests/backends/test_models.py index 02b3d0ff..ef8c1e0d 100644 --- a/tests/backends/test_models.py +++ b/tests/backends/test_models.py @@ -1,7 +1,7 @@ import datetime -import freezegun import pytest +import time_machine from canaille.app import models @@ -195,7 +195,7 @@ def test_model_creation_edition_datetime(testclient, backend): if "ldap" in backend.__class__.__module__: pytest.skip() - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): user = models.User( user_name="foo", family_name="foo", @@ -209,7 +209,7 @@ def test_model_creation_edition_datetime(testclient, backend): 2020, 1, 1, 2, tzinfo=datetime.timezone.utc ) - with freezegun.freeze_time("2021-01-01 02:00:00"): + with time_machine.travel("2021-01-01 02:00:00+00:00", tick=False): user.family_name = "bar" user.save() assert user.created == datetime.datetime( diff --git a/tests/core/test_email_confirmation.py b/tests/core/test_email_confirmation.py index 62678b5f..c8ff1730 100644 --- a/tests/core/test_email_confirmation.py +++ b/tests/core/test_email_confirmation.py @@ -1,7 +1,7 @@ import datetime from unittest import mock -import freezegun +import time_machine from flask import url_for from canaille.core.endpoints.account import EmailConfirmationPayload @@ -126,19 +126,19 @@ def test_confirmation_unset_smtp_enabled_email_user_validation( then users emails should be validated by sending a confirmation email.""" testclient.app.config["CANAILLE"]["EMAIL_CONFIRMATION"] = None - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get("/login") res.form["login"] = "user" res = res.form.submit().follow() res.form["password"] = "correct horse battery staple" res = res.form.submit() - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): res = testclient.get("/profile/user") assert "readonly" in res.forms["emailconfirmationform"]["old_emails-0"].attrs - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): res.forms["emailconfirmationform"]["new_email"] = "new_email@mydomain.tld" res = res.forms["emailconfirmationform"].submit( name="action", value="add_email" @@ -168,7 +168,7 @@ def test_confirmation_unset_smtp_enabled_email_user_validation( email_content = str(smtpd.messages[0].get_payload()[0]).replace("=\n", "") assert email_confirmation_url in email_content - with freezegun.freeze_time("2020-01-01 03:00:00"): + with time_machine.travel("2020-01-01 03:00:00+00:00", tick=False): res = testclient.get(email_confirmation_url) assert ("success", "Your email address have been confirmed.") in res.flashes @@ -187,19 +187,19 @@ def test_confirmation_invalid_link(testclient, backend, user): def test_confirmation_mail_form_failed(testclient, backend, user): """Tests when an error happens during the mail sending.""" - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get("/login") res.form["login"] = "user" res = res.form.submit().follow() res.form["password"] = "correct horse battery staple" res = res.form.submit() - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): res = testclient.get("/profile/user") assert "readonly" in res.forms["emailconfirmationform"]["old_emails-0"].attrs - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): res.forms["emailconfirmationform"]["new_email"] = "invalid" res = res.forms["emailconfirmationform"].submit( name="action", value="add_email" @@ -214,19 +214,19 @@ def test_confirmation_mail_form_failed(testclient, backend, user): def test_confirmation_mail_send_failed(SMTP, smtpd, testclient, backend, user): """Tests when an error happens during the mail sending.""" SMTP.side_effect = mock.Mock(side_effect=OSError("unit test mail error")) - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get("/login") res.form["login"] = "user" res = res.form.submit().follow() res.form["password"] = "correct horse battery staple" res = res.form.submit() - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): res = testclient.get("/profile/user") assert "readonly" in res.forms["emailconfirmationform"]["old_emails-0"].attrs - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): res.forms["emailconfirmationform"]["new_email"] = "new_email@mydomain.tld" res = res.forms["emailconfirmationform"].submit( name="action", value="add_email", expect_errors=True @@ -251,7 +251,7 @@ def test_confirmation_expired_link(testclient, backend, user): _external=True, ) - with freezegun.freeze_time("2021-01-01 01:00:00"): + with time_machine.travel("2021-01-01 01:00:00+00:00", tick=False): res = testclient.get(email_confirmation_url) assert ( @@ -276,7 +276,7 @@ def test_confirmation_invalid_hash_link(testclient, backend, user): _external=True, ) - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get(email_confirmation_url) assert ( @@ -305,7 +305,7 @@ def test_confirmation_invalid_user_link(testclient, backend, user): _external=True, ) - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get(email_confirmation_url) assert ( @@ -330,7 +330,7 @@ def test_confirmation_email_already_confirmed_link(testclient, backend, user, ad _external=True, ) - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get(email_confirmation_url) assert ( @@ -360,7 +360,7 @@ def test_confirmation_email_already_used_link(testclient, backend, user, admin): _external=True, ) - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get(email_confirmation_url) assert ( diff --git a/tests/core/test_registration.py b/tests/core/test_registration.py index 67fa3839..b989db4b 100644 --- a/tests/core/test_registration.py +++ b/tests/core/test_registration.py @@ -1,6 +1,6 @@ from unittest import mock -import freezegun +import time_machine from flask import url_for from canaille.app import models @@ -31,7 +31,7 @@ def test_registration_with_email_validation(testclient, backend, smtpd, foo_grou """Tests a nominal registration with email validation.""" testclient.app.config["CANAILLE"]["ENABLE_REGISTRATION"] = True - with freezegun.freeze_time("2020-01-01 02:00:00"): + with time_machine.travel("2020-01-01 02:00:00+00:00", tick=False): res = testclient.get(url_for("core.account.join")) res.form["email"] = "foo@bar.com" res = res.form.submit() @@ -61,7 +61,7 @@ def test_registration_with_email_validation(testclient, backend, smtpd, foo_grou assert registration_url in text_mail assert not models.User.query(user_name="newuser") - with freezegun.freeze_time("2020-01-01 02:01:00"): + with time_machine.travel("2020-01-01 02:01:00+00:00", tick=False): res = testclient.get(registration_url, status=200) res.form["user_name"] = "newuser" res.form["password1"] = "password" diff --git a/tests/oidc/test_authorization_code_flow.py b/tests/oidc/test_authorization_code_flow.py index 3113031f..6b101e7e 100644 --- a/tests/oidc/test_authorization_code_flow.py +++ b/tests/oidc/test_authorization_code_flow.py @@ -2,7 +2,7 @@ from urllib.parse import parse_qs from urllib.parse import urlsplit -import freezegun +import time_machine from authlib.jose import jwt from authlib.oauth2.rfc7636 import create_s256_code_challenge from flask import g @@ -626,7 +626,7 @@ def test_request_scope_too_large(testclient, logged_user, keypair, client): def test_code_expired(testclient, user, client): - with freezegun.freeze_time("2020-01-01 01:00:00"): + with time_machine.travel("2020-01-01 01:00:00+00:00", tick=False): res = testclient.get( "/oauth/authorize", params=dict( @@ -647,7 +647,7 @@ def test_code_expired(testclient, user, client): params = parse_qs(urlsplit(res.location).query) code = params["code"][0] - with freezegun.freeze_time("2021-01-01 01:00:00"): + with time_machine.travel("2021-01-01 01:00:00+00:00", tick=False): res = testclient.post( "/oauth/token", params=dict(