From b0a1e675bc04c2db6bd8a538a96081ae87fbaced Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:44:57 -0800 Subject: [PATCH 01/10] chore(deps-dev): Bump ruff from 0.7.4 to 0.8.0 (#3348) Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.4 to 0.8.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.4...0.8.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jamshale <31809382+jamshale@users.noreply.github.com> --- poetry.lock | 44 +++++++++++++++++++++++--------------------- pyproject.toml | 2 +- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/poetry.lock b/poetry.lock index 465055db55..bd70d367bf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "aiofiles" @@ -1325,6 +1325,8 @@ optional = false python-versions = "*" files = [ {file = "jsonpath-ng-1.7.0.tar.gz", hash = "sha256:f6f5f7fd4e5ff79c785f1573b394043b39849fb2bb47bcead935d12b00beab3c"}, + {file = "jsonpath_ng-1.7.0-py2-none-any.whl", hash = "sha256:898c93fc173f0c336784a3fa63d7434297544b7198124a68f9a3ef9597b0ae6e"}, + {file = "jsonpath_ng-1.7.0-py3-none-any.whl", hash = "sha256:f3d7f9e848cba1b6da28c55b1c26ff915dc9e0b1ba7e752a53d6da8d5cbd00b6"}, ] [package.dependencies] @@ -2598,29 +2600,29 @@ test = ["hypothesis (==5.19.0)", "pytest (>=7.0.0)", "pytest-xdist (>=2.4.0)"] [[package]] name = "ruff" -version = "0.7.4" +version = "0.8.0" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.7.4-py3-none-linux_armv6l.whl", hash = "sha256:a4919925e7684a3f18e18243cd6bea7cfb8e968a6eaa8437971f681b7ec51478"}, - {file = "ruff-0.7.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfb365c135b830778dda8c04fb7d4280ed0b984e1aec27f574445231e20d6c63"}, - {file = "ruff-0.7.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:63a569b36bc66fbadec5beaa539dd81e0527cb258b94e29e0531ce41bacc1f20"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d06218747d361d06fd2fdac734e7fa92df36df93035db3dc2ad7aa9852cb109"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e0cea28d0944f74ebc33e9f934238f15c758841f9f5edd180b5315c203293452"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:80094ecd4793c68b2571b128f91754d60f692d64bc0d7272ec9197fdd09bf9ea"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:997512325c6620d1c4c2b15db49ef59543ef9cd0f4aa8065ec2ae5103cedc7e7"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:00b4cf3a6b5fad6d1a66e7574d78956bbd09abfd6c8a997798f01f5da3d46a05"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7dbdc7d8274e1422722933d1edddfdc65b4336abf0b16dfcb9dedd6e6a517d06"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e92dfb5f00eaedb1501b2f906ccabfd67b2355bdf117fea9719fc99ac2145bc"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3bd726099f277d735dc38900b6a8d6cf070f80828877941983a57bca1cd92172"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:2e32829c429dd081ee5ba39aef436603e5b22335c3d3fff013cd585806a6486a"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:662a63b4971807623f6f90c1fb664613f67cc182dc4d991471c23c541fee62dd"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:876f5e09eaae3eb76814c1d3b68879891d6fde4824c015d48e7a7da4cf066a3a"}, - {file = "ruff-0.7.4-py3-none-win32.whl", hash = "sha256:75c53f54904be42dd52a548728a5b572344b50d9b2873d13a3f8c5e3b91f5cac"}, - {file = "ruff-0.7.4-py3-none-win_amd64.whl", hash = "sha256:745775c7b39f914238ed1f1b0bebed0b9155a17cd8bc0b08d3c87e4703b990d6"}, - {file = "ruff-0.7.4-py3-none-win_arm64.whl", hash = "sha256:11bff065102c3ae9d3ea4dc9ecdfe5a5171349cdd0787c1fc64761212fc9cf1f"}, - {file = "ruff-0.7.4.tar.gz", hash = "sha256:cd12e35031f5af6b9b93715d8c4f40360070b2041f81273d0527683d5708fce2"}, + {file = "ruff-0.8.0-py3-none-linux_armv6l.whl", hash = "sha256:fcb1bf2cc6706adae9d79c8d86478677e3bbd4ced796ccad106fd4776d395fea"}, + {file = "ruff-0.8.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:295bb4c02d58ff2ef4378a1870c20af30723013f441c9d1637a008baaf928c8b"}, + {file = "ruff-0.8.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7b1f1c76b47c18fa92ee78b60d2d20d7e866c55ee603e7d19c1e991fad933a9a"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eb0d4f250a7711b67ad513fde67e8870109e5ce590a801c3722580fe98c33a99"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0e55cce9aa93c5d0d4e3937e47b169035c7e91c8655b0974e61bb79cf398d49c"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f4cd64916d8e732ce6b87f3f5296a8942d285bbbc161acee7fe561134af64f9"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c5c1466be2a2ebdf7c5450dd5d980cc87c8ba6976fb82582fea18823da6fa362"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2dabfd05b96b7b8f2da00d53c514eea842bff83e41e1cceb08ae1966254a51df"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:facebdfe5a5af6b1588a1d26d170635ead6892d0e314477e80256ef4a8470cf3"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87a8e86bae0dbd749c815211ca11e3a7bd559b9710746c559ed63106d382bd9c"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:85e654f0ded7befe2d61eeaf3d3b1e4ef3894469cd664ffa85006c7720f1e4a2"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:83a55679c4cb449fa527b8497cadf54f076603cc36779b2170b24f704171ce70"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:812e2052121634cf13cd6fddf0c1871d0ead1aad40a1a258753c04c18bb71bbd"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:780d5d8523c04202184405e60c98d7595bdb498c3c6abba3b6d4cdf2ca2af426"}, + {file = "ruff-0.8.0-py3-none-win32.whl", hash = "sha256:5fdb6efecc3eb60bba5819679466471fd7d13c53487df7248d6e27146e985468"}, + {file = "ruff-0.8.0-py3-none-win_amd64.whl", hash = "sha256:582891c57b96228d146725975fbb942e1f30a0c4ba19722e692ca3eb25cc9b4f"}, + {file = "ruff-0.8.0-py3-none-win_arm64.whl", hash = "sha256:ba93e6294e9a737cd726b74b09a6972e36bb511f9a102f1d9a7e1ce94dd206a6"}, + {file = "ruff-0.8.0.tar.gz", hash = "sha256:a7ccfe6331bf8c8dad715753e157457faf7351c2b69f62f32c165c2dbcbacd44"}, ] [[package]] @@ -3139,4 +3141,4 @@ didcommv2 = ["didcomm-messaging"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "543d20028efad5a9d798071ba86e9d1ab39b202fe1afaa27f8f4c7f656f1d7cc" +content-hash = "bbb6160407926b8aceeceeb69268118c018e71a0857eefa9e3567b09d4088f15" diff --git a/pyproject.toml b/pyproject.toml index 7de97f37b3..557927eca2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ canonicaljson = "^2.0.0" [tool.poetry.group.dev.dependencies] pre-commit = "~3.8.0" # Sync with version in .pre-commit-config.yaml -ruff = "0.7.4" +ruff = "0.8.0" sphinx = "^5.3.0" sphinx-rtd-theme = ">=0.4.3" From b5e79fb1c948a5873c57f7a3e04ef208640add46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:51:30 -0800 Subject: [PATCH 02/10] chore(deps): Bump mkdocs-material from 9.5.44 to 9.5.46 (#3352) Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.44 to 9.5.46. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.5.44...9.5.46) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- mkdocs-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs-requirements.txt b/mkdocs-requirements.txt index eb1ee40600..a6d710f6af 100644 --- a/mkdocs-requirements.txt +++ b/mkdocs-requirements.txt @@ -1,3 +1,3 @@ -mkdocs-material==9.5.44 +mkdocs-material==9.5.46 mike==2.1.3 From 1613ed02c281ae5d6ac60673c7e4bdc65789202d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:18:27 -0800 Subject: [PATCH 03/10] chore(deps): Bump uuid-utils from 0.9.0 to 0.10.0 (#3351) Bumps [uuid-utils](https://github.com/aminalaee/uuid-utils) from 0.9.0 to 0.10.0. - [Release notes](https://github.com/aminalaee/uuid-utils/releases) - [Commits](https://github.com/aminalaee/uuid-utils/compare/0.9.0...0.10.0) --- updated-dependencies: - dependency-name: uuid-utils dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- poetry.lock | 109 ++++++++++++++----------------------------------- pyproject.toml | 2 +- 2 files changed, 31 insertions(+), 80 deletions(-) diff --git a/poetry.lock b/poetry.lock index bd70d367bf..1c0f343a8a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2901,87 +2901,38 @@ files = [ [[package]] name = "uuid-utils" -version = "0.9.0" +version = "0.10.0" description = "Drop-in replacement for Python UUID in Rust" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "uuid_utils-0.9.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:28da15c275ef06a759efe0fcba7c58eab8ae2217f7a7f66289dee6ae332605a0"}, - {file = "uuid_utils-0.9.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:81144165068e84a1ac8b92f23bfc961e5b5dbb89ddcff70c5e7d096ae07a439c"}, - {file = "uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:362695ed7756b1b89d9a2dd193fe2523ca1d4a31235606f7cb516a322789ffc4"}, - {file = "uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:36cb70e29f5749b554ae06f1a88926c9b47d5b48004b6903fb7ea47e8b398080"}, - {file = "uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fa39a95eb67e2b98a61d4e64ddf622ee902fe9142b579921ab3e9027472f5080"}, - {file = "uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d9b7029044d40f66366cebb6a94ecb04d8c0a745029561552d527ac52dc0deb9"}, - {file = "uuid_utils-0.9.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c883c6f815d2af344dab585d7b16a77410fcb1f6c097e6ad0384bd12cd84e16e"}, - {file = "uuid_utils-0.9.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:be5f83e9002a43aac868fa9cbc73f28cfb0b4e8b14f5a449fef04fea31bf2904"}, - {file = "uuid_utils-0.9.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:8f84b0fd38df8a211230b8bbd02d5e7e631f1d35c1ba67efb895f80c7d9215aa"}, - {file = "uuid_utils-0.9.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:89cc342b061d8e3f669b8aaeb8d9e2973407c93aaa675dc6a59e985feda2805c"}, - {file = "uuid_utils-0.9.0-cp310-none-win32.whl", hash = "sha256:3d5554f44aeab9706770169316897f79089b51a061800684b7f29bccf663ad0f"}, - {file = "uuid_utils-0.9.0-cp310-none-win_amd64.whl", hash = "sha256:db35df169f17617129cc070e3a8fba00598ee55adcbe22c79b2c2f306eeb3b9e"}, - {file = "uuid_utils-0.9.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:cdb7224fb8b1f18edcd4357f83fcbe33b9f82ac392095e5d9e0e05336d65d587"}, - {file = "uuid_utils-0.9.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:5312449ea5427a94edab3aebf2cff8f99a3112f273dd9d5919e332bc4e6a031f"}, - {file = "uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1d6837677217b3d0aa375f8aa7b89935c3ebf2ee5e1667be50b2090741684baa"}, - {file = "uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:402e522f62ceb8344f579e37f9a25c9274d484675afd71ad725ddd61ced7cd36"}, - {file = "uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e24a27724b2289d66d75358ffecf698ae36816458897cfdec972e6ede1ead328"}, - {file = "uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db04420c0b1a99f3160ddc90ba52986484ce8304b54586ea161133f755a4605b"}, - {file = "uuid_utils-0.9.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:152f3c1a0634558e329b64ff4a9592ee83b722e3fdc214f648f851fa14163c36"}, - {file = "uuid_utils-0.9.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:5710b6ca95966f80125f48dad9e3d70ef99f48dd892bec3cb38673d087a7d71a"}, - {file = "uuid_utils-0.9.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e3b9b9cf0cc544ef552c955bc2caaecf5e38cc8ed65e23f208b0dcdb6d37719e"}, - {file = "uuid_utils-0.9.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:6d715b6321d4728a1aa0d5e26a338c97aaba2bf337f3ef9804ef5027f07de61d"}, - {file = "uuid_utils-0.9.0-cp311-none-win32.whl", hash = "sha256:3b61b0543404c99f7f23fb556b69090bc58358e8bd9d570381722221281f3706"}, - {file = "uuid_utils-0.9.0-cp311-none-win_amd64.whl", hash = "sha256:b4bdd9e80c92b1f253e66392e1d6ad0ec4926d5c7e2de3d852ee6fed1939f58b"}, - {file = "uuid_utils-0.9.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:9cfcfb222f62612bea58bdec32b6842d9636fca53ca4579f88c1b620b1c4cbf7"}, - {file = "uuid_utils-0.9.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:7253039ecfa534b3177b3225764cede9c6dae5db572e17d8582dd7cc5b3af484"}, - {file = "uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fb6e792ae1e3a7bf9d357f87dcf628923d0881f1d13a9cba826b848ca1774b1"}, - {file = "uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fbea3bb9ad319de7f69d6a60b6921acaa97d577aaeceb247b1ff4a8a92b3aa6a"}, - {file = "uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:09043b3f48e20d631c7a81030be8c4f6ea9a6d44cccda8cbbdc1ad18da301c89"}, - {file = "uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d9ba2681f5f177f800e40f5a0f09ed03c49f4290a245e4273d21cb48a7e88969"}, - {file = "uuid_utils-0.9.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:866811473f3d9dc38c02dd08e076e333b9e4d41ce952353941b49d0724d2327b"}, - {file = "uuid_utils-0.9.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:14aa9917ef11bd0ee1648237dddbf33aa0459e609ebe2f9202ffb259ca80f763"}, - {file = "uuid_utils-0.9.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:22cae83bc486a6c12b38239eb0546f2f81c81c34fcf833f84c2c7cd0cab1ad8f"}, - {file = "uuid_utils-0.9.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c9513399045169435563c284caba0f1802748b02f27c95769426b7a00ed246e1"}, - {file = "uuid_utils-0.9.0-cp312-none-win_amd64.whl", hash = "sha256:284e6d24ba659d003bd47fcfc404d374c7807983407d4d61f26c80a3b7f4cb41"}, - {file = "uuid_utils-0.9.0-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:fd3d09c53d5a96c78c77211786fa25bbdbe031566b927383c10ab81a27c7e431"}, - {file = "uuid_utils-0.9.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:2b052d01176d2d1afa476ebe158eae052e265c92110d987d5801f0c3c1c8852a"}, - {file = "uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:85e636a9603dc04e15b8305129619b2b45843f883e58355c91dc6cc22d51dde8"}, - {file = "uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:37d2f9ec3a99caf29531fe257b7906f8a5946a3ee7000c744d73e5187a2542a1"}, - {file = "uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4ace932d10a83141d22c42287a0c707cfa41522ecb797f17e63820f09688c6d7"}, - {file = "uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:843ec54337233d5f99a99b156ba5be5659f5ea193db8287035bf85d6a6a00c58"}, - {file = "uuid_utils-0.9.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f16a60ef4ddf9fe16fcd4793f83932d2b5198af6873d0a0478acfe0bd19d8e2f"}, - {file = "uuid_utils-0.9.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:901da31d61f78ec8df96741326541ae7af156a2628ca82ccf2806bcee257de1a"}, - {file = "uuid_utils-0.9.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:fad20ba28a11f2b33f06b2d7e0e77be73a8c3a41de833a123c6d93025d463b4b"}, - {file = "uuid_utils-0.9.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:c5c30716a0dcffd1a7a66853f5a8372a276d454510f48fc7e4c39c13212bb1f6"}, - {file = "uuid_utils-0.9.0-cp38-none-win32.whl", hash = "sha256:2912c9a810e74cb3abaebd0fdfa5b1f202cf60a8f0fec9cc76117dab6c42cb77"}, - {file = "uuid_utils-0.9.0-cp38-none-win_amd64.whl", hash = "sha256:b55bcffc260356c84a09ac3a391e2442ad4df0beaaf71670d4e8ffd8b7328e75"}, - {file = "uuid_utils-0.9.0-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:08aec826a8ed4d3baab29d144ad634091e5accabcb88dfa0a834b9ba9e74930f"}, - {file = "uuid_utils-0.9.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:e7de8fcf3d22e299582ab61c67390abdf37cc7d5b330066c3f792a082167c419"}, - {file = "uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8de8da71bc5a6a527952648357acca8d6d1717bbbc044304c5a9cf53eb06568c"}, - {file = "uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ce3ef96aa6ba760e1d0481ed076fe9e8f0386e27c7039bc6ffa377c98979fae7"}, - {file = "uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:69dd8c0d622e4e40b1b993a2e452bbed21127b97f8e4a3fdbde6e5f556253265"}, - {file = "uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4600d5dcd9d0759be4bc580daf6d521da99a825a25db3d492abcbb12f6dc98f6"}, - {file = "uuid_utils-0.9.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:067d5f36ccc70896c76a9dafc8220a942db0e42ab58b84c43208e0ff84c1bdf0"}, - {file = "uuid_utils-0.9.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:7a23d20f08636899a1b24394a12a2c469262af56d5279dbac1c6b14b059e5d4b"}, - {file = "uuid_utils-0.9.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:6a2cbc5da89f0e701d2b80df0e6b30da16a0adcd2883da3d3e1f7aac1f046c1c"}, - {file = "uuid_utils-0.9.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:bbf93bdd3c8a3e3b2b2f82ad4dfafcd2aaecc1d6ec924fd5da2b712ab324ee51"}, - {file = "uuid_utils-0.9.0-cp39-none-win32.whl", hash = "sha256:9d9b3ba5be11a017c568e904eac76f6cd6f82f956ca65ffbaa73ee8d7cdbe13b"}, - {file = "uuid_utils-0.9.0-cp39-none-win_amd64.whl", hash = "sha256:b3e494547cfef124f0c51831a303bfc0278e3c33b9ab9d9db90d94728d9871c2"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:98c7c7b414b405b547c9bc1f972513b3a0bfb3dca248c89c623ab60efdd36ad8"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:7b75241666cae4bc5786e6c68e862ccf4e15b2f98c81e47a6b0a85c907b7b6fa"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf6b43723a2d4af21c07fec98385a97e2023a808fd6eaf4296a163bffca76cf5"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4c260bb9a9fdd484cadc437cdb26ad07d66c8049a365c4ef49c9f09d7ed9ac2e"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f4605c6326a7914d1b59c548f0ae4ef119619fe09c3ab4f07d99f3fbec39d470"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d498673249826ce7c47aa481709a5dd647bbff764fb64370bc691c7e43c7a2a1"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a37c48cba2f4eb6182a3857d045aa1420fa9878bfd268f6855fce7293a006677"}, - {file = "uuid_utils-0.9.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:eeb9c56d401e4a422ae7fd818ef1376bda384ae0bed86e339c9a256c6b10d252"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:33dd97e9c59891fbfb4e4a11596c42cc3d10774b843daaf75316d036a0a07799"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b5e67fc3c6def9d62de4caf19529bd8044e821eb2f5c39821cfd011940f96394"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:241ab8ddb76ef8d4294c09cd6045dd62a1aa46acf8ff0a017796a54a530a87ae"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5a9a16d2af4b4ad59d4cef7f43ba33644353b12769fafabf6e1663aa230cca38"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:897a167659d30a8431a094533bcb58d2b16005f7456408bd40f3e5872e1b2f46"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b4f56ab5ce19697552df9689c24c742054e8fd8e2ef8c26f9b8393f6d7ae893"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:7b219d9341de117e2e608f3fe08e31480ad60fb6128f8fffd2151ba88e53508c"}, - {file = "uuid_utils-0.9.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:b5c08de8a94181c0ba209a8b8275993499f424b57958bea6c39739311526fd18"}, - {file = "uuid_utils-0.9.0.tar.gz", hash = "sha256:239f45b7e71d0ea61e3a4957aa4b8f3b49bfb009cf768d11c3f464787dbb737f"}, + {file = "uuid_utils-0.10.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:8d5a4508feefec62456cd6a41bcdde458d56827d908f226803b886d22a3d5e63"}, + {file = "uuid_utils-0.10.0-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:dbefc2b9113f9dfe56bdae58301a2b3c53792221410d422826f3d1e3e6555fe7"}, + {file = "uuid_utils-0.10.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffc49c33edf87d1ec8112a9b43e4cf55326877716f929c165a2cc307d31c73d5"}, + {file = "uuid_utils-0.10.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0636b6208f69d5a4e629707ad2a89a04dfa8d1023e1999181f6830646ca048a1"}, + {file = "uuid_utils-0.10.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7bc06452856b724df9dedfc161c3582199547da54aeb81915ec2ed54f92d19b0"}, + {file = "uuid_utils-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:263b2589111c61decdd74a762e8f850c9e4386fb78d2cf7cb4dfc537054cda1b"}, + {file = "uuid_utils-0.10.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a558db48b7096de6b4d2d2210d82bba8586a6d55f99106b03bb7d01dc5c5bcd6"}, + {file = "uuid_utils-0.10.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:807465067f3c892514230326ac71a79b28a8dfe2c88ecd2d5675fc844f3c76b5"}, + {file = "uuid_utils-0.10.0-cp39-abi3-musllinux_1_2_i686.whl", hash = "sha256:57423d4a2b9d7b916de6dbd75ba85465a28f9578a89a97f7d3e098d9aa4e5d4a"}, + {file = "uuid_utils-0.10.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:76d8d660f18ff6b767e319b1b5f927350cd92eafa4831d7ef5b57fdd1d91f974"}, + {file = "uuid_utils-0.10.0-cp39-abi3-win32.whl", hash = "sha256:6c11a71489338837db0b902b75e1ba7618d5d29f05fde4f68b3f909177dbc226"}, + {file = "uuid_utils-0.10.0-cp39-abi3-win_amd64.whl", hash = "sha256:11c55ae64f6c0a7a0c741deae8ca2a4eaa11e9c09dbb7bec2099635696034cf7"}, + {file = "uuid_utils-0.10.0-pp310-pypy310_pp73-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:acea543dfc7b87df749e3e814c54ac739a82ff5e3800d25bd25a3e00599e1554"}, + {file = "uuid_utils-0.10.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:0767eefa7b1e96f06cfa9b95758d286240c01bbf19e9d8f1b6043cdbe76cc639"}, + {file = "uuid_utils-0.10.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:973fe4bb5258fd2ccb144d8b40c2d3158f16cc856a20527f8b40d14b2ae1dee9"}, + {file = "uuid_utils-0.10.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:71b8505b67a0d77d0fbd765d8463094a8f447677125da7647bec7ea0b99406f0"}, + {file = "uuid_utils-0.10.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6bdcb1211bb61476cbef12a87101fa48243e20ed82b2bd324c816b1b5826bd5e"}, + {file = "uuid_utils-0.10.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c5247f1df040aae71ea313819b563debe69bca7086a2cc6a3ac0eaddd3dadac"}, + {file = "uuid_utils-0.10.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a50bd29ef89660b93aa07ffa95ac691a0e12832375030569a8bd5c9272f3b8e6"}, + {file = "uuid_utils-0.10.0-pp39-pypy39_pp73-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:a778cd9d8f995b94bba6e51f3ebee5b338fd834b0c4ecc8f932bd23e29db3e19"}, + {file = "uuid_utils-0.10.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:d3d5b5c5ed66ff923961b9ebb902232cd67f6a7ec6b6f7a58e05e00ff44e3c7f"}, + {file = "uuid_utils-0.10.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:789ed6335225326c66f5d6162649bed978105a85f232be7811387c395c226801"}, + {file = "uuid_utils-0.10.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:05d1aa7b944b719eb1ee472435ae5444a3f8a00eb6350e3b1d1217d738477d33"}, + {file = "uuid_utils-0.10.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aa8d8559c2d25d6ac87e0adeee601d2c91ec40b357ab780bcf79061cc23324e6"}, + {file = "uuid_utils-0.10.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0badcbfe3c72b5b30d59c2b12f120923127abd95a0d2aa64ddc1234e495abc2"}, + {file = "uuid_utils-0.10.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:0a7c1c494012335113748815156c5b6234c59b0fe0d3a8eede1b1a46f7e25a69"}, + {file = "uuid_utils-0.10.0.tar.gz", hash = "sha256:5db0e1890e8f008657ffe6ded4d9459af724ab114cfe82af1557c87545301539"}, ] [[package]] @@ -3141,4 +3092,4 @@ didcommv2 = ["didcomm-messaging"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "bbb6160407926b8aceeceeb69268118c018e71a0857eefa9e3567b09d4088f15" +content-hash = "0ad79fb5601c4fea9a3e7d4f978e0b0085a76b49f7934a1814e04922c2029d80" diff --git a/pyproject.toml b/pyproject.toml index 557927eca2..5ab3ec2d4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ requests = "~2.32.3" rlp = "4.0.1" unflatten = "~0.2" sd-jwt = "^0.10.3" -uuid_utils = "^0.9.0" +uuid_utils = "^0.10.0" # did libraries did-peer-2 = "^0.1.2" From b8283d74262859311cd520df29739a6d44d8e736 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:59:05 -0800 Subject: [PATCH 04/10] chore(deps-dev): Bump debugpy from 1.8.8 to 1.8.9 (#3350) Bumps [debugpy](https://github.com/microsoft/debugpy) from 1.8.8 to 1.8.9. - [Release notes](https://github.com/microsoft/debugpy/releases) - [Commits](https://github.com/microsoft/debugpy/compare/v1.8.8...v1.8.9) --- updated-dependencies: - dependency-name: debugpy dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- poetry.lock | 56 +++++++++++++++++++++++++------------------------- pyproject.toml | 2 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/poetry.lock b/poetry.lock index 1c0f343a8a..4265229219 100644 --- a/poetry.lock +++ b/poetry.lock @@ -812,37 +812,37 @@ cython = ["cython"] [[package]] name = "debugpy" -version = "1.8.8" +version = "1.8.9" description = "An implementation of the Debug Adapter Protocol for Python" optional = false python-versions = ">=3.8" files = [ - {file = "debugpy-1.8.8-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:e59b1607c51b71545cb3496876544f7186a7a27c00b436a62f285603cc68d1c6"}, - {file = "debugpy-1.8.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a6531d952b565b7cb2fbd1ef5df3d333cf160b44f37547a4e7cf73666aca5d8d"}, - {file = "debugpy-1.8.8-cp310-cp310-win32.whl", hash = "sha256:b01f4a5e5c5fb1d34f4ccba99a20ed01eabc45a4684f4948b5db17a319dfb23f"}, - {file = "debugpy-1.8.8-cp310-cp310-win_amd64.whl", hash = "sha256:535f4fb1c024ddca5913bb0eb17880c8f24ba28aa2c225059db145ee557035e9"}, - {file = "debugpy-1.8.8-cp311-cp311-macosx_14_0_universal2.whl", hash = "sha256:c399023146e40ae373753a58d1be0a98bf6397fadc737b97ad612886b53df318"}, - {file = "debugpy-1.8.8-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:09cc7b162586ea2171eea055985da2702b0723f6f907a423c9b2da5996ad67ba"}, - {file = "debugpy-1.8.8-cp311-cp311-win32.whl", hash = "sha256:eea8821d998ebeb02f0625dd0d76839ddde8cbf8152ebbe289dd7acf2cdc6b98"}, - {file = "debugpy-1.8.8-cp311-cp311-win_amd64.whl", hash = "sha256:d4483836da2a533f4b1454dffc9f668096ac0433de855f0c22cdce8c9f7e10c4"}, - {file = "debugpy-1.8.8-cp312-cp312-macosx_14_0_universal2.whl", hash = "sha256:0cc94186340be87b9ac5a707184ec8f36547fb66636d1029ff4f1cc020e53996"}, - {file = "debugpy-1.8.8-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64674e95916e53c2e9540a056e5f489e0ad4872645399d778f7c598eacb7b7f9"}, - {file = "debugpy-1.8.8-cp312-cp312-win32.whl", hash = "sha256:5c6e885dbf12015aed73770f29dec7023cb310d0dc2ba8bfbeb5c8e43f80edc9"}, - {file = "debugpy-1.8.8-cp312-cp312-win_amd64.whl", hash = "sha256:19ffbd84e757a6ca0113574d1bf5a2298b3947320a3e9d7d8dc3377f02d9f864"}, - {file = "debugpy-1.8.8-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:705cd123a773d184860ed8dae99becd879dfec361098edbefb5fc0d3683eb804"}, - {file = "debugpy-1.8.8-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:890fd16803f50aa9cb1a9b9b25b5ec321656dd6b78157c74283de241993d086f"}, - {file = "debugpy-1.8.8-cp313-cp313-win32.whl", hash = "sha256:90244598214bbe704aa47556ec591d2f9869ff9e042e301a2859c57106649add"}, - {file = "debugpy-1.8.8-cp313-cp313-win_amd64.whl", hash = "sha256:4b93e4832fd4a759a0c465c967214ed0c8a6e8914bced63a28ddb0dd8c5f078b"}, - {file = "debugpy-1.8.8-cp38-cp38-macosx_14_0_x86_64.whl", hash = "sha256:143ef07940aeb8e7316de48f5ed9447644da5203726fca378f3a6952a50a9eae"}, - {file = "debugpy-1.8.8-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f95651bdcbfd3b27a408869a53fbefcc2bcae13b694daee5f1365b1b83a00113"}, - {file = "debugpy-1.8.8-cp38-cp38-win32.whl", hash = "sha256:26b461123a030e82602a750fb24d7801776aa81cd78404e54ab60e8b5fecdad5"}, - {file = "debugpy-1.8.8-cp38-cp38-win_amd64.whl", hash = "sha256:f3cbf1833e644a3100eadb6120f25be8a532035e8245584c4f7532937edc652a"}, - {file = "debugpy-1.8.8-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:53709d4ec586b525724819dc6af1a7703502f7e06f34ded7157f7b1f963bb854"}, - {file = "debugpy-1.8.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a9c013077a3a0000e83d97cf9cc9328d2b0bbb31f56b0e99ea3662d29d7a6a2"}, - {file = "debugpy-1.8.8-cp39-cp39-win32.whl", hash = "sha256:ffe94dd5e9a6739a75f0b85316dc185560db3e97afa6b215628d1b6a17561cb2"}, - {file = "debugpy-1.8.8-cp39-cp39-win_amd64.whl", hash = "sha256:5c0e5a38c7f9b481bf31277d2f74d2109292179081f11108e668195ef926c0f9"}, - {file = "debugpy-1.8.8-py2.py3-none-any.whl", hash = "sha256:ec684553aba5b4066d4de510859922419febc710df7bba04fe9e7ef3de15d34f"}, - {file = "debugpy-1.8.8.zip", hash = "sha256:e6355385db85cbd666be703a96ab7351bc9e6c61d694893206f8001e22aee091"}, + {file = "debugpy-1.8.9-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:cfe1e6c6ad7178265f74981edf1154ffce97b69005212fbc90ca22ddfe3d017e"}, + {file = "debugpy-1.8.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ada7fb65102a4d2c9ab62e8908e9e9f12aed9d76ef44880367bc9308ebe49a0f"}, + {file = "debugpy-1.8.9-cp310-cp310-win32.whl", hash = "sha256:c36856343cbaa448171cba62a721531e10e7ffb0abff838004701454149bc037"}, + {file = "debugpy-1.8.9-cp310-cp310-win_amd64.whl", hash = "sha256:17c5e0297678442511cf00a745c9709e928ea4ca263d764e90d233208889a19e"}, + {file = "debugpy-1.8.9-cp311-cp311-macosx_14_0_universal2.whl", hash = "sha256:b74a49753e21e33e7cf030883a92fa607bddc4ede1aa4145172debc637780040"}, + {file = "debugpy-1.8.9-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:62d22dacdb0e296966d7d74a7141aaab4bec123fa43d1a35ddcb39bf9fd29d70"}, + {file = "debugpy-1.8.9-cp311-cp311-win32.whl", hash = "sha256:8138efff315cd09b8dcd14226a21afda4ca582284bf4215126d87342bba1cc66"}, + {file = "debugpy-1.8.9-cp311-cp311-win_amd64.whl", hash = "sha256:ff54ef77ad9f5c425398efb150239f6fe8e20c53ae2f68367eba7ece1e96226d"}, + {file = "debugpy-1.8.9-cp312-cp312-macosx_14_0_universal2.whl", hash = "sha256:957363d9a7a6612a37458d9a15e72d03a635047f946e5fceee74b50d52a9c8e2"}, + {file = "debugpy-1.8.9-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e565fc54b680292b418bb809f1386f17081d1346dca9a871bf69a8ac4071afe"}, + {file = "debugpy-1.8.9-cp312-cp312-win32.whl", hash = "sha256:3e59842d6c4569c65ceb3751075ff8d7e6a6ada209ceca6308c9bde932bcef11"}, + {file = "debugpy-1.8.9-cp312-cp312-win_amd64.whl", hash = "sha256:66eeae42f3137eb428ea3a86d4a55f28da9bd5a4a3d369ba95ecc3a92c1bba53"}, + {file = "debugpy-1.8.9-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:957ecffff80d47cafa9b6545de9e016ae8c9547c98a538ee96ab5947115fb3dd"}, + {file = "debugpy-1.8.9-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1efbb3ff61487e2c16b3e033bc8595aea578222c08aaf3c4bf0f93fadbd662ee"}, + {file = "debugpy-1.8.9-cp313-cp313-win32.whl", hash = "sha256:7c4d65d03bee875bcb211c76c1d8f10f600c305dbd734beaed4077e902606fee"}, + {file = "debugpy-1.8.9-cp313-cp313-win_amd64.whl", hash = "sha256:e46b420dc1bea64e5bbedd678148be512442bc589b0111bd799367cde051e71a"}, + {file = "debugpy-1.8.9-cp38-cp38-macosx_14_0_x86_64.whl", hash = "sha256:472a3994999fe6c0756945ffa359e9e7e2d690fb55d251639d07208dbc37caea"}, + {file = "debugpy-1.8.9-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:365e556a4772d7d0d151d7eb0e77ec4db03bcd95f26b67b15742b88cacff88e9"}, + {file = "debugpy-1.8.9-cp38-cp38-win32.whl", hash = "sha256:54a7e6d3014c408eb37b0b06021366ee985f1539e12fe49ca2ee0d392d9ceca5"}, + {file = "debugpy-1.8.9-cp38-cp38-win_amd64.whl", hash = "sha256:8e99c0b1cc7bf86d83fb95d5ccdc4ad0586d4432d489d1f54e4055bcc795f693"}, + {file = "debugpy-1.8.9-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:7e8b079323a56f719977fde9d8115590cb5e7a1cba2fcee0986ef8817116e7c1"}, + {file = "debugpy-1.8.9-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6953b335b804a41f16a192fa2e7851bdcfd92173cbb2f9f777bb934f49baab65"}, + {file = "debugpy-1.8.9-cp39-cp39-win32.whl", hash = "sha256:7e646e62d4602bb8956db88b1e72fe63172148c1e25c041e03b103a25f36673c"}, + {file = "debugpy-1.8.9-cp39-cp39-win_amd64.whl", hash = "sha256:3d9755e77a2d680ce3d2c5394a444cf42be4a592caaf246dbfbdd100ffcf7ae5"}, + {file = "debugpy-1.8.9-py2.py3-none-any.whl", hash = "sha256:cc37a6c9987ad743d9c3a14fa1b1a14b7e4e6041f9dd0c8abf8895fe7a97b899"}, + {file = "debugpy-1.8.9.zip", hash = "sha256:1339e14c7d980407248f09824d1b25ff5c5616651689f1e0f0e51bdead3ea13e"}, ] [[package]] @@ -3092,4 +3092,4 @@ didcommv2 = ["didcomm-messaging"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "0ad79fb5601c4fea9a3e7d4f978e0b0085a76b49f7934a1814e04922c2029d80" +content-hash = "abc6c8d75193033d767c0a9422a991ed7fd65a10deb77fe64377c0a3716cc99d" diff --git a/pyproject.toml b/pyproject.toml index 5ab3ec2d4a..5a505ccd5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,7 @@ pytest-asyncio = "^0.24.0" pytest-cov = "^5.0.0" pytest-ruff = "^0.4.1" pytest-xdist = "^3.6.1" -debugpy = "^1.8.8" +debugpy = "^1.8.9" [tool.poetry.extras] askar = ["aries-askar", "indy-credx", "indy-vdr", "anoncreds"] From 249ac73b03d1a3039ee58225ac09091acdaf6bb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:28:57 -0800 Subject: [PATCH 05/10] chore(deps): Bump aiohttp from 3.11.2 to 3.11.7 (#3349) Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.11.2 to 3.11.7. - [Release notes](https://github.com/aio-libs/aiohttp/releases) - [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst) - [Commits](https://github.com/aio-libs/aiohttp/compare/v3.11.2...v3.11.7) --- updated-dependencies: - dependency-name: aiohttp dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- poetry.lock | 156 ++++++++++++++++++++++++------------------------- pyproject.toml | 2 +- 2 files changed, 79 insertions(+), 79 deletions(-) diff --git a/poetry.lock b/poetry.lock index 4265229219..2ec25c70e1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -24,87 +24,87 @@ files = [ [[package]] name = "aiohttp" -version = "3.11.2" +version = "3.11.7" description = "Async http client/server framework (asyncio)" optional = false python-versions = ">=3.9" files = [ - {file = "aiohttp-3.11.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:783741f534c14957fbe657d62a34b947ec06db23d45a2fd4a8aeb73d9c84d7e6"}, - {file = "aiohttp-3.11.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:435f7a08d8aa42371a94e7c141205a9cb092ba551084b5e0c57492e6673601a3"}, - {file = "aiohttp-3.11.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c681f34e2814bc6e1eef49752b338061b94a42c92734d0be9513447d3f83718c"}, - {file = "aiohttp-3.11.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:73a664478ae1ea011b5a710fb100b115ca8b2146864fa0ce4143ff944df714b8"}, - {file = "aiohttp-3.11.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f1d06c8fd8b453c3e553c956bd3b8395100401060430572174bb7876dd95ad49"}, - {file = "aiohttp-3.11.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3b1f4844909321ef2c1cee50ddeccbd6018cd8c8d1ddddda3f553e94a5859497"}, - {file = "aiohttp-3.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdc6f8dce09281ae534eaf08a54f0d38612398375f28dad733a8885f3bf9b978"}, - {file = "aiohttp-3.11.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d2d942421cf3a1d1eceae8fa192f1fbfb74eb9d3e207d35ad2696bd2ce2c987c"}, - {file = "aiohttp-3.11.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:08ebe7a1d6c1e5ca766d68407280d69658f5f98821c2ba6c41c63cabfed159af"}, - {file = "aiohttp-3.11.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:2793d3297f3e49015140e6d3ea26142c967e07998e2fb00b6ee8d041138fbc4e"}, - {file = "aiohttp-3.11.2-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:4a23475d8d5c56e447b7752a1e2ac267c1f723f765e406c81feddcd16cdc97bc"}, - {file = "aiohttp-3.11.2-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:556564d89e2f4a6e8fe000894c03e4e84cf0b6cfa5674e425db122633ee244d1"}, - {file = "aiohttp-3.11.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:57993f406ce3f114b2a6756d7809be3ffd0cc40f33e8f8b9a4aa1b027fd4e3eb"}, - {file = "aiohttp-3.11.2-cp310-cp310-win32.whl", hash = "sha256:177b000efaf8d2f7012c649e8aee5b0bf488677b1162be5e7511aa4f9d567607"}, - {file = "aiohttp-3.11.2-cp310-cp310-win_amd64.whl", hash = "sha256:ff5d22eece44528023254b595c670dfcf9733ac6af74c4b6cb4f6a784dc3870c"}, - {file = "aiohttp-3.11.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:50e0aee4adc9abcd2109c618a8d1b2c93b85ac277b24a003ab147d91e068b06d"}, - {file = "aiohttp-3.11.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9aa4e68f1e4f303971ec42976fb170204fb5092de199034b57199a1747e78a2d"}, - {file = "aiohttp-3.11.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d84930b4145991214602372edd7305fc76b700220db79ac0dd57d3afd0f0a1ca"}, - {file = "aiohttp-3.11.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b4ec8afd362356b8798c8caa806e91deb3f0602d8ffae8e91d2d3ced2a90c35e"}, - {file = "aiohttp-3.11.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fb0544a0e8294a5a5e20d3cacdaaa9a911d7c0a9150f5264aef36e7d8fdfa07e"}, - {file = "aiohttp-3.11.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a7b0a1618060e3f5aa73d3526ca2108a16a1b6bf86612cd0bb2ddcbef9879d06"}, - {file = "aiohttp-3.11.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d878a0186023ac391861958035174d0486f3259cabf8fd94e591985468da3ea"}, - {file = "aiohttp-3.11.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e33a7eddcd07545ccf5c3ab230f60314a17dc33e285475e8405e26e21f02660"}, - {file = "aiohttp-3.11.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4d7fad8c456d180a6d2f44c41cfab4b80e2e81451815825097db48b8293f59d5"}, - {file = "aiohttp-3.11.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8d954ba0eae7f33884d27dc00629ca4389d249eb8d26ca07c30911257cae8c96"}, - {file = "aiohttp-3.11.2-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:afa55e863224e664a782effa62245df73fdfc55aee539bed6efacf35f6d4e4b7"}, - {file = "aiohttp-3.11.2-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:10a5f91c319d9d4afba812f72984816b5fcd20742232ff7ecc1610ffbf3fc64d"}, - {file = "aiohttp-3.11.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:6e8e19a80ba194db5c06915a9df23c0c06e0e9ca9a4db9386a6056cca555a027"}, - {file = "aiohttp-3.11.2-cp311-cp311-win32.whl", hash = "sha256:9c8d1db4f65bbc9d75b7b271d68fb996f1c8c81a525263862477d93611856c2d"}, - {file = "aiohttp-3.11.2-cp311-cp311-win_amd64.whl", hash = "sha256:2adb967454e10e69478ba4a8d8afbba48a7c7a8619216b7c807f8481cc66ddfb"}, - {file = "aiohttp-3.11.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:f833a80d9de9307d736b6af58c235b17ef7f90ebea7b9c49cd274dec7a66a2f1"}, - {file = "aiohttp-3.11.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:382f853516664d2ebfc75dc01da4a10fdef5edcb335fe7b45cf471ce758ecb18"}, - {file = "aiohttp-3.11.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d3a2bcf6c81639a165da93469e1e0aff67c956721f3fa9c0560f07dd1e505116"}, - {file = "aiohttp-3.11.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:de3b4d5fb5d69749104b880a157f38baeea7765c93d9cd3837cedd5b84729e10"}, - {file = "aiohttp-3.11.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0a90a0dc4b054b5af299a900bf950fe8f9e3e54322bc405005f30aa5cacc5c98"}, - {file = "aiohttp-3.11.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:32334f35824811dd20a12cc90825d000e6b50faaeaa71408d42269151a66140d"}, - {file = "aiohttp-3.11.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0cba0b8d25aa2d450762f3dd6df85498f5e7c3ad0ddeb516ef2b03510f0eea32"}, - {file = "aiohttp-3.11.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bbb2dbc2701ab7e9307ca3a8fa4999c5b28246968e0a0202a5afabf48a42e22"}, - {file = "aiohttp-3.11.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:97fba98fc5d9ccd3d33909e898d00f2494d6a9eec7cbda3d030632e2c8bb4d00"}, - {file = "aiohttp-3.11.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:0ebdf5087e2ce903d8220cc45dcece90c2199ae4395fd83ca616fcc81010db2c"}, - {file = "aiohttp-3.11.2-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:122768e3ae9ce74f981b46edefea9c6e5a40aea38aba3ac50168e6370459bf20"}, - {file = "aiohttp-3.11.2-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:5587da333b7d280a312715b843d43e734652aa382cba824a84a67c81f75b338b"}, - {file = "aiohttp-3.11.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:85de9904bc360fd29a98885d2bfcbd4e02ab33c53353cb70607f2bea2cb92468"}, - {file = "aiohttp-3.11.2-cp312-cp312-win32.whl", hash = "sha256:b470de64d17156c37e91effc109d3b032b39867000e2c126732fe01d034441f9"}, - {file = "aiohttp-3.11.2-cp312-cp312-win_amd64.whl", hash = "sha256:3f617a48b70f4843d54f52440ea1e58da6bdab07b391a3a6aed8d3b311a4cc04"}, - {file = "aiohttp-3.11.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:5d90b5a3b0f32a5fecf5dd83d828713986c019585f5cddf40d288ff77f366615"}, - {file = "aiohttp-3.11.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:d23854e5867650d40cba54d49956aad8081452aa80b2cf0d8c310633f4f48510"}, - {file = "aiohttp-3.11.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:486273d3b5af75a80c31c311988931bdd2a4b96a74d5c7f422bad948f99988ef"}, - {file = "aiohttp-3.11.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9075313f8e41b481e4cb10af405054564b0247dc335db5398ed05f8ec38787e2"}, - {file = "aiohttp-3.11.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:44b69c69c194ffacbc50165911cf023a4b1b06422d1e1199d3aea82eac17004e"}, - {file = "aiohttp-3.11.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b339d91ac9060bd6ecdc595a82dc151045e5d74f566e0864ef3f2ba0887fec42"}, - {file = "aiohttp-3.11.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64e8f5178958a9954043bc8cd10a5ae97352c3f2fc99aa01f2aebb0026010910"}, - {file = "aiohttp-3.11.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3129151378f858cdc4a0a4df355c9a0d060ab49e2eea7e62e9f085bac100551b"}, - {file = "aiohttp-3.11.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:14eb6c628432720e41b4fab1ada879d56cfe7034159849e083eb536b4c2afa99"}, - {file = "aiohttp-3.11.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:e57a10aacedcf24666f4c90d03e599f71d172d1c5e00dcf48205c445806745b0"}, - {file = "aiohttp-3.11.2-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:66e58a2e8c7609a3545c4b38fb8b01a6b8346c4862e529534f7674c5265a97b8"}, - {file = "aiohttp-3.11.2-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:9b6d15adc9768ff167614ca853f7eeb6ee5f1d55d5660e3af85ce6744fed2b82"}, - {file = "aiohttp-3.11.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:2914061f5ca573f990ec14191e6998752fa8fe50d518e3405410353c3f44aa5d"}, - {file = "aiohttp-3.11.2-cp313-cp313-win32.whl", hash = "sha256:1c2496182e577042e0e07a328d91c949da9e77a2047c7291071e734cd7a6e780"}, - {file = "aiohttp-3.11.2-cp313-cp313-win_amd64.whl", hash = "sha256:cccb2937bece1310c5c0163d0406aba170a2e5fb1f0444d7b0e7fdc9bd6bb713"}, - {file = "aiohttp-3.11.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:994cb893936dd2e1803655ae8667a45066bfd53360b148e22b4e3325cc5ea7a3"}, - {file = "aiohttp-3.11.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3666c750b73ce463a413692e3a57c60f7089e2d9116a2aa5a0f0eaf2ae325148"}, - {file = "aiohttp-3.11.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6ad9a7d2a3a0f235184426425f80bd3b26c66b24fd5fddecde66be30c01ebe6e"}, - {file = "aiohttp-3.11.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4c979fc92aba66730b66099cd5becb42d869a26c0011119bc1c2478408a8bf7a"}, - {file = "aiohttp-3.11.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:766d0ebf8703d28f854f945982aa09224d5a27a29594c70d921c43c3930fe7ac"}, - {file = "aiohttp-3.11.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:79efd1ee3827b2f16797e14b1e45021206c3271249b4d0025014466d416d7413"}, - {file = "aiohttp-3.11.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d6e069b882c1fdcbe5577dc4be372eda705180197140577a4cddb648c29d22e"}, - {file = "aiohttp-3.11.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5e9a766c346b2ed7e88937919d84ed64b4ef489dad1d8939f806ee52901dc142"}, - {file = "aiohttp-3.11.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:2b02a68b9445c70d7f5c8b578c5f5e5866b1d67ca23eb9e8bc8658ae9e3e2c74"}, - {file = "aiohttp-3.11.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:374baefcb1b6275f350da605951f5f02487a9bc84a574a7d5b696439fabd49a3"}, - {file = "aiohttp-3.11.2-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:d2f991c18132f3e505c108147925372ffe4549173b7c258cf227df1c5977a635"}, - {file = "aiohttp-3.11.2-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:34f37c59b12bc3afc52bab6fcd9cd3be82ff01c4598a84cbea934ccb3a9c54a0"}, - {file = "aiohttp-3.11.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:33af11eca7bb0f5c6ffaf5e7d9d2336c2448f9c6279b93abdd6f3c35f9ee321f"}, - {file = "aiohttp-3.11.2-cp39-cp39-win32.whl", hash = "sha256:83a70e22e0f6222effe7f29fdeba6c6023f9595e59a0479edacfbd7de4b77bb7"}, - {file = "aiohttp-3.11.2-cp39-cp39-win_amd64.whl", hash = "sha256:c28c1677ea33ccb8b14330560094cc44d3ff4fad617a544fd18beb90403fe0f1"}, - {file = "aiohttp-3.11.2.tar.gz", hash = "sha256:68d1f46f9387db3785508f5225d3acbc5825ca13d9c29f2b5cce203d5863eb79"}, + {file = "aiohttp-3.11.7-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:8bedb1f6cb919af3b6353921c71281b1491f948ca64408871465d889b4ee1b66"}, + {file = "aiohttp-3.11.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f5022504adab881e2d801a88b748ea63f2a9d130e0b2c430824682a96f6534be"}, + {file = "aiohttp-3.11.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e22d1721c978a6494adc824e0916f9d187fa57baeda34b55140315fa2f740184"}, + {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e993676c71288618eb07e20622572b1250d8713e7e00ab3aabae28cb70f3640d"}, + {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e13a05db87d3b241c186d0936808d0e4e12decc267c617d54e9c643807e968b6"}, + {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4ba8d043fed7ffa117024d7ba66fdea011c0e7602327c6d73cacaea38abe4491"}, + {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dda3ed0a7869d2fa16aa41f9961ade73aa2c2e3b2fcb0a352524e7b744881889"}, + {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:43bfd25113c1e98aec6c70e26d5f4331efbf4aa9037ba9ad88f090853bf64d7f"}, + {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3dd3e7e7c9ef3e7214f014f1ae260892286647b3cf7c7f1b644a568fd410f8ca"}, + {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:78c657ece7a73b976905ab9ec8be9ef2df12ed8984c24598a1791c58ce3b4ce4"}, + {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:db70a47987e34494b451a334605bee57a126fe8d290511349e86810b4be53b01"}, + {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:9e67531370a3b07e49b280c1f8c2df67985c790ad2834d1b288a2f13cd341c5f"}, + {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:9202f184cc0582b1db15056f2225ab4c1e3dac4d9ade50dd0613ac3c46352ac2"}, + {file = "aiohttp-3.11.7-cp310-cp310-win32.whl", hash = "sha256:2257bdd5cf54a4039a4337162cd8048f05a724380a2283df34620f55d4e29341"}, + {file = "aiohttp-3.11.7-cp310-cp310-win_amd64.whl", hash = "sha256:b7215bf2b53bc6cb35808149980c2ae80a4ae4e273890ac85459c014d5aa60ac"}, + {file = "aiohttp-3.11.7-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:cea52d11e02123f125f9055dfe0ccf1c3857225fb879e4a944fae12989e2aef2"}, + {file = "aiohttp-3.11.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3ce18f703b7298e7f7633efd6a90138d99a3f9a656cb52c1201e76cb5d79cf08"}, + {file = "aiohttp-3.11.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:670847ee6aeb3a569cd7cdfbe0c3bec1d44828bbfbe78c5d305f7f804870ef9e"}, + {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4dda726f89bfa5c465ba45b76515135a3ece0088dfa2da49b8bb278f3bdeea12"}, + {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c25b74a811dba37c7ea6a14d99eb9402d89c8d739d50748a75f3cf994cf19c43"}, + {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e5522ee72f95661e79db691310290c4618b86dff2d9b90baedf343fd7a08bf79"}, + {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1fbf41a6bbc319a7816ae0f0177c265b62f2a59ad301a0e49b395746eb2a9884"}, + {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:59ee1925b5a5efdf6c4e7be51deee93984d0ac14a6897bd521b498b9916f1544"}, + {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:24054fce8c6d6f33a3e35d1c603ef1b91bbcba73e3f04a22b4f2f27dac59b347"}, + {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:351849aca2c6f814575c1a485c01c17a4240413f960df1bf9f5deb0003c61a53"}, + {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:12724f3a211fa243570e601f65a8831372caf1a149d2f1859f68479f07efec3d"}, + {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:7ea4490360b605804bea8173d2d086b6c379d6bb22ac434de605a9cbce006e7d"}, + {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:e0bf378db07df0a713a1e32381a1b277e62ad106d0dbe17b5479e76ec706d720"}, + {file = "aiohttp-3.11.7-cp311-cp311-win32.whl", hash = "sha256:cd8d62cab363dfe713067027a5adb4907515861f1e4ce63e7be810b83668b847"}, + {file = "aiohttp-3.11.7-cp311-cp311-win_amd64.whl", hash = "sha256:bf0e6cce113596377cadda4e3ac5fb89f095bd492226e46d91b4baef1dd16f60"}, + {file = "aiohttp-3.11.7-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:4bb7493c3e3a36d3012b8564bd0e2783259ddd7ef3a81a74f0dbfa000fce48b7"}, + {file = "aiohttp-3.11.7-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:e143b0ef9cb1a2b4f74f56d4fbe50caa7c2bb93390aff52f9398d21d89bc73ea"}, + {file = "aiohttp-3.11.7-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f7c58a240260822dc07f6ae32a0293dd5bccd618bb2d0f36d51c5dbd526f89c0"}, + {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8d20cfe63a1c135d26bde8c1d0ea46fd1200884afbc523466d2f1cf517d1fe33"}, + {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:12e4d45847a174f77b2b9919719203769f220058f642b08504cf8b1cf185dacf"}, + {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cf4efa2d01f697a7dbd0509891a286a4af0d86902fc594e20e3b1712c28c0106"}, + {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9ee6a4cdcbf54b8083dc9723cdf5f41f722c00db40ccf9ec2616e27869151129"}, + {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c6095aaf852c34f42e1bd0cf0dc32d1e4b48a90bfb5054abdbb9d64b36acadcb"}, + {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1cf03d27885f8c5ebf3993a220cc84fc66375e1e6e812731f51aab2b2748f4a6"}, + {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:1a17f6a230f81eb53282503823f59d61dff14fb2a93847bf0399dc8e87817307"}, + {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:481f10a1a45c5f4c4a578bbd74cff22eb64460a6549819242a87a80788461fba"}, + {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:db37248535d1ae40735d15bdf26ad43be19e3d93ab3f3dad8507eb0f85bb8124"}, + {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9d18a8b44ec8502a7fde91446cd9c9b95ce7c49f1eacc1fb2358b8907d4369fd"}, + {file = "aiohttp-3.11.7-cp312-cp312-win32.whl", hash = "sha256:3d1c9c15d3999107cbb9b2d76ca6172e6710a12fda22434ee8bd3f432b7b17e8"}, + {file = "aiohttp-3.11.7-cp312-cp312-win_amd64.whl", hash = "sha256:018f1b04883a12e77e7fc161934c0f298865d3a484aea536a6a2ca8d909f0ba0"}, + {file = "aiohttp-3.11.7-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:241a6ca732d2766836d62c58c49ca7a93d08251daef0c1e3c850df1d1ca0cbc4"}, + {file = "aiohttp-3.11.7-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:aa3705a8d14de39898da0fbad920b2a37b7547c3afd2a18b9b81f0223b7d0f68"}, + {file = "aiohttp-3.11.7-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9acfc7f652b31853eed3b92095b0acf06fd5597eeea42e939bd23a17137679d5"}, + {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dcefcf2915a2dbdbce37e2fc1622129a1918abfe3d06721ce9f6cdac9b6d2eaa"}, + {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c1f6490dd1862af5aae6cfcf2a274bffa9a5b32a8f5acb519a7ecf5a99a88866"}, + {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f1ac5462582d6561c1c1708853a9faf612ff4e5ea5e679e99be36143d6eabd8e"}, + {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c1a6309005acc4b2bcc577ba3b9169fea52638709ffacbd071f3503264620da"}, + {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f5b973cce96793725ef63eb449adfb74f99c043c718acb76e0d2a447ae369962"}, + {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ce91a24aac80de6be8512fb1c4838a9881aa713f44f4e91dd7bb3b34061b497d"}, + {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:875f7100ce0e74af51d4139495eec4025affa1a605280f23990b6434b81df1bd"}, + {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:c171fc35d3174bbf4787381716564042a4cbc008824d8195eede3d9b938e29a8"}, + {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:ee9afa1b0d2293c46954f47f33e150798ad68b78925e3710044e0d67a9487791"}, + {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8360c7cc620abb320e1b8d603c39095101391a82b1d0be05fb2225471c9c5c52"}, + {file = "aiohttp-3.11.7-cp313-cp313-win32.whl", hash = "sha256:7a9318da4b4ada9a67c1dd84d1c0834123081e746bee311a16bb449f363d965e"}, + {file = "aiohttp-3.11.7-cp313-cp313-win_amd64.whl", hash = "sha256:fc6da202068e0a268e298d7cd09b6e9f3997736cd9b060e2750963754552a0a9"}, + {file = "aiohttp-3.11.7-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:17829f37c0d31d89aa6b8b010475a10233774771f9b6dc2cc352ea4f8ce95d9a"}, + {file = "aiohttp-3.11.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d6177077a31b1aecfc3c9070bd2f11419dbb4a70f30f4c65b124714f525c2e48"}, + {file = "aiohttp-3.11.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:badda65ac99555791eed75e234afb94686ed2317670c68bff8a4498acdaee935"}, + {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0de6466b9d742b4ee56fe1b2440706e225eb48c77c63152b1584864a236e7a50"}, + {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:04b0cc74d5a882c9dacaeeccc1444f0233212b6f5be8bc90833feef1e1ce14b9"}, + {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c7af3e50e5903d21d7b935aceed901cc2475463bc16ddd5587653548661fdb"}, + {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c63f898f683d1379b9be5afc3dd139e20b30b0b1e0bf69a3fc3681f364cf1629"}, + {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fdadc3f6a32d6eca45f9a900a254757fd7855dfb2d8f8dcf0e88f0fae3ff8eb1"}, + {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:d329300fb23e14ed1f8c6d688dfd867d1dcc3b1d7cd49b7f8c5b44e797ce0932"}, + {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:5578cf40440eafcb054cf859964bc120ab52ebe0e0562d2b898126d868749629"}, + {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:7b2f8107a3c329789f3c00b2daad0e35f548d0a55cda6291579136622099a46e"}, + {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:43dd89a6194f6ab02a3fe36b09e42e2df19c211fc2050ce37374d96f39604997"}, + {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:d2fa6fc7cc865d26ff42480ac9b52b8c9b7da30a10a6442a9cdf429de840e949"}, + {file = "aiohttp-3.11.7-cp39-cp39-win32.whl", hash = "sha256:a7d9a606355655617fee25dd7e54d3af50804d002f1fd3118dd6312d26692d70"}, + {file = "aiohttp-3.11.7-cp39-cp39-win_amd64.whl", hash = "sha256:53c921b58fdc6485d6b2603e0132bb01cd59b8f0620ffc0907f525e0ba071687"}, + {file = "aiohttp-3.11.7.tar.gz", hash = "sha256:01a8aca4af3da85cea5c90141d23f4b0eee3cbecfd33b029a45a80f28c66c668"}, ] [package.dependencies] @@ -3092,4 +3092,4 @@ didcommv2 = ["didcomm-messaging"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "abc6c8d75193033d767c0a9422a991ed7fd65a10deb77fe64377c0a3716cc99d" +content-hash = "c9121c319eb42db81805bec50a15a153e7ef4f8bef5231a6b12a7a74b4ffe290" diff --git a/pyproject.toml b/pyproject.toml index 5a505ccd5c..de8a3531bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ repository = "https://github.com/openwallet-foundation/acapy" [tool.poetry.dependencies] python = "^3.12" -aiohttp = "~3.11.2" +aiohttp = "~3.11.7" aiohttp-apispec-acapy = "~3.0.2" aiohttp-cors = "~0.7.0" apispec = "^6.6.0" From eb52b05a97f2fcfe6e69cdebf8f8da4cd8b073d1 Mon Sep 17 00:00:00 2001 From: Mourits de Beer <31511766+ff137@users.noreply.github.com> Date: Wed, 27 Nov 2024 20:11:12 +0200 Subject: [PATCH 06/10] :art: Sync Ruff version in configs and apply formatting (#3358) * :arrow_up: Upgrade ruff version in pre-commit config and lint workflow Signed-off-by: ff137 * :art: Apply ruff formatting Signed-off-by: ff137 * :arrow_up: Upgrade pre-commit hook version Signed-off-by: ff137 --------- Signed-off-by: ff137 --- .github/workflows/format.yml | 2 +- .pre-commit-config.yaml | 4 +- acapy_agent/commands/tests/test_help.py | 18 +- acapy_agent/commands/tests/test_provision.py | 43 +- acapy_agent/commands/tests/test_start.py | 51 +- acapy_agent/commands/tests/test_upgrade.py | 526 ++++--- acapy_agent/config/tests/test_ledger.py | 102 +- acapy_agent/config/tests/test_logging.py | 7 +- acapy_agent/config/tests/test_wallet.py | 94 +- .../connections/tests/test_base_manager.py | 183 ++- acapy_agent/core/tests/test_conductor.py | 1326 ++++++++++------- acapy_agent/core/tests/test_dispatcher.py | 68 +- acapy_agent/core/tests/test_oob_processor.py | 25 +- acapy_agent/indy/tests/test_verifier.py | 11 +- .../tests/test_indy_vdr_manager.py | 52 +- acapy_agent/ledger/tests/test_indy_vdr.py | 62 +- acapy_agent/ledger/tests/test_routes.py | 100 +- .../tests/test_routes.py | 44 +- .../messaging/jsonld/tests/test_routes.py | 42 +- .../messaging/schemas/tests/test_routes.py | 44 +- .../multitenant/admin/tests/test_routes.py | 73 +- acapy_agent/multitenant/tests/test_base.py | 74 +- acapy_agent/multitenant/tests/test_manager.py | 9 +- .../multitenant/tests/test_route_manager.py | 49 +- .../tests/test_single_wallet_askar_manager.py | 26 +- .../actionmenu/v1_0/tests/test_routes.py | 111 +- .../basicmessage/v1_0/tests/test_routes.py | 38 +- .../connections/v1_0/tests/test_manager.py | 411 ++--- .../connections/v1_0/tests/test_routes.py | 272 ++-- .../test_keylist_update_response_handler.py | 9 +- .../tests/test_mediation_grant_handler.py | 34 +- .../v1_0/tests/test_mediation_manager.py | 26 +- .../v1_0/tests/test_route_manager.py | 168 ++- .../v1_0/tests/test_routes.py | 623 ++++---- .../did_rotate/v1_0/tests/test_manager.py | 9 +- .../didexchange/v1_0/tests/test_manager.py | 705 +++++---- .../didexchange/v1_0/tests/test_routes.py | 130 +- .../v1_0/handlers/tests/test_query_handler.py | 13 +- .../discovery/v1_0/tests/test_manager.py | 126 +- .../discovery/v1_0/tests/test_routes.py | 62 +- .../tests/test_disclosures_handler.py | 38 +- .../handlers/tests/test_queries_handler.py | 13 +- .../discovery/v2_0/tests/test_manager.py | 180 ++- .../discovery/v2_0/tests/test_routes.py | 62 +- .../v1_0/tests/test_manager.py | 18 +- .../v1_0/tests/test_routes.py | 569 ++++--- .../introduction/v0_1/tests/test_routes.py | 11 +- .../tests/test_credential_issue_handler.py | 11 +- .../tests/test_credential_offer_handler.py | 11 +- .../tests/test_credential_proposal_handler.py | 11 +- .../tests/test_credential_request_handler.py | 20 +- .../models/tests/test_credential_exchange.py | 11 +- .../v1_0/tests/test_manager.py | 218 +-- .../v1_0/tests/test_routes.py | 563 +++---- .../formats/anoncreds/tests/test_handler.py | 35 +- .../v2_0/formats/indy/tests/test_handler.py | 35 +- .../formats/ld_proof/tests/test_handler.py | 92 +- .../handlers/tests/test_cred_offer_handler.py | 26 +- .../tests/test_cred_proposal_handler.py | 26 +- .../tests/test_cred_request_handler.py | 44 +- .../v2_0/models/tests/test_cred_ex_record.py | 11 +- .../v2_0/tests/test_manager.py | 258 ++-- .../v2_0/tests/test_routes.py | 719 ++++----- .../out_of_band/v1_0/tests/test_manager.py | 451 +++--- .../out_of_band/v1_0/tests/test_routes.py | 80 +- .../dif/tests/test_pres_exch_handler.py | 162 +- .../test_presentation_request_handler.py | 130 +- .../v1_0/models/tests/test_record.py | 11 +- .../present_proof/v1_0/tests/test_manager.py | 197 +-- .../present_proof/v1_0/tests/test_routes.py | 782 +++++----- .../v2_0/formats/dif/tests/test_handler.py | 36 +- .../tests/test_pres_request_handler.py | 221 +-- .../v2_0/models/tests/test_record.py | 11 +- .../present_proof/v2_0/tests/test_manager.py | 375 +++-- .../v2_0/tests/test_manager_anoncreds.py | 375 +++-- .../present_proof/v2_0/tests/test_routes.py | 546 ++++--- .../v2_0/tests/test_routes_anoncreds.py | 546 ++++--- .../handlers/tests/test_forward_handler.py | 16 +- .../trustping/v1_0/tests/test_routes.py | 34 +- .../default/tests/test_legacy_peer.py | 19 +- .../tests/test_issuer_rev_reg_record.py | 46 +- .../models/tests/test_revocation_registry.py | 12 +- acapy_agent/revocation/tests/test_indy.py | 17 +- acapy_agent/revocation/tests/test_manager.py | 224 +-- acapy_agent/revocation/tests/test_routes.py | 521 ++++--- .../tests/test_manager.py | 114 +- .../revocation_anoncreds/tests/test_routes.py | 215 +-- acapy_agent/settings/tests/test_routes.py | 11 +- .../storage/tests/test_askar_storage.py | 134 +- acapy_agent/tests/test_main.py | 10 +- .../transport/inbound/tests/test_session.py | 18 +- .../transport/outbound/tests/test_manager.py | 39 +- .../transport/queue/tests/test_basic_queue.py | 34 +- acapy_agent/utils/tests/test_classloader.py | 9 +- acapy_agent/utils/tests/test_task_queue.py | 9 +- acapy_agent/vc/vc_ld/tests/test_manager.py | 21 +- .../wallet/tests/test_anoncreds_upgrade.py | 24 +- acapy_agent/wallet/tests/test_crypto.py | 13 +- 98 files changed, 8145 insertions(+), 6072 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 74302d3ee4..1f7584e464 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -17,5 +17,5 @@ jobs: - name: Ruff Format and Lint Check uses: chartboost/ruff-action@v1 with: - version: 0.5.7 + version: 0.8.0 args: "format --check" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b9edb79c9..9374f5f431 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook - rev: v9.16.0 + rev: v9.18.0 hooks: - id: commitlint stages: [commit-msg] @@ -8,7 +8,7 @@ repos: additional_dependencies: ['@commitlint/config-conventional'] - repo: https://github.com/astral-sh/ruff-pre-commit # Ensure this is synced with pyproject.toml - rev: v0.5.7 + rev: v0.8.0 hooks: # Run the linter - id: ruff diff --git a/acapy_agent/commands/tests/test_help.py b/acapy_agent/commands/tests/test_help.py index 562b371ee2..1e1360328f 100644 --- a/acapy_agent/commands/tests/test_help.py +++ b/acapy_agent/commands/tests/test_help.py @@ -5,11 +5,10 @@ class TestHelp(IsolatedAsyncioTestCase): def test_exec_help(self): - with mock.patch.object( - command.ArgumentParser, "print_help" - ) as mock_print_help, mock.patch( - "builtins.print", mock.MagicMock() - ) as mock_print: + with ( + mock.patch.object(command.ArgumentParser, "print_help") as mock_print_help, + mock.patch("builtins.print", mock.MagicMock()) as mock_print, + ): command.execute([]) mock_print_help.assert_called_once() @@ -17,10 +16,9 @@ def test_exec_help(self): mock_print.assert_called_once_with(command.__version__) def test_main(self): - with mock.patch.object( - command, "__name__", "__main__" - ) as mock_name, mock.patch.object( - command, "execute", mock.MagicMock() - ) as mock_execute: + with ( + mock.patch.object(command, "__name__", "__main__") as mock_name, + mock.patch.object(command, "execute", mock.MagicMock()) as mock_execute, + ): command.main() mock_execute.assert_called_once diff --git a/acapy_agent/commands/tests/test_provision.py b/acapy_agent/commands/tests/test_provision.py index 65d0d488bd..ed50bb9eb8 100644 --- a/acapy_agent/commands/tests/test_provision.py +++ b/acapy_agent/commands/tests/test_provision.py @@ -21,17 +21,20 @@ def test_bad_calls(self): async def test_provision_ledger_configured(self): profile = mock.MagicMock(close=mock.CoroutineMock()) - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), + ), + mock.patch.object( + test_module, "ledger_config", mock.CoroutineMock(return_value=True) ), - ), mock.patch.object( - test_module, "ledger_config", mock.CoroutineMock(return_value=True) ): await test_module.provision({}) @@ -44,9 +47,10 @@ async def test_provision_config_x(self): await test_module.provision({}) def test_main(self): - with mock.patch.object(test_module, "__name__", "__main__"), mock.patch.object( - test_module, "execute", mock.MagicMock() - ) as mock_execute: + with ( + mock.patch.object(test_module, "__name__", "__main__"), + mock.patch.object(test_module, "execute", mock.MagicMock()) as mock_execute, + ): test_module.main() mock_execute.assert_called_once @@ -55,12 +59,13 @@ async def test_provision_should_store_provided_mediation_invite(self): mediation_invite = "test-invite" test_profile = await create_test_profile() - with mock.patch.object( - test_module.MediationInviteStore, "store" - ) as invite_store, mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock(return_value=(test_profile, mock.MagicMock())), + with ( + mock.patch.object(test_module.MediationInviteStore, "store") as invite_store, + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock(return_value=(test_profile, mock.MagicMock())), + ), ): # when await test_module.provision({"mediation.invite": mediation_invite}) diff --git a/acapy_agent/commands/tests/test_start.py b/acapy_agent/commands/tests/test_start.py index 451ab584bb..cac10b8df6 100644 --- a/acapy_agent/commands/tests/test_start.py +++ b/acapy_agent/commands/tests/test_start.py @@ -25,22 +25,23 @@ async def test_start_shutdown_app(self): await test_module.shutdown_app(mock_conductor) def test_exec_start(self): - with mock.patch.object( - # Normally this would be a CoroutineMock. However, it is awaited by - # run_loop, which is mocked out. So we mock it as a MagicMock. - test_module, - "start_app", - mock.MagicMock(), - ) as start_app, mock.patch.object( - test_module, "run_loop" - ) as run_loop, mock.patch.object( - # Same here as note above - test_module, - "shutdown_app", - mock.MagicMock(), - ) as shutdown_app, mock.patch.object( - test_module, "uvloop", mock.MagicMock() - ) as mock_uvloop: + with ( + mock.patch.object( + # Normally this would be a CoroutineMock. However, it is awaited by + # run_loop, which is mocked out. So we mock it as a MagicMock. + test_module, + "start_app", + mock.MagicMock(), + ) as start_app, + mock.patch.object(test_module, "run_loop") as run_loop, + mock.patch.object( + # Same here as note above + test_module, + "shutdown_app", + mock.MagicMock(), + ) as shutdown_app, + mock.patch.object(test_module, "uvloop", mock.MagicMock()) as mock_uvloop, + ): mock_uvloop.install = mock.MagicMock() test_module.execute( [ @@ -102,11 +103,10 @@ async def test_run_loop_init_x(self): startup_call = startup() shutdown = mock.CoroutineMock() shutdown_call = shutdown() - with mock.patch.object( - test_module, "asyncio", autospec=True - ) as mock_asyncio, mock.patch.object( - test_module, "LOGGER", autospec=True - ) as mock_logger: + with ( + mock.patch.object(test_module, "asyncio", autospec=True) as mock_asyncio, + mock.patch.object(test_module, "LOGGER", autospec=True) as mock_logger, + ): test_module.run_loop(startup_call, shutdown_call) mock_add = mock_asyncio.get_event_loop.return_value.add_signal_handler mock_add.assert_called_once() @@ -135,10 +135,9 @@ async def test_run_loop_init_x(self): mock_logger.exception.assert_called_once() def test_main(self): - with mock.patch.object( - test_module, "__name__", "__main__" - ) as mock_name, mock.patch.object( - test_module, "execute", mock.MagicMock() - ) as mock_execute: + with ( + mock.patch.object(test_module, "__name__", "__main__") as mock_name, + mock.patch.object(test_module, "execute", mock.MagicMock()) as mock_execute, + ): test_module.main() mock_execute.assert_called_once diff --git a/acapy_agent/commands/tests/test_upgrade.py b/acapy_agent/commands/tests/test_upgrade.py index 51a33640a3..41728221c8 100644 --- a/acapy_agent/commands/tests/test_upgrade.py +++ b/acapy_agent/commands/tests/test_upgrade.py @@ -47,20 +47,24 @@ def test_bad_calls(self): test_module.execute(["bad"]) async def test_upgrade_storage_from_version_included(self): - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), + ), + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), ), - ), mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()): + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + ): await test_module.upgrade( settings={ "upgrade.config_path": "./acapy_agent/commands/default_version_upgrade_config.yml", @@ -69,20 +73,24 @@ async def test_upgrade_storage_from_version_included(self): ) async def test_upgrade_storage_missing_from_version(self): - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), + ), + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), ), - ), mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()): + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + ): await test_module.upgrade(settings={}) async def test_upgrade_from_version(self): @@ -91,11 +99,14 @@ async def test_upgrade_from_version(self): "upgrade.from_version": "v0.7.2", } ) - with mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()): + with ( + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), + ), + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + ): await test_module.upgrade( profile=self.profile, ) @@ -109,11 +120,14 @@ async def test_upgrade_all_subwallets(self): "upgrade.page_size": 1, } ) - with mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()): + with ( + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), + ), + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + ): await test_module.upgrade( profile=self.profile, ) @@ -131,11 +145,14 @@ async def test_upgrade_specified_subwallets(self): "upgrade.force_upgrade": True, } ) - with mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()): + with ( + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), + ), + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + ): await test_module.upgrade( profile=self.profile, ) @@ -148,11 +165,14 @@ async def test_upgrade_specified_subwallets(self): "upgrade.page_size": 1, } ) - with mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()): + with ( + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), + ), + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + ): await test_module.upgrade( profile=self.profile, ) @@ -164,29 +184,32 @@ async def test_upgrade_callable(self): type_filter="acapy_version", tag_query={} ) await storage.delete_record(version_storage_record) - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), ), - ), mock.patch.object( - test_module.yaml, - "safe_load", - mock.MagicMock( - return_value={ - "v0.7.2": { - "resave_records": { - "base_record_path": [ - "acapy_agent.connections.models.conn_record.ConnRecord" - ] + mock.patch.object( + test_module.yaml, + "safe_load", + mock.MagicMock( + return_value={ + "v0.7.2": { + "resave_records": { + "base_record_path": [ + "acapy_agent.connections.models.conn_record.ConnRecord" + ] + }, + "update_existing_records": True, }, - "update_existing_records": True, - }, - } + } + ), ), ): await test_module.upgrade( @@ -202,30 +225,33 @@ async def test_upgrade_callable_named_tag(self): type_filter="acapy_version", tag_query={} ) await storage.delete_record(version_storage_record) - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), ), - ), mock.patch.object( - test_module.yaml, - "safe_load", - mock.MagicMock( - return_value={ - "v0.7.2": { - "resave_records": { - "base_record_path": [ - "acapy_agent.connections.models.conn_record.ConnRecord" - ] + mock.patch.object( + test_module.yaml, + "safe_load", + mock.MagicMock( + return_value={ + "v0.7.2": { + "resave_records": { + "base_record_path": [ + "acapy_agent.connections.models.conn_record.ConnRecord" + ] + }, + "update_existing_records": True, }, - "update_existing_records": True, - }, - "fix_issue_rev_reg": {"fix_issue_rev_reg_records": True}, - } + "fix_issue_rev_reg": {"fix_issue_rev_reg_records": True}, + } + ), ), ): await test_module.upgrade( @@ -265,20 +291,24 @@ async def test_upgrade_missing_from_version(self): type_filter="acapy_version", tag_query={} ) await storage.delete_record(version_storage_record) - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), + ), + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), ), - ), mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()): + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + ): with self.assertRaises(UpgradeError) as ctx: await test_module.upgrade( settings={ @@ -296,30 +326,33 @@ async def test_upgrade_x_callable_not_set(self): type_filter="acapy_version", tag_query={} ) await storage.delete_record(version_storage_record) - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), ), - ), mock.patch.object( - test_module.yaml, - "safe_load", - mock.MagicMock( - return_value={ - "v0.7.2": { - "resave_records": { - "base_record_path": [ - "acapy_agent.connections.models.conn_record.ConnRecord" - ] + mock.patch.object( + test_module.yaml, + "safe_load", + mock.MagicMock( + return_value={ + "v0.7.2": { + "resave_records": { + "base_record_path": [ + "acapy_agent.connections.models.conn_record.ConnRecord" + ] + }, + "update_existing_records": True, }, - "update_existing_records": True, - }, - "v0.6.0": {"update_existing_records_b": True}, - } + "v0.6.0": {"update_existing_records_b": True}, + } + ), ), ): with self.assertRaises(UpgradeError) as ctx: @@ -331,28 +364,31 @@ async def test_upgrade_x_callable_not_set(self): assert "No function specified for" in str(ctx.exception) async def test_upgrade_x_class_not_found(self): - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), ), - ), mock.patch.object( - test_module.yaml, - "safe_load", - mock.MagicMock( - return_value={ - "v0.7.2": { - "resave_records": { - "base_record_path": [ - "acapy_agent.connections.models.conn_record.Invalid" - ], - } - }, - } + mock.patch.object( + test_module.yaml, + "safe_load", + mock.MagicMock( + return_value={ + "v0.7.2": { + "resave_records": { + "base_record_path": [ + "acapy_agent.connections.models.conn_record.Invalid" + ], + } + }, + } + ), ), ): with self.assertRaises(UpgradeError) as ctx: @@ -364,28 +400,34 @@ async def test_upgrade_x_class_not_found(self): assert "Unknown Record type" in str(ctx.exception) async def test_execute(self): - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), + ), + mock.patch.object( + ConnRecord, + "query", + mock.CoroutineMock(return_value=[ConnRecord()]), + ), + mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), + mock.patch.object( + asyncio, "get_event_loop", mock.MagicMock() + ) as mock_get_event_loop, + mock.patch.object( + # Normally, this would be a CoroutingMock. However, the coroutine + # is awaited by run_until_complete, which is mocked out. + # Use MagicMock to prevent unawaited coroutine warnings. + test_module, + "upgrade", + mock.MagicMock(), ), - ), mock.patch.object( - ConnRecord, - "query", - mock.CoroutineMock(return_value=[ConnRecord()]), - ), mock.patch.object(ConnRecord, "save", mock.CoroutineMock()), mock.patch.object( - asyncio, "get_event_loop", mock.MagicMock() - ) as mock_get_event_loop, mock.patch.object( - # Normally, this would be a CoroutingMock. However, the coroutine - # is awaited by run_until_complete, which is mocked out. - # Use MagicMock to prevent unawaited coroutine warnings. - test_module, - "upgrade", - mock.MagicMock(), ): mock_get_event_loop.return_value = mock.MagicMock( run_until_complete=mock.MagicMock(), @@ -401,28 +443,31 @@ async def test_execute(self): ) async def test_upgrade_x_invalid_record_type(self): - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), ), - ), mock.patch.object( - test_module.yaml, - "safe_load", - mock.MagicMock( - return_value={ - "v0.7.2": { - "resave_records": { - "base_exch_record_path": [ - "acapy_agent.connections.models.connection_target.ConnectionTarget" - ], + mock.patch.object( + test_module.yaml, + "safe_load", + mock.MagicMock( + return_value={ + "v0.7.2": { + "resave_records": { + "base_exch_record_path": [ + "acapy_agent.connections.models.connection_target.ConnectionTarget" + ], + } } } - } + ), ), ): with self.assertRaises(UpgradeError) as ctx: @@ -434,35 +479,38 @@ async def test_upgrade_x_invalid_record_type(self): assert "Only BaseRecord can be resaved" in str(ctx.exception) async def test_upgrade_force(self): - with mock.patch.object( - test_module, - "wallet_config", - mock.CoroutineMock( - return_value=( - self.profile, - mock.CoroutineMock(did="public DID", verkey="verkey"), - ) + with ( + mock.patch.object( + test_module, + "wallet_config", + mock.CoroutineMock( + return_value=( + self.profile, + mock.CoroutineMock(did="public DID", verkey="verkey"), + ) + ), ), - ), mock.patch.object( - test_module.yaml, - "safe_load", - mock.MagicMock( - return_value={ - "v0.7.2": { - "resave_records": { - "base_record_path": [ - "acapy_agent.connections.models.conn_record.ConnRecord" - ], + mock.patch.object( + test_module.yaml, + "safe_load", + mock.MagicMock( + return_value={ + "v0.7.2": { + "resave_records": { + "base_record_path": [ + "acapy_agent.connections.models.conn_record.ConnRecord" + ], + }, + "update_existing_records": True, }, - "update_existing_records": True, - }, - "v0.7.3": { - "update_existing_records": True, - }, - "v0.7.1": { - "update_existing_records": False, - }, - } + "v0.7.3": { + "update_existing_records": True, + }, + "v0.7.1": { + "update_existing_records": False, + }, + } + ), ), ): await test_module.upgrade( @@ -511,9 +559,10 @@ async def test_upgrade_x_params(self): assert "upgrade requires either profile or settings" in str(ctx.exception) def test_main(self): - with mock.patch.object(test_module, "__name__", "__main__"), mock.patch.object( - test_module, "execute", mock.MagicMock() - ) as mock_execute: + with ( + mock.patch.object(test_module, "__name__", "__main__"), + mock.patch.object(test_module, "execute", mock.MagicMock()) as mock_execute, + ): test_module.main() mock_execute.assert_called_once @@ -711,30 +760,31 @@ async def test_upgrade_explicit_check(self): await test_module.upgrade(profile=self.profile) assert "Explicit upgrade flag with critical value found" in str(ctx.exception) - with mock.patch.object( - test_module, "LOGGER", mock.MagicMock() - ) as mock_logger, mock.patch.object( - test_module.yaml, - "safe_load", - mock.MagicMock( - return_value={ - "v0.7.2": { - "resave_records": { - "base_record_path": [ - "acapy_agent.connections.models.conn_record.ConnRecord" - ], + with ( + mock.patch.object(test_module, "LOGGER", mock.MagicMock()) as mock_logger, + mock.patch.object( + test_module.yaml, + "safe_load", + mock.MagicMock( + return_value={ + "v0.7.2": { + "resave_records": { + "base_record_path": [ + "acapy_agent.connections.models.conn_record.ConnRecord" + ], + }, + "update_existing_records": True, }, - "update_existing_records": True, - }, - "v0.7.3": { - "update_existing_records": True, - "explicit_upgrade": "warning", - }, - "v0.7.1": { - "update_existing_records": True, - "explicit_upgrade": "warning", - }, - } + "v0.7.3": { + "update_existing_records": True, + "explicit_upgrade": "warning", + }, + "v0.7.1": { + "update_existing_records": True, + "explicit_upgrade": "warning", + }, + } + ), ), ): await test_module.upgrade(profile=self.profile) diff --git a/acapy_agent/config/tests/test_ledger.py b/acapy_agent/config/tests/test_ledger.py index 5c2940305b..813e9c5d88 100644 --- a/acapy_agent/config/tests/test_ledger.py +++ b/acapy_agent/config/tests/test_ledger.py @@ -317,11 +317,14 @@ async def test_load_multiple_genesis_transactions_from_config_a(self): }, ], } - with mock.patch.object( - test_module, - "fetch_genesis_transactions", - mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), - ), mock.patch("builtins.open", mock.MagicMock()) as mock_open: + with ( + mock.patch.object( + test_module, + "fetch_genesis_transactions", + mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), + ), + mock.patch("builtins.open", mock.MagicMock()) as mock_open, + ): mock_open.return_value = mock.MagicMock( __enter__=mock.MagicMock( return_value=mock.MagicMock( @@ -412,11 +415,14 @@ async def test_load_multiple_genesis_transactions_from_config_b(self): ], "ledger.genesis_url": "http://localhost:9000/genesis", } - with mock.patch.object( - test_module, - "fetch_genesis_transactions", - mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), - ), mock.patch("builtins.open", mock.MagicMock()) as mock_open: + with ( + mock.patch.object( + test_module, + "fetch_genesis_transactions", + mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), + ), + mock.patch("builtins.open", mock.MagicMock()) as mock_open, + ): mock_open.return_value = mock.MagicMock( __enter__=mock.MagicMock( return_value=mock.MagicMock( @@ -474,11 +480,14 @@ async def test_load_multiple_genesis_transactions_config_error_a(self): }, ], } - with mock.patch.object( - test_module, - "fetch_genesis_transactions", - mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), - ), mock.patch("builtins.open", mock.MagicMock()) as mock_open: + with ( + mock.patch.object( + test_module, + "fetch_genesis_transactions", + mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), + ), + mock.patch("builtins.open", mock.MagicMock()) as mock_open, + ): mock_open.return_value = mock.MagicMock( __enter__=mock.MagicMock( return_value=mock.MagicMock( @@ -537,11 +546,14 @@ async def test_load_multiple_genesis_transactions_multiple_write(self): }, ] } - with mock.patch.object( - test_module, - "fetch_genesis_transactions", - mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), - ), mock.patch("builtins.open", mock.MagicMock()) as mock_open: + with ( + mock.patch.object( + test_module, + "fetch_genesis_transactions", + mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), + ), + mock.patch("builtins.open", mock.MagicMock()) as mock_open, + ): mock_open.return_value = mock.MagicMock( __enter__=mock.MagicMock( return_value=mock.MagicMock( @@ -596,11 +608,14 @@ async def test_load_multiple_genesis_transactions_from_config_io_x(self): }, ], } - with mock.patch.object( - test_module, - "fetch_genesis_transactions", - mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), - ), mock.patch("builtins.open", mock.MagicMock()) as mock_open: + with ( + mock.patch.object( + test_module, + "fetch_genesis_transactions", + mock.CoroutineMock(return_value=TEST_GENESIS_TXNS), + ), + mock.patch("builtins.open", mock.MagicMock()) as mock_open, + ): mock_open.side_effect = IOError("no read permission") with self.assertRaises(test_module.ConfigError): await test_module.load_multiple_genesis_transactions_from_config(settings) @@ -629,31 +644,38 @@ async def test_ledger_accept_taa_tty(self, mock_stdout): "aml_record": {"aml": ["wallet_agreement", "on_file"]}, } - with mock.patch.object( - test_module, "use_asyncio_event_loop", mock.MagicMock() - ), mock.patch.object( - test_module.prompt_toolkit, "prompt", mock.CoroutineMock() - ) as mock_prompt: + with ( + mock.patch.object(test_module, "use_asyncio_event_loop", mock.MagicMock()), + mock.patch.object( + test_module.prompt_toolkit, "prompt", mock.CoroutineMock() + ) as mock_prompt, + ): mock_prompt.side_effect = EOFError() assert not await test_module.accept_taa( None, self.profile, taa_info, provision=False ) - with mock.patch.object( - test_module, "use_asyncio_event_loop", mock.MagicMock() - ) as mock_use_aio_loop, mock.patch.object( - test_module.prompt_toolkit, "prompt", mock.CoroutineMock() - ) as mock_prompt: + with ( + mock.patch.object( + test_module, "use_asyncio_event_loop", mock.MagicMock() + ) as mock_use_aio_loop, + mock.patch.object( + test_module.prompt_toolkit, "prompt", mock.CoroutineMock() + ) as mock_prompt, + ): mock_prompt.return_value = "x" assert not await test_module.accept_taa( None, self.profile, taa_info, provision=False ) - with mock.patch.object( - test_module, "use_asyncio_event_loop", mock.MagicMock() - ) as mock_use_aio_loop, mock.patch.object( - test_module.prompt_toolkit, "prompt", mock.CoroutineMock() - ) as mock_prompt: + with ( + mock.patch.object( + test_module, "use_asyncio_event_loop", mock.MagicMock() + ) as mock_use_aio_loop, + mock.patch.object( + test_module.prompt_toolkit, "prompt", mock.CoroutineMock() + ) as mock_prompt, + ): mock_ledger = mock.MagicMock(accept_txn_author_agreement=mock.CoroutineMock()) mock_prompt.return_value = "" assert await test_module.accept_taa( diff --git a/acapy_agent/config/tests/test_logging.py b/acapy_agent/config/tests/test_logging.py index cf23074568..0f027b2124 100644 --- a/acapy_agent/config/tests/test_logging.py +++ b/acapy_agent/config/tests/test_logging.py @@ -126,9 +126,10 @@ def test_load_resource(self): assert result is None # Testing package resource access with encoding (text mode) - with mock.patch("importlib.resources.files") as mock_files, mock.patch( - "io.TextIOWrapper", mock.MagicMock() - ) as mock_text_io_wrapper: + with ( + mock.patch("importlib.resources.files") as mock_files, + mock.patch("io.TextIOWrapper", mock.MagicMock()) as mock_text_io_wrapper, + ): # Setup the mocks mock_resource_path = mock.MagicMock() mock_files.return_value.joinpath.return_value = mock_resource_path diff --git a/acapy_agent/config/tests/test_wallet.py b/acapy_agent/config/tests/test_wallet.py index 3fbcae8593..6f360dcf06 100644 --- a/acapy_agent/config/tests/test_wallet.py +++ b/acapy_agent/config/tests/test_wallet.py @@ -67,10 +67,13 @@ async def test_wallet_config_existing_replace(self): ) self.injector.bind_instance(BaseWallet, mock_wallet) - with mock.patch.object( - test_module, "seed_to_did", mock.MagicMock() - ) as mock_seed_to_did, mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "seed_to_did", mock.MagicMock() + ) as mock_seed_to_did, + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): mock_seed_to_did.return_value = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -106,10 +109,13 @@ async def test_wallet_config_existing_open(self): self.context.injector.bind_instance(ProfileManager, MockManager(self.profile)) - with mock.patch.object( - test_module, "seed_to_did", mock.MagicMock() - ) as mock_seed_to_did, mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "seed_to_did", mock.MagicMock() + ) as mock_seed_to_did, + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): mock_seed_to_did.return_value = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -135,10 +141,11 @@ async def test_wallet_config_auto_provision(self): ) self.injector.bind_instance(BaseWallet, mock_wallet) - with mock.patch.object( - MockManager, "open", mock.CoroutineMock() - ) as mock_mgr_open, mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object(MockManager, "open", mock.CoroutineMock()) as mock_mgr_open, + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): mock_mgr_open.side_effect = test_module.ProfileNotFoundError() @@ -180,12 +187,15 @@ async def test_wallet_config_bad_seed_x(self): ) self.injector.bind_instance(BaseWallet, mock_wallet) - with mock.patch.object( - test_module, - "seed_to_did", - mock.MagicMock(return_value="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), - ), mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, + "seed_to_did", + mock.MagicMock(return_value="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), + ), + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): with self.assertRaises(test_module.ConfigError): await test_module.wallet_config(self.context, provision=True) @@ -206,10 +216,13 @@ async def test_wallet_config_seed_local(self): ) self.injector.bind_instance(BaseWallet, mock_wallet) - with mock.patch.object( - test_module, "seed_to_did", mock.MagicMock() - ) as mock_seed_to_did, mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "seed_to_did", mock.MagicMock() + ) as mock_seed_to_did, + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): mock_seed_to_did.return_value = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -230,12 +243,15 @@ async def test_wallet_config_seed_public(self): ) self.injector.bind_instance(BaseWallet, mock_wallet) - with mock.patch.object( - test_module, - "seed_to_did", - mock.MagicMock(return_value="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), - ), mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, + "seed_to_did", + mock.MagicMock(return_value="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), + ), + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): await test_module.wallet_config(self.context, provision=True) @@ -249,10 +265,13 @@ async def test_wallet_config_seed_no_public_did(self): ) self.injector.bind_instance(BaseWallet, mock_wallet) - with mock.patch.object( - test_module, "seed_to_did", mock.MagicMock() - ) as mock_seed_to_did, mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "seed_to_did", mock.MagicMock() + ) as mock_seed_to_did, + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): mock_seed_to_did.return_value = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -275,10 +294,13 @@ async def test_wallet_config_for_key_derivation_method(self): ) self.injector.bind_instance(BaseWallet, mock_wallet) - with mock.patch.object( - MockManager, "provision", mock.CoroutineMock() - ) as mock_mgr_provision, mock.patch.object( - test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + with ( + mock.patch.object( + MockManager, "provision", mock.CoroutineMock() + ) as mock_mgr_provision, + mock.patch.object( + test_module, "add_or_update_version_to_storage", mock.CoroutineMock() + ), ): mock_mgr_provision.return_value = self.profile diff --git a/acapy_agent/connections/tests/test_base_manager.py b/acapy_agent/connections/tests/test_base_manager.py index 84089929ca..12aa05d8a7 100644 --- a/acapy_agent/connections/tests/test_base_manager.py +++ b/acapy_agent/connections/tests/test_base_manager.py @@ -1190,11 +1190,14 @@ async def test_resolve_inbound_connection(self): mock_conn = mock.MagicMock() mock_conn.connection_id = "dummy" - with mock.patch.object( - AskarWallet, "get_local_did_for_verkey", mock.CoroutineMock() - ) as mock_wallet_get_local_did_for_verkey, mock.patch.object( - self.manager, "find_connection", mock.CoroutineMock() - ) as mock_mgr_find_conn: + with ( + mock.patch.object( + AskarWallet, "get_local_did_for_verkey", mock.CoroutineMock() + ) as mock_wallet_get_local_did_for_verkey, + mock.patch.object( + self.manager, "find_connection", mock.CoroutineMock() + ) as mock_mgr_find_conn, + ): mock_wallet_get_local_did_for_verkey.return_value = DIDInfo( self.test_did, self.test_verkey, @@ -1216,11 +1219,14 @@ async def test_resolve_inbound_connection_injector_error(self): mock_conn = mock.MagicMock() mock_conn.connection_id = "dummy" - with mock.patch.object( - AskarWallet, "get_local_did_for_verkey", mock.CoroutineMock() - ) as mock_wallet_get_local_did_for_verkey, mock.patch.object( - self.manager, "find_connection", mock.CoroutineMock() - ) as mock_mgr_find_conn: + with ( + mock.patch.object( + AskarWallet, "get_local_did_for_verkey", mock.CoroutineMock() + ) as mock_wallet_get_local_did_for_verkey, + mock.patch.object( + self.manager, "find_connection", mock.CoroutineMock() + ) as mock_mgr_find_conn, + ): mock_wallet_get_local_did_for_verkey.side_effect = InjectionError() mock_mgr_find_conn.return_value = mock_conn @@ -1236,11 +1242,14 @@ async def test_resolve_inbound_connection_wallet_not_found_error(self): mock_conn = mock.MagicMock() mock_conn.connection_id = "dummy" - with mock.patch.object( - AskarWallet, "get_local_did_for_verkey", mock.CoroutineMock() - ) as mock_wallet_get_local_did_for_verkey, mock.patch.object( - self.manager, "find_connection", mock.CoroutineMock() - ) as mock_mgr_find_conn: + with ( + mock.patch.object( + AskarWallet, "get_local_did_for_verkey", mock.CoroutineMock() + ) as mock_wallet_get_local_did_for_verkey, + mock.patch.object( + self.manager, "find_connection", mock.CoroutineMock() + ) as mock_mgr_find_conn, + ): mock_wallet_get_local_did_for_verkey.side_effect = WalletNotFoundError() mock_mgr_find_conn.return_value = mock_conn @@ -1339,11 +1348,14 @@ async def test_get_connection_targets_retrieve_connection(self): retrieve_invitation=mock.CoroutineMock(return_value=conn_invite), ) - with mock.patch.object( - ConnectionTarget, "serialize", autospec=True - ) as mock_conn_target_ser, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id: + with ( + mock.patch.object( + ConnectionTarget, "serialize", autospec=True + ) as mock_conn_target_ser, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn mock_conn_target_ser.return_value = {"serialized": "value"} targets = await self.manager.get_connection_targets( @@ -1383,13 +1395,17 @@ async def test_get_connection_targets_from_cache(self): state=ConnRecord.State.COMPLETED.rfc160, ) - with mock.patch.object( - ConnectionTarget, "serialize", autospec=True - ) as mock_conn_target_ser, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - self.manager, "fetch_connection_targets", mock.CoroutineMock() - ) as mock_fetch_connection_targets: + with ( + mock.patch.object( + ConnectionTarget, "serialize", autospec=True + ) as mock_conn_target_ser, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object( + self.manager, "fetch_connection_targets", mock.CoroutineMock() + ) as mock_fetch_connection_targets, + ): mock_fetch_connection_targets.return_value = [ConnectionTarget()] mock_conn_rec_retrieve_by_id.return_value = mock_conn mock_conn_target_ser.return_value = {"serialized": "value"} @@ -1428,13 +1444,17 @@ async def test_get_connection_targets_no_cache(self): state=ConnRecord.State.COMPLETED.rfc160, ) - with mock.patch.object( - ConnectionTarget, "serialize", autospec=True - ) as mock_conn_target_ser, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - self.manager, "fetch_connection_targets", mock.CoroutineMock() - ) as mock_fetch_connection_targets: + with ( + mock.patch.object( + ConnectionTarget, "serialize", autospec=True + ) as mock_conn_target_ser, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object( + self.manager, "fetch_connection_targets", mock.CoroutineMock() + ) as mock_fetch_connection_targets, + ): mock_fetch_connection_targets.return_value = [ConnectionTarget()] mock_conn_rec_retrieve_by_id.return_value = mock_conn mock_conn_target_ser.return_value = {"serialized": "value"} @@ -1522,9 +1542,12 @@ async def test_create_static_connection_multitenant(self): self.multitenant_mgr.get_default_mediator.return_value = None self.route_manager.route_static = mock.CoroutineMock() - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - AskarWallet, "create_local_did", autospec=True - ) as mock_wallet_create_local_did: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + AskarWallet, "create_local_did", autospec=True + ) as mock_wallet_create_local_did, + ): mock_wallet_create_local_did.return_value = DIDInfo( self.test_did, self.test_verkey, @@ -1552,11 +1575,15 @@ async def test_create_static_connection_multitenant_auto_disclose_features(self) ) self.multitenant_mgr.get_default_mediator.return_value = None self.route_manager.route_static = mock.CoroutineMock() - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - AskarWallet, "create_local_did", autospec=True - ) as mock_wallet_create_local_did, mock.patch.object( - V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() - ) as mock_proactive_disclose_features: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + AskarWallet, "create_local_did", autospec=True + ) as mock_wallet_create_local_did, + mock.patch.object( + V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() + ) as mock_proactive_disclose_features, + ): mock_wallet_create_local_did.return_value = DIDInfo( self.test_did, self.test_verkey, @@ -1581,12 +1608,15 @@ async def test_create_static_connection_multitenant_mediator(self): default_mediator = mock.MagicMock() self.route_manager.route_static = mock.CoroutineMock() - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - AskarWallet, "create_local_did", autospec=True - ) as mock_wallet_create_local_did, mock.patch.object( - BaseConnectionManager, "create_did_document" - ) as create_did_document, mock.patch.object( - BaseConnectionManager, "store_did_document" + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + AskarWallet, "create_local_did", autospec=True + ) as mock_wallet_create_local_did, + mock.patch.object( + BaseConnectionManager, "create_did_document" + ) as create_did_document, + mock.patch.object(BaseConnectionManager, "store_did_document"), ): mock_wallet_create_local_did.return_value = DIDInfo( self.test_did, @@ -1675,11 +1705,14 @@ async def test_find_connection_retrieve_by_did(self): async def test_find_connection_retrieve_by_did_auto_disclose_features(self): self.context.update_settings({"auto_disclose_features": True}) - with mock.patch.object( - ConnRecord, "retrieve_by_did", mock.CoroutineMock() - ) as mock_conn_retrieve_by_did, mock.patch.object( - V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() - ) as mock_proactive_disclose_features: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ) as mock_conn_retrieve_by_did, + mock.patch.object( + V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() + ) as mock_proactive_disclose_features, + ): mock_conn_retrieve_by_did.return_value = mock.MagicMock( state=ConnRecord.State.RESPONSE.rfc23, save=mock.CoroutineMock(), @@ -1695,11 +1728,14 @@ async def test_find_connection_retrieve_by_did_auto_disclose_features(self): mock_proactive_disclose_features.assert_called_once() async def test_find_connection_retrieve_by_invitation_key(self): - with mock.patch.object( - ConnRecord, "retrieve_by_did", mock.CoroutineMock() - ) as mock_conn_retrieve_by_did, mock.patch.object( - ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_invitation_msg_id: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ) as mock_conn_retrieve_by_did, + mock.patch.object( + ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_invitation_msg_id, + ): mock_conn_retrieve_by_did.side_effect = StorageNotFoundError() mock_conn_retrieve_by_invitation_msg_id.return_value = mock.MagicMock( state=ConnRecord.State.RESPONSE, @@ -1714,11 +1750,14 @@ async def test_find_connection_retrieve_by_invitation_key(self): assert conn_rec async def test_find_connection_retrieve_none_by_invitation_key(self): - with mock.patch.object( - ConnRecord, "retrieve_by_did", mock.CoroutineMock() - ) as mock_conn_retrieve_by_did, mock.patch.object( - ConnRecord, "retrieve_by_invitation_key", mock.CoroutineMock() - ) as mock_conn_retrieve_by_invitation_msg_id: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ) as mock_conn_retrieve_by_did, + mock.patch.object( + ConnRecord, "retrieve_by_invitation_key", mock.CoroutineMock() + ) as mock_conn_retrieve_by_invitation_msg_id, + ): mock_conn_retrieve_by_did.side_effect = StorageNotFoundError() mock_conn_retrieve_by_invitation_msg_id.return_value = None @@ -1732,13 +1771,17 @@ async def test_find_connection_retrieve_none_by_invitation_key(self): async def test_get_endpoints(self): conn_id = "dummy" - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - AskarWallet, "get_local_did", autospec=True - ) as mock_wallet_get_local_did, mock.patch.object( - self.manager, "get_connection_targets", mock.CoroutineMock() - ) as mock_get_conn_targets: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object( + AskarWallet, "get_local_did", autospec=True + ) as mock_wallet_get_local_did, + mock.patch.object( + self.manager, "get_connection_targets", mock.CoroutineMock() + ) as mock_get_conn_targets, + ): mock_retrieve.return_value = mock.MagicMock() mock_wallet_get_local_did.return_value = mock.MagicMock( metadata={"endpoint": "localhost:8020"} diff --git a/acapy_agent/core/tests/test_conductor.py b/acapy_agent/core/tests/test_conductor.py index 875623deee..6b66d1fa73 100644 --- a/acapy_agent/core/tests/test_conductor.py +++ b/acapy_agent/core/tests/test_conductor.py @@ -120,26 +120,32 @@ async def test_startup_version_record_exists(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, - "get_upgrade_version_list", - mock.MagicMock( - return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] - ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, "LoggingConfigurator", autospec=True - ) as mock_logger: + mock.patch.object( + test_module, + "get_upgrade_version_list", + mock.MagicMock( + return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] + ), + ), + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, "LoggingConfigurator", autospec=True + ) as mock_logger, + ): await conductor.setup() mock_inbound_mgr.return_value.setup.assert_awaited_once() @@ -178,24 +184,29 @@ async def test_startup_version_no_upgrade_add_record(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, - "get_upgrade_version_list", - mock.MagicMock( - return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] - ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, + "get_upgrade_version_list", + mock.MagicMock( + return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] + ), + ), + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -218,26 +229,34 @@ async def test_startup_version_force_upgrade(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, - "get_upgrade_version_list", - mock.MagicMock( - return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] - ), - ), mock.patch.object( - test_module, "upgrade_wallet_to_anoncreds_if_requested", return_value=False - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, + "get_upgrade_version_list", + mock.MagicMock( + return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] + ), + ), + mock.patch.object( + test_module, + "upgrade_wallet_to_anoncreds_if_requested", + return_value=False, + ), + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -255,27 +274,36 @@ async def test_startup_version_force_upgrade(self): await conductor.stop() test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, "LoggingConfigurator", autospec=True - ) as mock_logger, mock.patch.object( - test_module, "upgrade_wallet_to_anoncreds_if_requested", return_value=False - ), mock.patch.object( - test_module, - "get_upgrade_version_list", - mock.MagicMock(return_value=["v0.8.0-rc1", "v8.0.0", "v0.8.1-rc1"]), - ), mock.patch.object(test_module, "ledger_config"), mock.patch.object( - test_module.Conductor, "check_for_valid_wallet_type" + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, "LoggingConfigurator", autospec=True + ) as mock_logger, + mock.patch.object( + test_module, + "upgrade_wallet_to_anoncreds_if_requested", + return_value=False, + ), + mock.patch.object( + test_module, + "get_upgrade_version_list", + mock.MagicMock(return_value=["v0.8.0-rc1", "v8.0.0", "v0.8.1-rc1"]), + ), + mock.patch.object(test_module, "ledger_config"), + mock.patch.object(test_module.Conductor, "check_for_valid_wallet_type"), ): await conductor.setup() mock_inbound_mgr.return_value.registered_transports = {} @@ -290,35 +318,46 @@ async def test_startup_version_record_not_exists(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), + ), + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, "LoggingConfigurator", autospec=True + ) as mock_logger, + mock.patch.object( + test_module, + "upgrade_wallet_to_anoncreds_if_requested", + return_value=False, + ), + mock.patch.object( + BaseStorage, + "find_record", + mock.CoroutineMock( + side_effect=[mock.MagicMock(value="askar"), StorageNotFoundError()] + ), + ), + mock.patch.object( + test_module, + "get_upgrade_version_list", + mock.MagicMock(return_value=["v0.8.0-rc1", "v8.0.0", "v0.8.1-rc1"]), + ), + mock.patch.object( + test_module, + "upgrade", + mock.CoroutineMock(), ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, "LoggingConfigurator", autospec=True - ) as mock_logger, mock.patch.object( - test_module, "upgrade_wallet_to_anoncreds_if_requested", return_value=False - ), mock.patch.object( - BaseStorage, - "find_record", - mock.CoroutineMock( - side_effect=[mock.MagicMock(value="askar"), StorageNotFoundError()] - ), - ), mock.patch.object( - test_module, - "get_upgrade_version_list", - mock.MagicMock(return_value=["v0.8.0-rc1", "v8.0.0", "v0.8.1-rc1"]), - ), mock.patch.object( - test_module, - "upgrade", - mock.CoroutineMock(), ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) @@ -348,20 +387,23 @@ async def test_startup_admin_server_x(self): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, "LoggingConfigurator", autospec=True - ), mock.patch.object( - test_module, "AdminServer", mock.MagicMock() - ) as mock_admin_server: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object(test_module, "LoggingConfigurator", autospec=True), + mock.patch.object( + test_module, "AdminServer", mock.MagicMock() + ) as mock_admin_server, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -375,21 +417,29 @@ async def test_startup_no_public_did(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), + ), + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, "LoggingConfigurator", autospec=True + ) as mock_logger, + mock.patch.object( + test_module, + "upgrade_wallet_to_anoncreds_if_requested", + return_value=False, ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, "LoggingConfigurator", autospec=True - ) as mock_logger, mock.patch.object( - test_module, "upgrade_wallet_to_anoncreds_if_requested", return_value=False ): mock_outbound_mgr.return_value.registered_transports = {} mock_outbound_mgr.return_value.enqueue_message = mock.CoroutineMock() @@ -422,19 +472,26 @@ async def test_stats(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), + ), + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, + "upgrade_wallet_to_anoncreds_if_requested", + return_value=False, ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, "upgrade_wallet_to_anoncreds_if_requested", return_value=False ): mock_inbound_mgr.return_value.sessions = ["dummy"] mock_outbound_mgr.return_value.outbound_buffer = [ @@ -466,16 +523,19 @@ async def test_inbound_message_handler(self): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -504,26 +564,32 @@ async def test_inbound_message_handler_ledger_x(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } await conductor.setup() - with mock.patch.object( - conductor.dispatcher, "queue_message", autospec=True - ) as mock_dispatch_q, mock.patch.object( - conductor.admin_server, "notify_fatal_error", mock.MagicMock() - ) as mock_notify: + with ( + mock.patch.object( + conductor.dispatcher, "queue_message", autospec=True + ) as mock_dispatch_q, + mock.patch.object( + conductor.admin_server, "notify_fatal_error", mock.MagicMock() + ) as mock_notify, + ): mock_dispatch_q.side_effect = test_module.LedgerConfigError("ledger down") message_body = "{}" @@ -583,16 +649,19 @@ async def test_outbound_message_handler_with_target(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -623,18 +692,22 @@ async def test_outbound_message_handler_with_connection(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as conn_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as conn_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -672,16 +745,19 @@ async def test_outbound_message_handler_with_verkey_no_target(self): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -717,16 +793,19 @@ async def test_handle_nots(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", mock.MagicMock() - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", mock.MagicMock() + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value = mock.MagicMock( setup=mock.CoroutineMock(), enqueue_message=mock.CoroutineMock(), @@ -743,11 +822,12 @@ async def test_handle_nots(self): conductor.handle_not_returned(conductor.root_profile, message) - with mock.patch.object( - test_module, "ConnectionManager" - ) as mock_conn_mgr, mock.patch.object( - conductor.dispatcher, "run_task", mock.MagicMock() - ) as mock_run_task: + with ( + mock.patch.object(test_module, "ConnectionManager") as mock_conn_mgr, + mock.patch.object( + conductor.dispatcher, "run_task", mock.MagicMock() + ) as mock_run_task, + ): # Normally this should be a coroutine mock; however, the coroutine # is awaited by dispatcher.run_task, which is mocked here. MagicMock # to prevent unawaited coroutine warning. @@ -795,25 +875,31 @@ async def test_handle_not_returned_ledger_x(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } await conductor.setup() - with mock.patch.object( - conductor.dispatcher, "run_task", mock.MagicMock() - ) as mock_dispatch_run, mock.patch.object( - conductor.admin_server, "notify_fatal_error", mock.MagicMock() - ) as mock_notify: + with ( + mock.patch.object( + conductor.dispatcher, "run_task", mock.MagicMock() + ) as mock_dispatch_run, + mock.patch.object( + conductor.admin_server, "notify_fatal_error", mock.MagicMock() + ) as mock_notify, + ): mock_dispatch_run.side_effect = test_module.LedgerConfigError( "No such ledger" ) @@ -837,28 +923,35 @@ async def test_queue_outbound_ledger_x(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } await conductor.setup() - with mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as conn_mgr, mock.patch.object( - conductor.dispatcher, "run_task", mock.MagicMock() - ) as mock_dispatch_run, mock.patch.object( - conductor.admin_server, "notify_fatal_error", mock.MagicMock() - ) as mock_notify: + with ( + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as conn_mgr, + mock.patch.object( + conductor.dispatcher, "run_task", mock.MagicMock() + ) as mock_dispatch_run, + mock.patch.object( + conductor.admin_server, "notify_fatal_error", mock.MagicMock() + ) as mock_notify, + ): # Normally this should be a coroutine mock; however, the coroutine # is awaited by dispatcher.run_task, which is mocked here. MagicMock # to prevent unawaited coroutine warning. @@ -886,16 +979,19 @@ async def test_admin(self): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -903,9 +999,10 @@ async def test_admin(self): admin = conductor.context.inject(BaseAdminServer) assert admin is conductor.admin_server - with mock.patch.object( - admin, "start", autospec=True - ) as admin_start, mock.patch.object(admin, "stop", autospec=True) as admin_stop: + with ( + mock.patch.object(admin, "start", autospec=True) as admin_start, + mock.patch.object(admin, "stop", autospec=True) as admin_stop, + ): await conductor.start() admin_start.assert_awaited_once_with() @@ -925,16 +1022,19 @@ async def test_admin_startx(self): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -942,13 +1042,12 @@ async def test_admin_startx(self): admin = conductor.context.inject(BaseAdminServer) assert admin is conductor.admin_server - with mock.patch.object( - admin, "start", autospec=True - ) as admin_start, mock.patch.object( - admin, "stop", autospec=True - ) as admin_stop, mock.patch.object( - test_module, "OutOfBandManager" - ) as oob_mgr, mock.patch.object(test_module, "ConnectionManager") as conn_mgr: + with ( + mock.patch.object(admin, "start", autospec=True) as admin_start, + mock.patch.object(admin, "stop", autospec=True) as admin_stop, + mock.patch.object(test_module, "OutOfBandManager") as oob_mgr, + mock.patch.object(test_module, "ConnectionManager") as conn_mgr, + ): admin_start.side_effect = KeyError("trouble") oob_mgr.return_value.create_invitation = mock.CoroutineMock( side_effect=KeyError("double trouble") @@ -967,16 +1066,19 @@ async def test_setup_collector(self): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -989,18 +1091,20 @@ async def test_start_static(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "ConnectionManager" - ) as mock_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object(test_module, "ConnectionManager") as mock_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1017,20 +1121,21 @@ async def test_start_x_in(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "ConnectionManager" - ) as mock_mgr, mock.patch.object( - test_module, "InboundTransportManager" - ) as mock_intx_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object(test_module, "ConnectionManager") as mock_mgr, + mock.patch.object(test_module, "InboundTransportManager") as mock_intx_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_intx_mgr.return_value = mock.MagicMock( setup=mock.CoroutineMock(), start=mock.CoroutineMock(side_effect=KeyError("trouble")), @@ -1050,18 +1155,18 @@ async def test_start_x_out_a(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "ConnectionManager" - ) as mock_mgr, mock.patch.object( - test_module, "OutboundTransportManager" - ) as mock_outx_mgr: + mock.patch.object(test_module, "ConnectionManager") as mock_mgr, + mock.patch.object(test_module, "OutboundTransportManager") as mock_outx_mgr, + ): mock_outx_mgr.return_value = mock.MagicMock( setup=mock.CoroutineMock(), start=mock.CoroutineMock(side_effect=KeyError("trouble")), @@ -1078,18 +1183,18 @@ async def test_start_x_out_b(self): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "ConnectionManager" - ) as mock_mgr, mock.patch.object( - test_module, "OutboundTransportManager" - ) as mock_outx_mgr: + mock.patch.object(test_module, "ConnectionManager") as mock_mgr, + mock.patch.object(test_module, "OutboundTransportManager") as mock_outx_mgr, + ): mock_outx_mgr.return_value = mock.MagicMock( setup=mock.CoroutineMock(), start=mock.CoroutineMock(side_effect=KeyError("trouble")), @@ -1123,16 +1228,19 @@ async def test_dispatch_complete_non_fatal_x(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1165,16 +1273,19 @@ async def test_dispatch_complete_fatal_x(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1203,16 +1314,20 @@ async def test_print_invite_connection(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch("sys.stdout", new=StringIO()) as captured, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch("sys.stdout", new=StringIO()) as captured, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1231,16 +1346,19 @@ async def test_clear_default_mediator(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1262,34 +1380,41 @@ async def test_set_default_mediator(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } await conductor.setup() - with mock.patch.object( - test_module, - "MediationManager", - return_value=mock.MagicMock(set_default_mediator_by_id=mock.CoroutineMock()), - ) as mock_mgr, mock.patch.object( - MediationRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module, - "LOGGER", - mock.MagicMock( - exception=mock.MagicMock( - side_effect=Exception("This method should not have been called") - ) + with ( + mock.patch.object( + test_module, + "MediationManager", + return_value=mock.MagicMock( + set_default_mediator_by_id=mock.CoroutineMock() + ), + ) as mock_mgr, + mock.patch.object(MediationRecord, "retrieve_by_id", mock.CoroutineMock()), + mock.patch.object( + test_module, + "LOGGER", + mock.MagicMock( + exception=mock.MagicMock( + side_effect=Exception("This method should not have been called") + ) + ), ), ): await conductor.start() @@ -1303,26 +1428,32 @@ async def test_set_default_mediator_x(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } await conductor.setup() - with mock.patch.object( - MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=Exception()), - ), mock.patch.object(test_module, "LOGGER") as mock_logger: + with ( + mock.patch.object( + MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=Exception()), + ), + mock.patch.object(test_module, "LOGGER") as mock_logger, + ): await conductor.start() await conductor.stop() mock_logger.exception.assert_called_once() @@ -1341,16 +1472,19 @@ async def test_webhook_router(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1386,16 +1520,19 @@ async def test_shutdown_multitenant_profiles(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1456,16 +1593,19 @@ async def test_mediator_invitation_0160(self, mock_from_url, _): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1473,18 +1613,24 @@ async def test_mediator_invitation_0160(self, mock_from_url, _): mock_conn_record = mock.MagicMock() - with mock.patch.object( - test_module, - "ConnectionManager", - mock.MagicMock( - return_value=mock.MagicMock( - receive_invitation=mock.CoroutineMock(return_value=mock_conn_record) - ) + with ( + mock.patch.object( + test_module, + "ConnectionManager", + mock.MagicMock( + return_value=mock.MagicMock( + receive_invitation=mock.CoroutineMock( + return_value=mock_conn_record + ) + ) + ), + ) as mock_mgr, + mock.patch.object(mock_conn_record, "metadata_set", mock.CoroutineMock()), + mock.patch.object( + test_module, + "upgrade_wallet_to_anoncreds_if_requested", + return_value=False, ), - ) as mock_mgr, mock.patch.object( - mock_conn_record, "metadata_set", mock.CoroutineMock() - ), mock.patch.object( - test_module, "upgrade_wallet_to_anoncreds_if_requested", return_value=False ): await conductor.start() await conductor.stop() @@ -1502,16 +1648,19 @@ async def test_mediator_invitation_0434(self, mock_from_url, _): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1537,16 +1686,21 @@ async def test_mediator_invitation_0434(self, mock_from_url, _): state=OobRecord.STATE_INITIAL, ) - with mock.patch.object( - test_module, - "OutOfBandManager", - mock.MagicMock( - return_value=mock.MagicMock( - receive_invitation=mock.CoroutineMock(return_value=oob_record) - ) + with ( + mock.patch.object( + test_module, + "OutOfBandManager", + mock.MagicMock( + return_value=mock.MagicMock( + receive_invitation=mock.CoroutineMock(return_value=oob_record) + ) + ), + ) as mock_mgr, + mock.patch.object( + test_module, + "upgrade_wallet_to_anoncreds_if_requested", + return_value=False, ), - ) as mock_mgr, mock.patch.object( - test_module, "upgrade_wallet_to_anoncreds_if_requested", return_value=False ): assert not conductor.root_profile.settings["mediation.connections_invite"] await conductor.start() @@ -1572,16 +1726,19 @@ async def test_mediation_invitation_should_use_stored_invitation( conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1598,12 +1755,14 @@ async def test_mediation_invitation_should_use_stored_invitation( ) # when - with mock.patch.object( - test_module, "ConnectionManager", return_value=connection_manager_mock - ), mock.patch.object( - mock_conn_record, "metadata_set", mock.CoroutineMock() - ), mock.patch.object( - test_module, "MediationManager", return_value=mock_mediation_manager + with ( + mock.patch.object( + test_module, "ConnectionManager", return_value=connection_manager_mock + ), + mock.patch.object(mock_conn_record, "metadata_set", mock.CoroutineMock()), + mock.patch.object( + test_module, "MediationManager", return_value=mock_mediation_manager + ), ): await conductor.start() await conductor.stop() @@ -1627,16 +1786,19 @@ async def test_mediation_invitation_should_not_create_connection_for_old_invitat conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1665,26 +1827,32 @@ async def test_mediator_invitation_x(self, _): conductor = test_module.Conductor(builder) test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr: + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } await conductor.setup() - with mock.patch.object( - test_module.ConnectionInvitation, - "from_url", - mock.MagicMock(side_effect=Exception()), - ) as mock_from_url, mock.patch.object(test_module, "LOGGER") as mock_logger: + with ( + mock.patch.object( + test_module.ConnectionInvitation, + "from_url", + mock.MagicMock(side_effect=Exception()), + ) as mock_from_url, + mock.patch.object(test_module, "LOGGER") as mock_logger, + ): await conductor.start() await conductor.stop() mock_from_url.assert_called_once_with("test-invite") @@ -1711,22 +1879,28 @@ async def test_setup_ledger_both_multiple_and_base(self): BaseLedger, mock.MagicMock(BaseLedger, autospec=True) ) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, - "load_multiple_genesis_transactions_from_config", - mock.CoroutineMock(), - ) as mock_multiple_genesis_load, mock.patch.object( - test_module, "get_genesis_transactions", mock.CoroutineMock() - ) as mock_genesis_load, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object(test_module, "ledger_config"): + mock.patch.object( + test_module, + "load_multiple_genesis_transactions_from_config", + mock.CoroutineMock(), + ) as mock_multiple_genesis_load, + mock.patch.object( + test_module, "get_genesis_transactions", mock.CoroutineMock() + ) as mock_genesis_load, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object(test_module, "ledger_config"), + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1741,18 +1915,23 @@ async def test_setup_ledger_only_base(self): test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "get_genesis_transactions", mock.CoroutineMock() - ) as mock_genesis_load, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object(test_module, "ledger_config"): + mock.patch.object( + test_module, "get_genesis_transactions", mock.CoroutineMock() + ) as mock_genesis_load, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object(test_module, "ledger_config"), + ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) } @@ -1765,21 +1944,26 @@ async def test_startup_storage_type_anoncreds_and_config_askar_re_calls_setup(se test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), + ), + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, + "upgrade", + mock.CoroutineMock(), ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, - "upgrade", - mock.CoroutineMock(), ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) @@ -1811,27 +1995,33 @@ async def test_startup_storage_type_does_not_exist_and_existing_agent_then_set_t test_profile = await create_test_profile(None, await builder.build_context()) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, - "get_upgrade_version_list", - mock.MagicMock( - return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, + "get_upgrade_version_list", + mock.MagicMock( + return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] + ), + ), + mock.patch.object( + test_module, + "upgrade", + mock.CoroutineMock(), ), - ), mock.patch.object( - test_module, - "upgrade", - mock.CoroutineMock(), ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) @@ -1866,27 +2056,33 @@ async def test_startup_storage_type_does_not_exist_and_new_anoncreds_agent( test_settings, await builder.build_context() ) - with mock.patch.object( - test_module, - "wallet_config", - return_value=( - test_profile, - DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + with ( + mock.patch.object( + test_module, + "wallet_config", + return_value=( + test_profile, + DIDInfo("did", "verkey", metadata={}, method=SOV, key_type=ED25519), + ), ), - ), mock.patch.object( - test_module, "InboundTransportManager", autospec=True - ) as mock_inbound_mgr, mock.patch.object( - test_module, "OutboundTransportManager", autospec=True - ) as mock_outbound_mgr, mock.patch.object( - test_module, - "get_upgrade_version_list", - mock.MagicMock( - return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] + mock.patch.object( + test_module, "InboundTransportManager", autospec=True + ) as mock_inbound_mgr, + mock.patch.object( + test_module, "OutboundTransportManager", autospec=True + ) as mock_outbound_mgr, + mock.patch.object( + test_module, + "get_upgrade_version_list", + mock.MagicMock( + return_value=["v0.7.4", "0.7.5", "v0.8.0-rc1", "v8.0.0", "v0.8.1-rc2"] + ), + ), + mock.patch.object( + test_module, + "upgrade", + mock.CoroutineMock(), ), - ), mock.patch.object( - test_module, - "upgrade", - mock.CoroutineMock(), ): mock_outbound_mgr.return_value.registered_transports = { "test": mock.MagicMock(schemes=["http"]) diff --git a/acapy_agent/core/tests/test_dispatcher.py b/acapy_agent/core/tests/test_dispatcher.py index c352192f19..b941e584e3 100644 --- a/acapy_agent/core/tests/test_dispatcher.py +++ b/acapy_agent/core/tests/test_dispatcher.py @@ -105,11 +105,14 @@ async def test_dispatch(self): "@type": DIDCommPrefix.qualify_current(StubAgentMessage.Meta.message_type) } - with mock.patch.object( - StubAgentMessageHandler, "handle", autospec=True - ) as handler_mock, mock.patch.object( - test_module, "BaseConnectionManager", autospec=True - ) as conn_mgr_mock: + with ( + mock.patch.object( + StubAgentMessageHandler, "handle", autospec=True + ) as handler_mock, + mock.patch.object( + test_module, "BaseConnectionManager", autospec=True + ) as conn_mgr_mock, + ): conn_mgr_mock.return_value = mock.MagicMock( find_inbound_connection=mock.CoroutineMock( return_value=mock.MagicMock(connection_id="dummy") @@ -148,10 +151,11 @@ async def test_dispatch_versioned_message(self): "@type": DIDCommPrefix.qualify_current(StubAgentMessage.Meta.message_type) } - with mock.patch.object( - StubAgentMessageHandler, "handle", autospec=True - ) as handler_mock, mock.patch.object( - test_module, "BaseConnectionManager", autospec=True + with ( + mock.patch.object( + StubAgentMessageHandler, "handle", autospec=True + ) as handler_mock, + mock.patch.object(test_module, "BaseConnectionManager", autospec=True), ): await dispatcher.queue_message( dispatcher.profile, make_inbound(message), rcv.send @@ -217,11 +221,12 @@ async def test_dispatch_versioned_message_message_class_deserialize_x(self): rcv = Receiver() message = {"@type": "doc/proto-name/1.1/no-such-message-type"} - with mock.patch.object( - StubAgentMessageHandler, "handle", autospec=True - ), mock.patch.object( - registry, "resolve_message_class", mock.MagicMock() - ) as mock_resolve: + with ( + mock.patch.object(StubAgentMessageHandler, "handle", autospec=True), + mock.patch.object( + registry, "resolve_message_class", mock.MagicMock() + ) as mock_resolve, + ): mock_resolve.return_value = mock.MagicMock( deserialize=mock.MagicMock(side_effect=test_module.BaseModelError()) ) @@ -258,10 +263,11 @@ async def test_dispatch_versioned_message_handle_greater_succeeds(self): "@type": DIDCommPrefix.qualify_current(StubV1_2AgentMessage.Meta.message_type) } - with mock.patch.object( - StubAgentMessageHandler, "handle", autospec=True - ) as handler_mock, mock.patch.object( - test_module, "BaseConnectionManager", autospec=True + with ( + mock.patch.object( + StubAgentMessageHandler, "handle", autospec=True + ) as handler_mock, + mock.patch.object(test_module, "BaseConnectionManager", autospec=True), ): await dispatcher.queue_message( dispatcher.profile, make_inbound(message), rcv.send @@ -393,12 +399,13 @@ async def test_create_send_outbound(self): outbound_message = await responder.create_outbound( json.dumps(message.serialize()) ) - with mock.patch.object( - responder, "_send", mock.CoroutineMock() - ), mock.patch.object( - test_module.BaseResponder, - "conn_rec_active_state_check", - mock.CoroutineMock(return_value=True), + with ( + mock.patch.object(responder, "_send", mock.CoroutineMock()), + mock.patch.object( + test_module.BaseResponder, + "conn_rec_active_state_check", + mock.CoroutineMock(return_value=True), + ), ): await responder.send_outbound(outbound_message) @@ -418,12 +425,13 @@ async def test_create_send_outbound_with_msg_attrs(self): message = StubAgentMessage() responder = test_module.DispatcherResponder(context, message, None) outbound_message = await responder.create_outbound(message) - with mock.patch.object( - responder, "_send", mock.CoroutineMock() - ), mock.patch.object( - test_module.BaseResponder, - "conn_rec_active_state_check", - mock.CoroutineMock(return_value=True), + with ( + mock.patch.object(responder, "_send", mock.CoroutineMock()), + mock.patch.object( + test_module.BaseResponder, + "conn_rec_active_state_check", + mock.CoroutineMock(return_value=True), + ), ): await responder.send_outbound( message=outbound_message, diff --git a/acapy_agent/core/tests/test_oob_processor.py b/acapy_agent/core/tests/test_oob_processor.py index f3a9541f78..4b3e85bedb 100644 --- a/acapy_agent/core/tests/test_oob_processor.py +++ b/acapy_agent/core/tests/test_oob_processor.py @@ -426,17 +426,20 @@ async def test_find_oob_record_for_inbound_message_sender_connection_id_no_match mock_retrieve.assert_called_once_with(ANY, {"invi_msg_id": "the-pthid"}) # Connection id is not the same, state is AWAIT_RESPONSE. oob has connection_id - with mock.patch.object( - OobRecord, - "retrieve_by_tag_filter", - mock.CoroutineMock(return_value=self.oob_record), - ) as mock_retrieve, mock.patch.object( - ConnRecord, - "retrieve_by_id", - mock.CoroutineMock( - return_value=mock.MagicMock(delete_record=mock.CoroutineMock()) - ), - ) as mock_retrieve_conn: + with ( + mock.patch.object( + OobRecord, + "retrieve_by_tag_filter", + mock.CoroutineMock(return_value=self.oob_record), + ) as mock_retrieve, + mock.patch.object( + ConnRecord, + "retrieve_by_id", + mock.CoroutineMock( + return_value=mock.MagicMock(delete_record=mock.CoroutineMock()) + ), + ) as mock_retrieve_conn, + ): self.oob_record.role = OobRecord.ROLE_SENDER self.oob_record.state = OobRecord.STATE_AWAIT_RESPONSE self.context.connection_record = mock.MagicMock( diff --git a/acapy_agent/indy/tests/test_verifier.py b/acapy_agent/indy/tests/test_verifier.py index c038daa3d3..54762cb636 100644 --- a/acapy_agent/indy/tests/test_verifier.py +++ b/acapy_agent/indy/tests/test_verifier.py @@ -436,11 +436,12 @@ async def test_check_timestamps(self): proof_req_x = deepcopy(INDY_PROOF_REQ_NAME) proof_req_x["non_revoked"] = {"from": 1600000000, "to": 1600001000} proof_x["identifiers"][0]["timestamp"] = 1579890000 - with mock.patch.object( - test_module, "LOGGER", mock.MagicMock() - ) as mock_logger, mock.patch.object( - IndyLedgerRequestsExecutor, "get_ledger_for_identifier" - ) as mock_get_ledger: + with ( + mock.patch.object(test_module, "LOGGER", mock.MagicMock()) as mock_logger, + mock.patch.object( + IndyLedgerRequestsExecutor, "get_ledger_for_identifier" + ) as mock_get_ledger, + ): mock_get_ledger.return_value = (None, self.ledger) pre_logger_calls = mock_logger.info.call_count await self.verifier.check_timestamps( diff --git a/acapy_agent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py b/acapy_agent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py index a64f20a8b7..c567b33cf2 100644 --- a/acapy_agent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py +++ b/acapy_agent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py @@ -239,11 +239,14 @@ async def test_get_ledger_by_did_not_self_cert( "verkey": "ABUF7uxYTxZ6qYdZ4G9e1Gi", } ) - with mock.patch.object( - test_module.asyncio, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object( - test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() - ) as mock_verify_spv_proof: + with ( + mock.patch.object( + test_module.asyncio, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object( + test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() + ) as mock_verify_spv_proof, + ): mock_build_get_nym_req.return_value = mock.MagicMock() mock_submit.return_value = get_nym_reply mock_wait.return_value = mock_submit.return_value @@ -354,11 +357,14 @@ async def test_get_ledger_by_did_not_self_cert_not_self_cert_prod( ): get_nym_reply = deepcopy(GET_NYM_INDY_VDR_REPLY) get_nym_reply["data"]["verkey"] = "ABUF7uxYTxZ6qYdZ4G9e1Gi" - with mock.patch.object( - test_module.asyncio, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object( - test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() - ) as mock_verify_spv_proof: + with ( + mock.patch.object( + test_module.asyncio, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object( + test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() + ) as mock_verify_spv_proof, + ): mock_build_get_nym_req.return_value = mock.MagicMock() mock_submit.return_value = get_nym_reply mock_wait.return_value = mock_submit.return_value @@ -425,11 +431,14 @@ async def test_get_ledger_by_did_not_self_cert_non_prod( ) get_nym_reply = deepcopy(GET_NYM_REPLY) get_nym_reply["result"]["data"]["verkey"] = "ABUF7uxYTxZ6qYdZ4G9e1Gi" - with mock.patch.object( - test_module.asyncio, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object( - test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() - ) as mock_verify_spv_proof: + with ( + mock.patch.object( + test_module.asyncio, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object( + test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() + ) as mock_verify_spv_proof, + ): mock_build_get_nym_req.return_value = mock.MagicMock() mock_submit.return_value = get_nym_reply mock_wait.return_value = mock_submit.return_value @@ -450,11 +459,14 @@ async def test_get_ledger_by_did_not_self_cert_non_prod( async def test_lookup_did_in_configured_ledgers_x( self, mock_submit, mock_build_get_nym_req, mock_close, mock_open ): - with mock.patch.object( - test_module.asyncio, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object( - test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() - ) as mock_verify_spv_proof: + with ( + mock.patch.object( + test_module.asyncio, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object( + test_module.SubTrie, "verify_spv_proof", mock.CoroutineMock() + ) as mock_verify_spv_proof, + ): mock_build_get_nym_req.return_value = mock.MagicMock() mock_submit.return_value = GET_NYM_INDY_VDR_REPLY mock_wait.return_value = mock_submit.return_value diff --git a/acapy_agent/ledger/tests/test_indy_vdr.py b/acapy_agent/ledger/tests/test_indy_vdr.py index 927498c707..9b0ee8ce3c 100644 --- a/acapy_agent/ledger/tests/test_indy_vdr.py +++ b/acapy_agent/ledger/tests/test_indy_vdr.py @@ -51,10 +51,12 @@ async def open(): async def close(): ledger.pool.handle = None - with mock.patch.object(ledger.pool, "open", open), mock.patch.object( - ledger.pool, "close", close - ), mock.patch.object( - ledger, "is_ledger_read_only", mock.CoroutineMock(return_value=False) + with ( + mock.patch.object(ledger.pool, "open", open), + mock.patch.object(ledger.pool, "close", close), + mock.patch.object( + ledger, "is_ledger_read_only", mock.CoroutineMock(return_value=False) + ), ): yield ledger @@ -338,14 +340,17 @@ async def test_send_schema_ledger_read_only( async with ledger: ledger.pool.read_only = True - with mock.patch.object( - ledger, - "check_existing_schema", - mock.CoroutineMock(return_value=False), - ), mock.patch.object( - ledger, - "is_ledger_read_only", - mock.CoroutineMock(return_value=True), + with ( + mock.patch.object( + ledger, + "check_existing_schema", + mock.CoroutineMock(return_value=False), + ), + mock.patch.object( + ledger, + "is_ledger_read_only", + mock.CoroutineMock(return_value=True), + ), ): with pytest.raises(LedgerError): await ledger.create_and_send_schema( @@ -768,25 +773,28 @@ async def test_update_endpoint_for_did_calls_attr_json(self, ledger: IndyVdrLedg test_did = await wallet.create_public_did(SOV, ED25519) async with ledger: - with mock.patch.object( - ledger, - "_construct_attr_json", - mock.CoroutineMock( - return_value=json.dumps( - { - "endpoint": { + with ( + mock.patch.object( + ledger, + "_construct_attr_json", + mock.CoroutineMock( + return_value=json.dumps( + { "endpoint": { - "endpoint": "https://url", - "routingKeys": [], + "endpoint": { + "endpoint": "https://url", + "routingKeys": [], + } } } - } - ) + ) + ), + ) as mock_construct_attr_json, + mock.patch.object( + ledger, + "get_all_endpoints_for_did", + mock.CoroutineMock(return_value={}), ), - ) as mock_construct_attr_json, mock.patch.object( - ledger, - "get_all_endpoints_for_did", - mock.CoroutineMock(return_value={}), ): await ledger.update_endpoint_for_did( test_did.did, diff --git a/acapy_agent/ledger/tests/test_routes.py b/acapy_agent/ledger/tests/test_routes.py index 00adc0952b..70e1092b56 100644 --- a/acapy_agent/ledger/tests/test_routes.py +++ b/acapy_agent/ledger/tests/test_routes.py @@ -134,13 +134,16 @@ async def test_get_verkey_multitenant(self): IndyLedgerRequestsExecutor, self.mock_ledger_requests_executor, ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as json_response: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as json_response, + ): self.ledger.get_key_for_did.return_value = self.test_verkey result = await test_module.get_did_verkey(self.request) json_response.assert_called_once_with( @@ -208,13 +211,16 @@ async def test_get_endpoint_multitenant(self): mock.MagicMock(MultitenantManager, autospec=True), ) self.request.query = {"did": self.test_did} - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as json_response: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as json_response, + ): self.ledger.get_endpoint_for_did.return_value = self.test_endpoint result = await test_module.get_did_endpoint(self.request) json_response.assert_called_once_with( @@ -327,13 +333,17 @@ async def test_register_nym_create_transaction_for_endorser(self): "conn_id": "dummy", } - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( create_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -371,13 +381,17 @@ async def test_register_nym_create_transaction_for_endorser_no_public_did(self): } self.profile.context.settings["endorser.author"] = True - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( create_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -414,11 +428,14 @@ async def test_register_nym_create_transaction_for_endorser_storage_x(self): "conn_id": "dummy", } - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_record=mock.CoroutineMock(side_effect=test_module.StorageError()) ) @@ -583,13 +600,16 @@ async def test_get_nym_role_multitenant(self): ) self.request.query = {"did": self.test_did} - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as json_response: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as json_response, + ): self.ledger.get_nym_role.return_value = Role.USER result = await test_module.get_nym_role(self.request) json_response.assert_called_once_with( diff --git a/acapy_agent/messaging/credential_definitions/tests/test_routes.py b/acapy_agent/messaging/credential_definitions/tests/test_routes.py index 93ad921c48..65fb61e0b1 100644 --- a/acapy_agent/messaging/credential_definitions/tests/test_routes.py +++ b/acapy_agent/messaging/credential_definitions/tests/test_routes.py @@ -103,13 +103,17 @@ async def test_send_credential_definition_create_transaction_for_endorser(self): "conn_id": "dummy", } - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( create_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -152,11 +156,14 @@ async def test_send_credential_definition_create_transaction_for_endorser_storag "conn_id": "dummy", } - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -356,11 +363,14 @@ async def test_get_credential_definition_multitenant(self): mock.MagicMock(MultitenantManager, autospec=True), ) self.request.match_info = {"cred_def_id": CRED_DEF_ID} - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): result = await test_module.credential_definitions_get_credential_definition( self.request ) diff --git a/acapy_agent/messaging/jsonld/tests/test_routes.py b/acapy_agent/messaging/jsonld/tests/test_routes.py index 992b907a49..a98d0818f2 100644 --- a/acapy_agent/messaging/jsonld/tests/test_routes.py +++ b/acapy_agent/messaging/jsonld/tests/test_routes.py @@ -353,13 +353,13 @@ async def test_verify_credential(self): mock_response.assert_called_once_with({"valid": True}) # expected response # compact, expand take a LONG TIME: do them once above, mock for error cases - with mock.patch.object( - jsonld, "compact", mock.MagicMock() - ) as mock_compact, mock.patch.object( - jsonld, "expand", mock.MagicMock() - ) as mock_expand, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object(jsonld, "compact", mock.MagicMock()) as mock_compact, + mock.patch.object(jsonld, "expand", mock.MagicMock()) as mock_expand, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_expand.return_value = [mock.MagicMock()] mock_compact.return_value = { "@context": "...", @@ -388,13 +388,13 @@ async def test_verify_credential(self): result = await test_module.verify(self.request) assert "error" in json.loads(result) - with mock.patch.object( - jsonld, "compact", mock.MagicMock() - ) as mock_compact, mock.patch.object( - jsonld, "expand", mock.MagicMock() - ) as mock_expand, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object(jsonld, "compact", mock.MagicMock()) as mock_compact, + mock.patch.object(jsonld, "expand", mock.MagicMock()) as mock_expand, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_expand.return_value = [mock.MagicMock()] mock_compact.return_value = { "@context": "...", @@ -503,13 +503,13 @@ async def test_sign_credential(self): # compact, expand take a LONG TIME: do them once above, mock for error cases posted_request = deepcopy(POSTED_REQUEST) self.request.json = mock.CoroutineMock(return_value=posted_request) - with mock.patch.object( - jsonld, "compact", mock.MagicMock() - ) as mock_compact, mock.patch.object( - jsonld, "expand", mock.MagicMock() - ) as mock_expand, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object(jsonld, "compact", mock.MagicMock()) as mock_compact, + mock.patch.object(jsonld, "expand", mock.MagicMock()) as mock_expand, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_expand.return_value = [mock.MagicMock()] mock_compact.return_value = {} # drop all attributes mock_response.side_effect = lambda x: json.dumps(x) diff --git a/acapy_agent/messaging/schemas/tests/test_routes.py b/acapy_agent/messaging/schemas/tests/test_routes.py index eb29c9cf31..a84a05171d 100644 --- a/acapy_agent/messaging/schemas/tests/test_routes.py +++ b/acapy_agent/messaging/schemas/tests/test_routes.py @@ -104,13 +104,17 @@ async def test_send_schema_create_transaction_for_endorser(self): "conn_id": "dummy", } - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( create_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -155,11 +159,14 @@ async def test_send_schema_create_transaction_for_endorser_storage_x(self): "conn_id": "dummy", } - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_record=mock.CoroutineMock(side_effect=test_module.StorageError()) ) @@ -339,11 +346,14 @@ async def test_get_schema_multitenant(self): mock.MagicMock(MultitenantManager, autospec=True), ) self.request.match_info = {"schema_id": SCHEMA_ID} - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): result = await test_module.schemas_get_schema(self.request) assert result == mock_response.return_value mock_response.assert_called_once_with( diff --git a/acapy_agent/multitenant/admin/tests/test_routes.py b/acapy_agent/multitenant/admin/tests/test_routes.py index 823d8704aa..4ec0ba142a 100644 --- a/acapy_agent/multitenant/admin/tests/test_routes.py +++ b/acapy_agent/multitenant/admin/tests/test_routes.py @@ -51,11 +51,12 @@ async def test_format_wallet_record_removes_wallet_key(self): assert "wallet.key" not in formatted["settings"] async def test_wallets_list(self): - with mock.patch.object( - test_module, "WalletRecord", autospec=True - ) as mock_wallet_record, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "WalletRecord", autospec=True + ) as mock_wallet_record, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): wallets = [ mock.MagicMock( serialize=mock.MagicMock( @@ -110,11 +111,12 @@ async def test_wallets_list_x(self): async def test_wallets_list_query(self): self.request.query = {"wallet_name": "test"} - with mock.patch.object( - test_module, "WalletRecord", autospec=True - ) as mock_wallet_record, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "WalletRecord", autospec=True + ) as mock_wallet_record, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): wallets = [ mock.MagicMock( serialize=mock.MagicMock( @@ -654,11 +656,12 @@ async def test_wallet_get(self): return_value={"settings": {}, "wallet_id": "dummy"} ) - with mock.patch.object( - test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_wallet_record_retrieve_by_id, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_wallet_record_retrieve_by_id, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_wallet_record_retrieve_by_id.return_value = mock_wallet_record await test_module.wallet_get(self.request) @@ -698,11 +701,12 @@ async def test_wallet_create_token_managed(self): return_value={"settings": {}, "wallet_id": "dummy"} ) - with mock.patch.object( - test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_wallet_record_retrieve_by_id, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_wallet_record_retrieve_by_id, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_wallet_record_retrieve_by_id.return_value = mock_wallet_record mock_multitenant_mgr = mock.AsyncMock(BaseMultitenantManager, autospec=True) mock_multitenant_mgr.create_auth_token = mock.CoroutineMock( @@ -727,11 +731,12 @@ async def test_wallet_create_token_unmanaged(self): return_value={"settings": {}, "wallet_id": "dummy"} ) - with mock.patch.object( - test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_wallet_record_retrieve_by_id, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_wallet_record_retrieve_by_id, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_wallet_record_retrieve_by_id.return_value = mock_wallet_record mock_multitenant_mgr = mock.AsyncMock(BaseMultitenantManager, autospec=True) mock_multitenant_mgr.create_auth_token = mock.CoroutineMock( @@ -803,10 +808,11 @@ async def test_wallet_remove_managed(self): BaseMultitenantManager, mock_multitenant_mgr ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() + ), ): result = await test_module.wallet_remove(self.request) @@ -822,10 +828,11 @@ async def test_wallet_remove_unmanaged(self): self.profile.context.injector.bind_instance( BaseMultitenantManager, mock_multitenant_mgr ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + test_module.WalletRecord, "retrieve_by_id", mock.CoroutineMock() + ), ): result = await test_module.wallet_remove(self.request) diff --git a/acapy_agent/multitenant/tests/test_base.py b/acapy_agent/multitenant/tests/test_base.py index 88834434f0..dbfb40a85c 100644 --- a/acapy_agent/multitenant/tests/test_base.py +++ b/acapy_agent/multitenant/tests/test_base.py @@ -210,11 +210,10 @@ async def test_create_wallet_saves_wallet_record_creates_profile(self): mock_route_manager.route_verkey = mock.CoroutineMock() self.context.injector.bind_instance(RouteManager, mock_route_manager) - with mock.patch.object( - WalletRecord, "save" - ) as wallet_record_save, mock.patch.object( - self.manager, "get_wallet_profile" - ) as get_wallet_profile: + with ( + mock.patch.object(WalletRecord, "save") as wallet_record_save, + mock.patch.object(self.manager, "get_wallet_profile") as get_wallet_profile, + ): get_wallet_profile.return_value = await create_test_profile() wallet_record = await self.manager.create_wallet( @@ -247,13 +246,11 @@ async def test_create_wallet_adds_wallet_route(self): mock_route_manager = mock.MagicMock() mock_route_manager.route_verkey = mock.CoroutineMock() - with mock.patch.object( - WalletRecord, "save" - ) as wallet_record_save, mock.patch.object( - self.manager, "get_wallet_profile" - ) as get_wallet_profile, mock.patch.object( - BaseWallet, "get_public_did" - ) as get_public_did: + with ( + mock.patch.object(WalletRecord, "save") as wallet_record_save, + mock.patch.object(self.manager, "get_wallet_profile") as get_wallet_profile, + mock.patch.object(BaseWallet, "get_public_did") as get_public_did, + ): mock_profile = await create_test_profile() mock_profile.context.injector.bind_instance(RouteManager, mock_route_manager) get_wallet_profile.return_value = mock_profile @@ -277,11 +274,10 @@ async def test_create_wallet_adds_wallet_route(self): assert wallet_record.wallet_key == "test_key" async def test_update_wallet(self): - with mock.patch.object( - WalletRecord, "retrieve_by_id" - ) as retrieve_by_id, mock.patch.object( - WalletRecord, "save" - ) as wallet_record_save: + with ( + mock.patch.object(WalletRecord, "retrieve_by_id") as retrieve_by_id, + mock.patch.object(WalletRecord, "save") as wallet_record_save, + ): wallet_id = "test-wallet-id" retrieve_by_id.return_value = WalletRecord( wallet_id=wallet_id, @@ -315,17 +311,15 @@ async def test_remove_wallet_fails_no_wallet_key_but_required(self): await self.manager.remove_wallet("test") async def test_remove_wallet_removes_profile_wallet_storage_records(self): - with mock.patch.object( - WalletRecord, "retrieve_by_id" - ) as retrieve_by_id, mock.patch.object( - self.manager, "get_wallet_profile" - ) as get_wallet_profile, mock.patch.object( - self.manager, "remove_wallet_profile" - ) as remove_wallet_profile, mock.patch.object( - WalletRecord, "delete_record" - ) as wallet_delete_record, mock.patch.object( - AskarStorage, "delete_all_records" - ) as delete_all_records: + with ( + mock.patch.object(WalletRecord, "retrieve_by_id") as retrieve_by_id, + mock.patch.object(self.manager, "get_wallet_profile") as get_wallet_profile, + mock.patch.object( + self.manager, "remove_wallet_profile" + ) as remove_wallet_profile, + mock.patch.object(WalletRecord, "delete_record") as wallet_delete_record, + mock.patch.object(AskarStorage, "delete_all_records") as delete_all_records, + ): wallet_record = WalletRecord( wallet_id="test", key_management_mode=WalletRecord.MODE_UNMANAGED, @@ -555,10 +549,9 @@ async def test_get_profile_for_token_managed_wallet_x_iat_no_match(self): algorithm="HS256", ) - with mock.patch.object( - self.manager, "get_wallet_profile" - ) as get_wallet_profile, self.assertRaises( - MultitenantManagerError, msg="Token not valid" + with ( + mock.patch.object(self.manager, "get_wallet_profile") as get_wallet_profile, + self.assertRaises(MultitenantManagerError, msg="Token not valid"), ): await self.manager.get_profile_for_token(self.profile.context, token) @@ -632,12 +625,15 @@ async def test_get_wallets_by_message(self): async def test_get_profile_for_key(self): mock_wallet = mock.MagicMock() mock_wallet.requires_external_key = False - with mock.patch.object( - self.manager, - "_get_wallet_by_key", - mock.CoroutineMock(return_value=mock_wallet), - ), mock.patch.object( - self.manager, "get_wallet_profile", mock.CoroutineMock() - ) as mock_get_wallet_profile: + with ( + mock.patch.object( + self.manager, + "_get_wallet_by_key", + mock.CoroutineMock(return_value=mock_wallet), + ), + mock.patch.object( + self.manager, "get_wallet_profile", mock.CoroutineMock() + ) as mock_get_wallet_profile, + ): profile = await self.manager.get_profile_for_key(self.context, "test-verkey") assert profile == mock_get_wallet_profile.return_value diff --git a/acapy_agent/multitenant/tests/test_manager.py b/acapy_agent/multitenant/tests/test_manager.py index 7cd92e5bc7..cc633d2e09 100644 --- a/acapy_agent/multitenant/tests/test_manager.py +++ b/acapy_agent/multitenant/tests/test_manager.py @@ -169,11 +169,10 @@ async def side_effect(context, provision): assert profile.settings.get("mediation.clear") is True async def test_update_wallet_update_wallet_profile(self): - with mock.patch.object( - WalletRecord, "retrieve_by_id" - ) as retrieve_by_id, mock.patch.object( - WalletRecord, "save" - ) as wallet_record_save: + with ( + mock.patch.object(WalletRecord, "retrieve_by_id") as retrieve_by_id, + mock.patch.object(WalletRecord, "save") as wallet_record_save, + ): wallet_id = "test-wallet-id" wallet_profile = await create_test_profile() self.manager._profiles.put("test-wallet-id", wallet_profile) diff --git a/acapy_agent/multitenant/tests/test_route_manager.py b/acapy_agent/multitenant/tests/test_route_manager.py index 3a3218199d..4dad3d9dce 100644 --- a/acapy_agent/multitenant/tests/test_route_manager.py +++ b/acapy_agent/multitenant/tests/test_route_manager.py @@ -61,11 +61,16 @@ async def test_route_for_key_sub_mediator_no_base_mediator( mediation_id="test-mediation-id", connection_id="test-mediator-conn-id" ) - with mock.patch.object( - route_manager, "get_base_wallet_mediator", mock.CoroutineMock(return_value=None) - ), mock.patch.object( - RoutingManager, "create_route_record", mock.CoroutineMock() - ) as mock_create_route_record: + with ( + mock.patch.object( + route_manager, + "get_base_wallet_mediator", + mock.CoroutineMock(return_value=None), + ), + mock.patch.object( + RoutingManager, "create_route_record", mock.CoroutineMock() + ) as mock_create_route_record, + ): keylist_update = await route_manager._route_for_key( sub_profile, TEST_VERKEY, @@ -102,13 +107,16 @@ async def test_route_for_key_sub_mediator_and_base_mediator( connection_id="test-base-mediator-conn-id", ) - with mock.patch.object( - route_manager, - "get_base_wallet_mediator", - mock.CoroutineMock(return_value=base_mediation_record), - ), mock.patch.object( - RoutingManager, "create_route_record", mock.CoroutineMock() - ) as mock_create_route_record: + with ( + mock.patch.object( + route_manager, + "get_base_wallet_mediator", + mock.CoroutineMock(return_value=base_mediation_record), + ), + mock.patch.object( + RoutingManager, "create_route_record", mock.CoroutineMock() + ) as mock_create_route_record, + ): keylist_update = await route_manager._route_for_key( sub_profile, TEST_VERKEY, @@ -142,13 +150,16 @@ async def test_route_for_key_base_mediator_no_sub_mediator( connection_id="test-base-mediator-conn-id", ) - with mock.patch.object( - route_manager, - "get_base_wallet_mediator", - mock.CoroutineMock(return_value=base_mediation_record), - ), mock.patch.object( - RoutingManager, "create_route_record", mock.CoroutineMock() - ) as mock_create_route_record: + with ( + mock.patch.object( + route_manager, + "get_base_wallet_mediator", + mock.CoroutineMock(return_value=base_mediation_record), + ), + mock.patch.object( + RoutingManager, "create_route_record", mock.CoroutineMock() + ) as mock_create_route_record, + ): keylist_update = await route_manager._route_for_key( sub_profile, TEST_VERKEY, diff --git a/acapy_agent/multitenant/tests/test_single_wallet_askar_manager.py b/acapy_agent/multitenant/tests/test_single_wallet_askar_manager.py index 6ac3cbb77f..322a8517ec 100644 --- a/acapy_agent/multitenant/tests/test_single_wallet_askar_manager.py +++ b/acapy_agent/multitenant/tests/test_single_wallet_askar_manager.py @@ -43,11 +43,14 @@ async def test_get_wallet_profile_should_open_store_and_return_profile_with_wall }, ) - with mock.patch( - "acapy_agent.multitenant.single_wallet_askar_manager.wallet_config" - ) as wallet_config, mock.patch( - "acapy_agent.multitenant.single_wallet_askar_manager.AskarProfile", - ) as AskarProfile: + with ( + mock.patch( + "acapy_agent.multitenant.single_wallet_askar_manager.wallet_config" + ) as wallet_config, + mock.patch( + "acapy_agent.multitenant.single_wallet_askar_manager.AskarProfile", + ) as AskarProfile, + ): sub_wallet_profile_context = InjectionContext() sub_wallet_profile = AskarProfile(None, None) sub_wallet_profile.context.copy.return_value = sub_wallet_profile_context @@ -115,11 +118,14 @@ async def test_get_anoncreds_wallet_profile_should_open_store_and_return_anoncre }, ) - with mock.patch( - "acapy_agent.multitenant.single_wallet_askar_manager.wallet_config" - ) as wallet_config, mock.patch( - "acapy_agent.multitenant.single_wallet_askar_manager.AskarAnoncredsProfile", - ) as AskarAnoncredsProfile: + with ( + mock.patch( + "acapy_agent.multitenant.single_wallet_askar_manager.wallet_config" + ) as wallet_config, + mock.patch( + "acapy_agent.multitenant.single_wallet_askar_manager.AskarAnoncredsProfile", + ) as AskarAnoncredsProfile, + ): sub_wallet_profile_context = InjectionContext() sub_wallet_profile = AskarAnoncredsProfile(None, None) sub_wallet_profile.context.copy.return_value = sub_wallet_profile_context diff --git a/acapy_agent/protocols/actionmenu/v1_0/tests/test_routes.py b/acapy_agent/protocols/actionmenu/v1_0/tests/test_routes.py index 1b76449de6..268a252711 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/actionmenu/v1_0/tests/test_routes.py @@ -73,13 +73,13 @@ async def test_actionmenu_perform(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object( - test_module, "Perform", autospec=True - ) as mock_perform, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Perform", autospec=True) as mock_perform, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_record.retrieve_by_id = mock.CoroutineMock() await test_module.actionmenu_perform(self.request) @@ -93,9 +93,12 @@ async def test_actionmenu_perform_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object(test_module, "Perform", autospec=True): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Perform", autospec=True), + ): # Emulate storage not found (bad connection id) mock_conn_record.retrieve_by_id = mock.CoroutineMock( side_effect=StorageNotFoundError @@ -108,9 +111,12 @@ async def test_actionmenu_perform_conn_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object(test_module, "Perform", autospec=True): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Perform", autospec=True), + ): # Emulate connection not ready mock_conn_record.retrieve_by_id = mock.CoroutineMock() mock_conn_record.retrieve_by_id.return_value.is_ready = False @@ -122,13 +128,13 @@ async def test_actionmenu_request(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object( - test_module, "MenuRequest", autospec=True - ) as menu_request, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "MenuRequest", autospec=True) as menu_request, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_record.retrieve_by_id = mock.CoroutineMock() await test_module.actionmenu_request(self.request) @@ -142,9 +148,12 @@ async def test_actionmenu_request_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object(test_module, "Perform", autospec=True): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Perform", autospec=True), + ): # Emulate storage not found (bad connection id) mock_conn_record.retrieve_by_id = mock.CoroutineMock( side_effect=StorageNotFoundError @@ -157,9 +166,12 @@ async def test_actionmenu_request_conn_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object(test_module, "Perform", autospec=True): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Perform", autospec=True), + ): # Emulate connection not ready mock_conn_record.retrieve_by_id = mock.CoroutineMock() mock_conn_record.retrieve_by_id.return_value.is_ready = False @@ -171,13 +183,13 @@ async def test_actionmenu_send(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object( - test_module, "Menu", autospec=True - ) as mock_menu, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Menu", autospec=True) as mock_menu, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_record.retrieve_by_id = mock.CoroutineMock() mock_menu.deserialize = mock.MagicMock() @@ -192,11 +204,12 @@ async def test_actionmenu_send_deserialize_x(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object( - test_module, "Menu", autospec=True - ) as mock_menu: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Menu", autospec=True) as mock_menu, + ): mock_conn_record.retrieve_by_id = mock.CoroutineMock() mock_menu.deserialize = mock.MagicMock( side_effect=test_module.BaseModelError("cannot deserialize") @@ -209,11 +222,12 @@ async def test_actionmenu_send_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object( - test_module, "Menu", autospec=True - ) as mock_menu: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Menu", autospec=True) as mock_menu, + ): mock_menu.deserialize = mock.MagicMock() # Emulate storage not found (bad connection id) @@ -228,11 +242,12 @@ async def test_actionmenu_send_conn_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_record, mock.patch.object( - test_module, "Menu", autospec=True - ) as mock_menu: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_record, + mock.patch.object(test_module, "Menu", autospec=True) as mock_menu, + ): mock_menu.deserialize = mock.MagicMock() # Emulate connection not ready diff --git a/acapy_agent/protocols/basicmessage/v1_0/tests/test_routes.py b/acapy_agent/protocols/basicmessage/v1_0/tests/test_routes.py index cd15506fd4..736ae633d7 100644 --- a/acapy_agent/protocols/basicmessage/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/basicmessage/v1_0/tests/test_routes.py @@ -33,13 +33,15 @@ async def test_connections_send_message(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": self.test_conn_id} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_connection_record, mock.patch.object( - test_module, "BasicMessage", autospec=True - ) as mock_basic_message, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_connection_record, + mock.patch.object( + test_module, "BasicMessage", autospec=True + ) as mock_basic_message, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_connection_record.retrieve_by_id = mock.CoroutineMock() await test_module.connections_send_message(self.request) @@ -50,10 +52,11 @@ async def test_connections_send_message_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": self.test_conn_id} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_connection_record, mock.patch.object( - test_module, "BasicMessage", autospec=True + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_connection_record, + mock.patch.object(test_module, "BasicMessage", autospec=True), ): # Emulate storage not found (bad connection id) mock_connection_record.retrieve_by_id = mock.CoroutineMock( @@ -67,11 +70,14 @@ async def test_connections_send_message_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"conn_id": self.test_conn_id} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_connection_record, mock.patch.object( - test_module, "BasicMessage", autospec=True - ) as mock_basic_message: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_connection_record, + mock.patch.object( + test_module, "BasicMessage", autospec=True + ) as mock_basic_message, + ): # Emulate connection not ready mock_connection_record.retrieve_by_id = mock.CoroutineMock() mock_connection_record.retrieve_by_id.return_value.is_ready = False diff --git a/acapy_agent/protocols/connections/v1_0/tests/test_manager.py b/acapy_agent/protocols/connections/v1_0/tests/test_manager.py index a96363dc00..eb2c5b7f6d 100644 --- a/acapy_agent/protocols/connections/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/connections/v1_0/tests/test_manager.py @@ -412,14 +412,18 @@ async def test_create_request_multitenant(self): endpoint=self.test_mediator_endpoint, ) - with mock.patch.object( - AskarWallet, "create_local_did", autospec=True - ) as mock_wallet_create_local_did, mock.patch.object( - ConnectionManager, "create_did_document", autospec=True - ) as create_did_document, mock.patch.object( - self.route_manager, - "mediation_records_for_connection", - mock.CoroutineMock(return_value=[mediation_record]), + with ( + mock.patch.object( + AskarWallet, "create_local_did", autospec=True + ) as mock_wallet_create_local_did, + mock.patch.object( + ConnectionManager, "create_did_document", autospec=True + ) as create_did_document, + mock.patch.object( + self.route_manager, + "mediation_records_for_connection", + mock.CoroutineMock(return_value=[mediation_record]), + ), ): mock_wallet_create_local_did.return_value = DIDInfo( self.test_did, @@ -465,14 +469,16 @@ async def test_create_request_mediation_id(self): # Ensure the path with new did creation is hit record.my_did = None - with mock.patch.object( - ConnectionManager, "create_did_document", autospec=True - ) as create_did_document, mock.patch.object( - AskarWallet, "create_local_did" - ) as create_local_did, mock.patch.object( - self.route_manager, - "mediation_records_for_connection", - mock.CoroutineMock(return_value=[mediation_record]), + with ( + mock.patch.object( + ConnectionManager, "create_did_document", autospec=True + ) as create_did_document, + mock.patch.object(AskarWallet, "create_local_did") as create_local_did, + mock.patch.object( + self.route_manager, + "mediation_records_for_connection", + mock.CoroutineMock(return_value=[mediation_record]), + ), ): did_info = DIDInfo( did=self.test_did, @@ -516,14 +522,16 @@ async def test_create_request_default_mediator(self): # Ensure the path with new did creation is hit record.my_did = None - with mock.patch.object( - ConnectionManager, "create_did_document", autospec=True - ) as create_did_document, mock.patch.object( - AskarWallet, "create_local_did" - ) as create_local_did, mock.patch.object( - self.route_manager, - "mediation_records_for_connection", - mock.CoroutineMock(return_value=[mediation_record]), + with ( + mock.patch.object( + ConnectionManager, "create_did_document", autospec=True + ) as create_did_document, + mock.patch.object(AskarWallet, "create_local_did") as create_local_did, + mock.patch.object( + self.route_manager, + "mediation_records_for_connection", + mock.CoroutineMock(return_value=[mediation_record]), + ), ): did_info = DIDInfo( did=self.test_did, @@ -565,18 +573,18 @@ async def test_receive_request_public_did_oob_invite(self): ) self.context.update_settings({"public_invites": True}) - with mock.patch.object( - ConnRecord, "connection_id", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_invitation_msg_id, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "connection_id", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_invitation_msg_id, + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_conn_retrieve_by_invitation_msg_id.return_value = ConnRecord() conn_rec = await self.manager.receive_request(mock_request, receipt) @@ -606,18 +614,19 @@ async def test_receive_request_public_did_unsolicited_fails(self): ) self.context.update_settings({"public_invites": True}) - with self.assertRaises(ConnectionManagerError), mock.patch.object( - ConnRecord, "connection_id", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_invitation_msg_id, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + self.assertRaises(ConnectionManagerError), + mock.patch.object(ConnRecord, "connection_id", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_invitation_msg_id, + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_conn_retrieve_by_invitation_msg_id.return_value = None await self.manager.receive_request(mock_request, receipt) @@ -646,20 +655,20 @@ async def test_receive_request_public_did_conn_invite(self): mock_connection_record.attach_request = mock.CoroutineMock() self.context.update_settings({"public_invites": True}) - with mock.patch.object( - ConnRecord, "connection_id", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object( - ConnRecord, - "retrieve_by_invitation_msg_id", - mock.CoroutineMock(return_value=mock_connection_record), - ), mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "connection_id", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object( + ConnRecord, + "retrieve_by_invitation_msg_id", + mock.CoroutineMock(return_value=mock_connection_record), + ), + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): conn_rec = await self.manager.receive_request(mock_request, receipt) assert conn_rec @@ -685,18 +694,18 @@ async def test_receive_request_public_did_unsolicited(self): self.context.update_settings({"public_invites": True}) self.context.update_settings({"requests_through_public_did": True}) - with mock.patch.object( - ConnRecord, "connection_id", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_invitation_msg_id, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "connection_id", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_invitation_msg_id, + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_conn_retrieve_by_invitation_msg_id.return_value = None conn_rec = await self.manager.receive_request(mock_request, receipt) @@ -721,11 +730,12 @@ async def test_receive_request_public_did_no_did_doc(self): ) self.context.update_settings({"public_invites": True}) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object(ConnRecord, "retrieve_request", autospec=True): + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + ): with self.assertRaises(ConnectionManagerError): await self.manager.receive_request(mock_request, receipt) @@ -749,11 +759,12 @@ async def test_receive_request_public_did_wrong_did(self): ) self.context.update_settings({"public_invites": True}) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object(ConnRecord, "retrieve_request", autospec=True): + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + ): with self.assertRaises(ConnectionManagerError): await self.manager.receive_request(mock_request, receipt) @@ -775,13 +786,13 @@ async def test_receive_request_public_did_no_public_invites(self): ) self.context.update_settings({"public_invites": False}) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()): + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), + ): with self.assertRaises(ConnectionManagerError): await self.manager.receive_request(mock_request, receipt) @@ -807,16 +818,17 @@ async def test_receive_request_public_did_no_auto_accept(self): self.context.update_settings( {"public_invites": True, "debug.auto_accept_requests": False} ) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "attach_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_id", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_invitation_msg_id, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnRecord, "attach_request", autospec=True), + mock.patch.object(ConnRecord, "retrieve_by_id", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_invitation_msg_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_invitation_msg_id, + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_conn_retrieve_by_invitation_msg_id.return_value = ConnRecord() conn_rec = await self.manager.receive_request(mock_request, receipt) @@ -828,11 +840,13 @@ async def test_receive_request_public_did_no_auto_accept(self): async def test_create_response(self): conn_rec = ConnRecord(state=ConnRecord.State.REQUEST.rfc160) - with mock.patch.object(ConnRecord, "log_state", autospec=True), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnectionResponse, "sign_field", autospec=True - ), mock.patch.object(conn_rec, "metadata_get", mock.CoroutineMock()): + with ( + mock.patch.object(ConnRecord, "log_state", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnectionResponse, "sign_field", autospec=True), + mock.patch.object(conn_rec, "metadata_get", mock.CoroutineMock()), + ): await self.manager.create_response(conn_rec, "http://10.20.30.40:5060/") async def test_create_response_multitenant(self): @@ -849,22 +863,25 @@ async def test_create_response_multitenant(self): endpoint=self.test_mediator_endpoint, ) - with mock.patch.object(ConnRecord, "log_state", autospec=True), mock.patch.object( - ConnRecord, "save", autospec=True - ), mock.patch.object( - ConnRecord, "metadata_get", mock.CoroutineMock(return_value=False) - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object( - ConnectionResponse, "sign_field", autospec=True - ), mock.patch.object( - AskarWallet, "create_local_did", autospec=True - ) as mock_wallet_create_local_did, mock.patch.object( - ConnectionManager, "create_did_document", autospec=True - ) as create_did_document, mock.patch.object( - self.route_manager, - "mediation_records_for_connection", - mock.CoroutineMock(return_value=[mediation_record]), + with ( + mock.patch.object(ConnRecord, "log_state", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "metadata_get", mock.CoroutineMock(return_value=False) + ), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object(ConnectionResponse, "sign_field", autospec=True), + mock.patch.object( + AskarWallet, "create_local_did", autospec=True + ) as mock_wallet_create_local_did, + mock.patch.object( + ConnectionManager, "create_did_document", autospec=True + ) as create_did_document, + mock.patch.object( + self.route_manager, + "mediation_records_for_connection", + mock.CoroutineMock(return_value=[mediation_record]), + ), ): mock_wallet_create_local_did.return_value = DIDInfo( self.test_did, @@ -921,21 +938,24 @@ async def test_create_response_mediation(self): # Ensure the path with new did creation is hit record.my_did = None - with mock.patch.object(ConnRecord, "log_state", autospec=True), mock.patch.object( - ConnRecord, "save", autospec=True - ), mock.patch.object( - record, "metadata_get", mock.CoroutineMock(return_value=False) - ), mock.patch.object( - ConnectionManager, "create_did_document", autospec=True - ) as create_did_document, mock.patch.object( - AskarWallet, "create_local_did" - ) as create_local_did, mock.patch.object( - self.route_manager, - "mediation_records_for_connection", - mock.CoroutineMock(return_value=[mediation_record]), - ), mock.patch.object( - record, "retrieve_request", autospec=True - ), mock.patch.object(ConnectionResponse, "sign_field", autospec=True): + with ( + mock.patch.object(ConnRecord, "log_state", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + record, "metadata_get", mock.CoroutineMock(return_value=False) + ), + mock.patch.object( + ConnectionManager, "create_did_document", autospec=True + ) as create_did_document, + mock.patch.object(AskarWallet, "create_local_did") as create_local_did, + mock.patch.object( + self.route_manager, + "mediation_records_for_connection", + mock.CoroutineMock(return_value=[mediation_record]), + ), + mock.patch.object(record, "retrieve_request", autospec=True), + mock.patch.object(ConnectionResponse, "sign_field", autospec=True), + ): did_info = DIDInfo( did=self.test_did, verkey=self.test_verkey, @@ -964,12 +984,14 @@ async def test_create_response_auto_send_mediation_request(self): ) conn_rec.my_did = None - with mock.patch.object(ConnRecord, "log_state", autospec=True), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnectionResponse, "sign_field", autospec=True - ), mock.patch.object( - conn_rec, "metadata_get", mock.CoroutineMock(return_value=True) + with ( + mock.patch.object(ConnRecord, "log_state", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object(ConnectionResponse, "sign_field", autospec=True), + mock.patch.object( + conn_rec, "metadata_get", mock.CoroutineMock(return_value=True) + ), ): await self.manager.create_response(conn_rec) @@ -988,11 +1010,16 @@ async def test_accept_response_find_by_thread_id(self): mock_response.verify_signed_field = mock.CoroutineMock(return_value="sig_verkey") receipt = MessageReceipt(recipient_did=self.test_did, recipient_did_public=True) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - MediationManager, "get_default_mediator", mock.CoroutineMock() - ), mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()): + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + MediationManager, "get_default_mediator", mock.CoroutineMock() + ), + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), + ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=self.test_target_did, did_doc=mock.MagicMock(did=self.test_target_did), @@ -1017,13 +1044,19 @@ async def test_accept_response_not_found_by_thread_id_receipt_has_sender_did(sel receipt = MessageReceipt(sender_did=self.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_did", mock.CoroutineMock() - ) as mock_conn_retrieve_by_did, mock.patch.object( - MediationManager, "get_default_mediator", mock.CoroutineMock() - ), mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()): + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ) as mock_conn_retrieve_by_did, + mock.patch.object( + MediationManager, "get_default_mediator", mock.CoroutineMock() + ), + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), + ): mock_conn_retrieve_by_req_id.side_effect = StorageNotFoundError() mock_conn_retrieve_by_did.return_value = mock.MagicMock( did=self.test_target_did, @@ -1051,11 +1084,15 @@ async def test_accept_response_not_found_by_thread_id_nor_receipt_sender_did(sel receipt = MessageReceipt(sender_did=self.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_did", mock.CoroutineMock() - ) as mock_conn_retrieve_by_did: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ) as mock_conn_retrieve_by_did, + ): mock_conn_retrieve_by_req_id.side_effect = StorageNotFoundError() mock_conn_retrieve_by_did.side_effect = StorageNotFoundError() @@ -1072,9 +1109,12 @@ async def test_accept_response_find_by_thread_id_bad_state(self): receipt = MessageReceipt(sender_did=self.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( state=ConnRecord.State.ABANDONED.rfc23 ) @@ -1091,9 +1131,12 @@ async def test_accept_response_find_by_thread_id_no_connection_did_doc(self): receipt = MessageReceipt(sender_did=self.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=self.test_target_did, did_doc=mock.MagicMock(did=self.test_target_did), @@ -1113,9 +1156,12 @@ async def test_accept_response_find_by_thread_id_did_mismatch(self): receipt = MessageReceipt(sender_did=self.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=self.test_target_did, did_doc=mock.MagicMock(did=self.test_target_did), @@ -1135,10 +1181,14 @@ async def test_accept_response_verify_invitation_key_sign_failure(self): mock_response.verify_signed_field = mock.CoroutineMock(side_effect=ValueError) receipt = MessageReceipt(recipient_did=self.test_did, recipient_did_public=True) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - MediationManager, "get_default_mediator", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + MediationManager, "get_default_mediator", mock.CoroutineMock() + ), ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=self.test_target_did, @@ -1162,11 +1212,16 @@ async def test_accept_response_auto_send_mediation_request(self): mock_response.verify_signed_field = mock.CoroutineMock(return_value="sig_verkey") receipt = MessageReceipt(recipient_did=self.test_did, recipient_did_public=True) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - MediationManager, "get_default_mediator", mock.CoroutineMock() - ), mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()): + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + MediationManager, "get_default_mediator", mock.CoroutineMock() + ), + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), + ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=self.test_target_did, did_doc=mock.MagicMock(did=self.test_target_did), diff --git a/acapy_agent/protocols/connections/v1_0/tests/test_routes.py b/acapy_agent/protocols/connections/v1_0/tests/test_routes.py index 46f32714eb..917c795c5f 100644 --- a/acapy_agent/protocols/connections/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/connections/v1_0/tests/test_routes.py @@ -146,11 +146,12 @@ async def test_connections_retrieve(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock(return_value={"hello": "world"}) - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec await test_module.connections_retrieve(self.request) @@ -159,11 +160,12 @@ async def test_connections_retrieve(self): async def test_connections_endpoints(self): self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_mgr_cls.return_value = mock.MagicMock( get_endpoints=mock.CoroutineMock( return_value=("localhost:8080", "1.2.3.4:8081") @@ -180,9 +182,12 @@ async def test_connections_endpoints(self): async def test_connections_endpoints_x(self): self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr_cls, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr_cls, + mock.patch.object(test_module.web, "json_response"), + ): mock_conn_mgr_cls.return_value = mock.MagicMock( get_endpoints=mock.CoroutineMock(side_effect=StorageNotFoundError()) ) @@ -201,13 +206,15 @@ async def test_connections_metadata(self): self.request.match_info = {"conn_id": "dummy"} mock_conn_rec = mock.MagicMock() - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - mock_conn_rec, "metadata_get_all", mock.CoroutineMock() - ) as mock_metadata_get_all, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object( + mock_conn_rec, "metadata_get_all", mock.CoroutineMock() + ) as mock_metadata_get_all, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_metadata_get_all.return_value = {"hello": "world"} @@ -220,15 +227,16 @@ async def test_connections_metadata_get_single(self): mock_conn_rec = mock.MagicMock() self.request.query = {"key": "test"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - mock_conn_rec, "metadata_get_all", mock.CoroutineMock() - ), mock.patch.object( - mock_conn_rec, "metadata_get", mock.CoroutineMock() - ) as mock_metadata_get, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object(mock_conn_rec, "metadata_get_all", mock.CoroutineMock()), + mock.patch.object( + mock_conn_rec, "metadata_get", mock.CoroutineMock() + ) as mock_metadata_get, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_metadata_get.return_value = {"test": "value"} @@ -240,11 +248,15 @@ async def test_connections_metadata_x(self): self.request.match_info = {"conn_id": "dummy"} mock_conn_rec = mock.MagicMock() - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - mock_conn_rec, "metadata_get_all", mock.CoroutineMock() - ) as mock_metadata_get_all, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object( + mock_conn_rec, "metadata_get_all", mock.CoroutineMock() + ) as mock_metadata_get_all, + mock.patch.object(test_module.web, "json_response"), + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_metadata_get_all.side_effect = StorageNotFoundError() @@ -262,15 +274,18 @@ async def test_connections_metadata_set(self): return_value={"metadata": {"hello": "world"}} ) - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - mock_conn_rec, "metadata_get_all", mock.CoroutineMock() - ) as mock_metadata_get_all, mock.patch.object( - mock_conn_rec, "metadata_set", mock.CoroutineMock() - ) as mock_metadata_set, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object( + mock_conn_rec, "metadata_get_all", mock.CoroutineMock() + ) as mock_metadata_get_all, + mock.patch.object( + mock_conn_rec, "metadata_set", mock.CoroutineMock() + ) as mock_metadata_set, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_metadata_get_all.return_value = {"hello": "world"} @@ -285,13 +300,16 @@ async def test_connections_metadata_set_x(self): return_value={"metadata": {"hello": "world"}} ) - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - mock_conn_rec, "metadata_get_all", mock.CoroutineMock() - ), mock.patch.object( - mock_conn_rec, "metadata_set", mock.CoroutineMock() - ) as mock_metadata_set, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object(mock_conn_rec, "metadata_get_all", mock.CoroutineMock()), + mock.patch.object( + mock_conn_rec, "metadata_set", mock.CoroutineMock() + ) as mock_metadata_set, + mock.patch.object(test_module.web, "json_response"), + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_metadata_set.side_effect = StorageNotFoundError() @@ -343,11 +361,12 @@ async def test_connections_create_invitation(self): "multi_use": "true", } - with mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_mgr.return_value.create_invitation = mock.CoroutineMock( return_value=( mock.MagicMock( # connection record @@ -450,13 +469,15 @@ async def test_connections_receive_invitation(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module.ConnectionInvitation, "deserialize", autospec=True - ), mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnectionInvitation, "deserialize", autospec=True + ), + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_mgr.return_value.receive_invitation = mock.CoroutineMock( return_value=mock_conn_rec ) @@ -474,10 +495,11 @@ async def test_connections_receive_invitation_bad(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module.ConnectionInvitation, "deserialize", autospec=True - ) as mock_inv_deser, mock.patch.object( - test_module, "ConnectionManager", autospec=True + with ( + mock.patch.object( + test_module.ConnectionInvitation, "deserialize", autospec=True + ) as mock_inv_deser, + mock.patch.object(test_module, "ConnectionManager", autospec=True), ): mock_inv_deser.side_effect = test_module.BaseModelError() @@ -501,11 +523,14 @@ async def test_connections_receive_invitation_x_bad_mediation_id(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module.ConnectionInvitation, "deserialize", autospec=True - ), mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr: + with ( + mock.patch.object( + test_module.ConnectionInvitation, "deserialize", autospec=True + ), + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + ): mock_conn_mgr.return_value.receive_invitation = mock.CoroutineMock( side_effect=StorageNotFoundError() ) @@ -523,13 +548,15 @@ async def test_connections_accept_invitation(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_conn_mgr.return_value.create_request = mock.CoroutineMock() @@ -550,11 +577,14 @@ async def test_connections_accept_invitation_not_found(self): async def test_connections_accept_invitation_x(self): self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + ): mock_conn_mgr.return_value.create_request = mock.CoroutineMock( side_effect=test_module.ConnectionManagerError() ) @@ -566,11 +596,14 @@ async def test_connections_accept_invitation_x_bad_mediation_id(self): self.request.match_info = {"conn_id": "dummy"} self.request.query["mediation_id"] = "some-id" - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + ): mock_conn_mgr.return_value.create_request = mock.CoroutineMock( side_effect=StorageNotFoundError() ) @@ -587,13 +620,15 @@ async def test_connections_accept_request(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_conn_mgr.return_value.create_response = mock.CoroutineMock() @@ -614,11 +649,15 @@ async def test_connections_accept_request_not_found(self): async def test_connections_accept_request_x(self): self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_conn_mgr.return_value.create_response = mock.CoroutineMock( side_effect=test_module.ConnectionManagerError() ) @@ -631,11 +670,12 @@ async def test_connections_remove(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.delete_record = mock.CoroutineMock() - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec await test_module.connections_remove(self.request) @@ -650,11 +690,12 @@ async def test_connections_remove_cache_key(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.delete_record = mock.CoroutineMock() assert (await cache.get("conn_rec_state::dummy")) == "active" - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec await test_module.connections_remove(self.request) @@ -714,11 +755,12 @@ async def test_connections_create_static(self): mock_their_info.did = "their_did" mock_their_info.verkey = "their_verkey" - with mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_conn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_conn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_mgr.return_value.create_static_connection = mock.CoroutineMock( return_value=(mock_my_info, mock_their_info, mock_conn_rec) ) diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_keylist_update_response_handler.py b/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_keylist_update_response_handler.py index 8f7dbcc25d..4d32ebc819 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_keylist_update_response_handler.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_keylist_update_response_handler.py @@ -57,11 +57,10 @@ async def test_handler_no_active_connection(self): async def test_handler(self): handler, responder = KeylistUpdateResponseHandler(), MockResponder() - with mock.patch.object( - MediationManager, "store_update_results" - ) as mock_store, mock.patch.object( - handler, "notify_keylist_updated" - ) as mock_notify: + with ( + mock.patch.object(MediationManager, "store_update_results") as mock_store, + mock.patch.object(handler, "notify_keylist_updated") as mock_notify, + ): await handler.handle(self.context, responder) mock_store.assert_called_once_with(TEST_CONN_ID, self.updated) mock_notify.assert_called_once_with( diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_mediation_grant_handler.py b/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_mediation_grant_handler.py index 79b2ab6ae2..e494e4c83a 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_mediation_grant_handler.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/tests/test_mediation_grant_handler.py @@ -78,13 +78,16 @@ async def test_handler_connection_has_set_to_default_meta( handler, responder = MediationGrantHandler(), MockResponder() record = MediationRecord(connection_id=TEST_CONN_ID) await record.save(session) - with mock.patch.object( - context.connection_record, - "metadata_get", - mock.CoroutineMock(return_value=True), - ), mock.patch.object( - test_module, "MediationManager", autospec=True - ) as mock_mediation_manager: + with ( + mock.patch.object( + context.connection_record, + "metadata_get", + mock.CoroutineMock(return_value=True), + ), + mock.patch.object( + test_module, "MediationManager", autospec=True + ) as mock_mediation_manager, + ): await handler.handle(context, responder) mock_mediation_manager.return_value.set_default_mediator.assert_called_once_with( record @@ -127,12 +130,15 @@ async def test_handler_connection_no_set_to_default( handler, responder = MediationGrantHandler(), MockResponder() record = MediationRecord(connection_id=TEST_CONN_ID) await record.save(session) - with mock.patch.object( - context.connection_record, - "metadata_get", - mock.CoroutineMock(return_value=False), - ), mock.patch.object( - test_module, "MediationManager", autospec=True - ) as mock_mediation_manager: + with ( + mock.patch.object( + context.connection_record, + "metadata_get", + mock.CoroutineMock(return_value=False), + ), + mock.patch.object( + test_module, "MediationManager", autospec=True + ) as mock_mediation_manager, + ): await handler.handle(context, responder) mock_mediation_manager.return_value.set_default_mediator.assert_not_called() diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_mediation_manager.py b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_mediation_manager.py index 9bd237c9c0..c0ef5c6855 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_mediation_manager.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_mediation_manager.py @@ -397,21 +397,27 @@ async def test_store_update_results( ), ] - with mock.patch.object( - RouteRecord, "query", mock.CoroutineMock() - ) as mock_route_rec_query, mock.patch.object( - test_module.LOGGER, "error", mock.MagicMock() - ) as mock_logger_error: + with ( + mock.patch.object( + RouteRecord, "query", mock.CoroutineMock() + ) as mock_route_rec_query, + mock.patch.object( + test_module.LOGGER, "error", mock.MagicMock() + ) as mock_logger_error, + ): mock_route_rec_query.side_effect = StorageNotFoundError("no record") await manager.store_update_results(TEST_CONN_ID, results) mock_logger_error.assert_called_once() - with mock.patch.object( - RouteRecord, "query", mock.CoroutineMock() - ) as mock_route_rec_query, mock.patch.object( - test_module.LOGGER, "error", mock.MagicMock() - ) as mock_logger_error: + with ( + mock.patch.object( + RouteRecord, "query", mock.CoroutineMock() + ) as mock_route_rec_query, + mock.patch.object( + test_module.LOGGER, "error", mock.MagicMock() + ) as mock_logger_error, + ): mock_route_rec_query.return_value = [ mock.MagicMock(delete_record=mock.CoroutineMock()) ] * 2 diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_route_manager.py b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_route_manager.py index 5ff5b4ac5b..86d9cc6bff 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_route_manager.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_route_manager.py @@ -78,13 +78,14 @@ async def test_get_or_create_my_did_no_did( ): conn_record.my_did = None mock_did_info = mock.MagicMock() - with mock.patch.object( - AskarWallet, - "create_local_did", - mock.CoroutineMock(return_value=mock_did_info), - ) as mock_create_local_did, mock.patch.object( - conn_record, "save", mock.CoroutineMock() - ) as mock_save: + with ( + mock.patch.object( + AskarWallet, + "create_local_did", + mock.CoroutineMock(return_value=mock_did_info), + ) as mock_create_local_did, + mock.patch.object(conn_record, "save", mock.CoroutineMock()) as mock_save, + ): info = await route_manager.get_or_create_my_did(profile, conn_record) assert mock_did_info == info mock_create_local_did.assert_called_once() @@ -110,12 +111,15 @@ async def test_mediation_record_for_connection_mediation_id( profile: Profile, route_manager: RouteManager, conn_record: ConnRecord ): mediation_record = MediationRecord(mediation_id="test-mediation-id") - with mock.patch.object( - route_manager, - "mediation_record_if_id", - mock.CoroutineMock(return_value=mediation_record), - ) as mock_mediation_record_if_id, mock.patch.object( - route_manager, "save_mediator_for_connection", mock.CoroutineMock() + with ( + mock.patch.object( + route_manager, + "mediation_record_if_id", + mock.CoroutineMock(return_value=mediation_record), + ) as mock_mediation_record_if_id, + mock.patch.object( + route_manager, "save_mediator_for_connection", mock.CoroutineMock() + ), ): assert await route_manager.mediation_records_for_connection( profile, conn_record, mediation_record.mediation_id @@ -133,12 +137,15 @@ async def test_mediation_record_for_connection_mediation_metadata( conn_record.metadata_get.return_value = { MediationManager.METADATA_ID: mediation_record.mediation_id } - with mock.patch.object( - route_manager, - "mediation_record_if_id", - mock.CoroutineMock(return_value=mediation_record), - ) as mock_mediation_record_if_id, mock.patch.object( - route_manager, "save_mediator_for_connection", mock.CoroutineMock() + with ( + mock.patch.object( + route_manager, + "mediation_record_if_id", + mock.CoroutineMock(return_value=mediation_record), + ) as mock_mediation_record_if_id, + mock.patch.object( + route_manager, "save_mediator_for_connection", mock.CoroutineMock() + ), ): assert await route_manager.mediation_records_for_connection( profile, conn_record, "another-mediation-id" @@ -153,12 +160,15 @@ async def test_mediation_record_for_connection_default( profile: Profile, route_manager: RouteManager, conn_record: ConnRecord ): mediation_record = MediationRecord(mediation_id="test-mediation-id") - with mock.patch.object( - route_manager, - "mediation_record_if_id", - mock.CoroutineMock(return_value=mediation_record), - ) as mock_mediation_record_if_id, mock.patch.object( - route_manager, "save_mediator_for_connection", mock.CoroutineMock() + with ( + mock.patch.object( + route_manager, + "mediation_record_if_id", + mock.CoroutineMock(return_value=mediation_record), + ) as mock_mediation_record_if_id, + mock.patch.object( + route_manager, "save_mediator_for_connection", mock.CoroutineMock() + ), ): assert await route_manager.mediation_records_for_connection( profile, conn_record, None, or_default=True @@ -210,13 +220,16 @@ async def test_mediation_record_if_id_with_id_and_default( mediation_record = MediationRecord( mediation_id="test-mediation-id", state=MediationRecord.STATE_GRANTED ) - with mock.patch.object( - MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mediation_record), - ) as mock_retrieve_by_id, mock.patch.object( - MediationManager, "get_default_mediator", mock.CoroutineMock() - ) as mock_get_default_mediator: + with ( + mock.patch.object( + MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mediation_record), + ) as mock_retrieve_by_id, + mock.patch.object( + MediationManager, "get_default_mediator", mock.CoroutineMock() + ) as mock_get_default_mediator, + ): actual = await route_manager.mediation_record_if_id( profile, mediation_id=mediation_record.mediation_id, or_default=True ) @@ -233,13 +246,16 @@ async def test_mediation_record_if_id_without_id_and_default( mediation_record = MediationRecord( mediation_id="test-mediation-id", state=MediationRecord.STATE_GRANTED ) - with mock.patch.object( - MediationRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve_by_id, mock.patch.object( - MediationManager, - "get_default_mediator", - mock.CoroutineMock(return_value=mediation_record), - ) as mock_get_default_mediator: + with ( + mock.patch.object( + MediationRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve_by_id, + mock.patch.object( + MediationManager, + "get_default_mediator", + mock.CoroutineMock(return_value=mediation_record), + ) as mock_get_default_mediator, + ): actual = await route_manager.mediation_record_if_id( profile, mediation_id=None, or_default=True ) @@ -253,11 +269,16 @@ async def test_mediation_record_if_id_without_id_and_no_default( profile: Profile, route_manager: RouteManager, ): - with mock.patch.object( - MediationRecord, "retrieve_by_id", mock.CoroutineMock(return_value=None) - ) as mock_retrieve_by_id, mock.patch.object( - MediationManager, "get_default_mediator", mock.CoroutineMock(return_value=None) - ) as mock_get_default_mediator: + with ( + mock.patch.object( + MediationRecord, "retrieve_by_id", mock.CoroutineMock(return_value=None) + ) as mock_retrieve_by_id, + mock.patch.object( + MediationManager, + "get_default_mediator", + mock.CoroutineMock(return_value=None), + ) as mock_get_default_mediator, + ): assert ( await route_manager.mediation_record_if_id( profile, mediation_id=None, or_default=True @@ -319,21 +340,24 @@ async def test_route_connection_state_inviter_replace_key_none( mock_did_info = mock.MagicMock(DIDInfo) conn_record.invitation_key = TEST_RECORD_VERKEY - with mock.patch.object( - route_manager, - "get_or_create_my_did", - mock.CoroutineMock(return_value=mock_did_info), - ), mock.patch.object( - AskarWallet, - "get_public_did", - mock.CoroutineMock( - return_value=DIDInfo( - TEST_RECORD_DID, - TEST_RECORD_VERKEY, - None, - method=SOV, - key_type=ED25519, - ) + with ( + mock.patch.object( + route_manager, + "get_or_create_my_did", + mock.CoroutineMock(return_value=mock_did_info), + ), + mock.patch.object( + AskarWallet, + "get_public_did", + mock.CoroutineMock( + return_value=DIDInfo( + TEST_RECORD_DID, + TEST_RECORD_VERKEY, + None, + method=SOV, + key_type=ED25519, + ) + ), ), ): await route_manager.route_connection_as_inviter( @@ -355,11 +379,14 @@ async def test_route_connection_state_invitee( mediation_record = MediationRecord(mediation_id="test-mediation-id") conn_record.state = "invitation" conn_record.their_role = "responder" - with mock.patch.object( - route_manager, "route_connection_as_invitee", mock.CoroutineMock() - ) as mock_route_connection_as_invitee, mock.patch.object( - route_manager, "route_connection_as_inviter", mock.CoroutineMock() - ) as mock_route_connection_as_inviter: + with ( + mock.patch.object( + route_manager, "route_connection_as_invitee", mock.CoroutineMock() + ) as mock_route_connection_as_invitee, + mock.patch.object( + route_manager, "route_connection_as_inviter", mock.CoroutineMock() + ) as mock_route_connection_as_inviter, + ): await route_manager.route_connection(profile, conn_record, [mediation_record]) mock_route_connection_as_invitee.assert_called_once() mock_route_connection_as_inviter.assert_not_called() @@ -372,11 +399,14 @@ async def test_route_connection_state_inviter( mediation_record = MediationRecord(mediation_id="test-mediation-id") conn_record.state = "request" conn_record.their_role = "requester" - with mock.patch.object( - route_manager, "route_connection_as_invitee", mock.CoroutineMock() - ) as mock_route_connection_as_invitee, mock.patch.object( - route_manager, "route_connection_as_inviter", mock.CoroutineMock() - ) as mock_route_connection_as_inviter: + with ( + mock.patch.object( + route_manager, "route_connection_as_invitee", mock.CoroutineMock() + ) as mock_route_connection_as_invitee, + mock.patch.object( + route_manager, "route_connection_as_inviter", mock.CoroutineMock() + ) as mock_route_connection_as_inviter, + ): await route_manager.route_connection(profile, conn_record, [mediation_record]) mock_route_connection_as_inviter.assert_called_once() mock_route_connection_as_invitee.assert_not_called() diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_routes.py b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_routes.py index 773f31fbc6..cf0eda45ab 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_routes.py @@ -71,13 +71,14 @@ def test_mediation_sort_key(self): async def test_list_mediation_requests(self): self.request.query = {} - with mock.patch.object( - test_module.MediationRecord, - "query", - mock.CoroutineMock(return_value=[self.mock_record]), - ) as mock_query, mock.patch.object( - test_module.web, "json_response" - ) as json_response: + with ( + mock.patch.object( + test_module.MediationRecord, + "query", + mock.CoroutineMock(return_value=[self.mock_record]), + ) as mock_query, + mock.patch.object(test_module.web, "json_response") as json_response, + ): await test_module.list_mediation_requests(self.request) json_response.assert_called_once_with( {"results": [self.mock_record.serialize.return_value]} @@ -89,13 +90,14 @@ async def test_list_mediation_requests_filters(self): "state": MediationRecord.STATE_GRANTED, "conn_id": "test-conn-id", } - with mock.patch.object( - test_module.MediationRecord, - "query", - mock.CoroutineMock(return_value=[self.mock_record]), - ) as mock_query, mock.patch.object( - test_module.web, "json_response" - ) as json_response: + with ( + mock.patch.object( + test_module.MediationRecord, + "query", + mock.CoroutineMock(return_value=[self.mock_record]), + ) as mock_query, + mock.patch.object(test_module.web, "json_response") as json_response, + ): await test_module.list_mediation_requests(self.request) json_response.assert_called_once_with( {"results": [self.mock_record.serialize.return_value]} @@ -114,53 +116,63 @@ async def test_list_mediation_requests_x(self): await test_module.list_mediation_requests(self.request) async def test_list_mediation_requests_no_records(self): - with mock.patch.object( - test_module, - "MediationRecord", - mock.MagicMock(query=mock.CoroutineMock(return_value=[])), - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object( + test_module, + "MediationRecord", + mock.MagicMock(query=mock.CoroutineMock(return_value=[])), + ), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): await test_module.list_mediation_requests(self.request) mock_response.assert_called_once_with({"results": []}) async def test_retrieve_mediation_request(self): - with mock.patch.object( - test_module.MediationRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_mediation_record_retrieve, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.MediationRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_mediation_record_retrieve, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_mediation_record_retrieve.return_value = self.mock_record await test_module.retrieve_mediation_request(self.request) mock_response.assert_called_once_with(self.mock_record.serialize.return_value) mock_mediation_record_retrieve.assert_called() async def test_retrieve_mediation_request_x_not_found(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), - ), mock.patch.object(test_module.web, "json_response"), self.assertRaises( - test_module.web.HTTPNotFound + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), + mock.patch.object(test_module.web, "json_response"), + self.assertRaises(test_module.web.HTTPNotFound), ): await test_module.retrieve_mediation_request(self.request) async def test_retrieve_mediation_request_x_storage_error(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), mock.patch.object(test_module.web, "json_response"), self.assertRaises( - test_module.web.HTTPBadRequest + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + mock.patch.object(test_module.web, "json_response"), + self.assertRaises(test_module.web.HTTPBadRequest), ): await test_module.retrieve_mediation_request(self.request) async def test_delete_mediation_request(self): - with mock.patch.object( - test_module.MediationRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_mediation_record_retrieve, mock.patch.object( - self.mock_record, "delete_record", mock.CoroutineMock() - ) as mock_delete_record, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.MediationRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_mediation_record_retrieve, + mock.patch.object( + self.mock_record, "delete_record", mock.CoroutineMock() + ) as mock_delete_record, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_mediation_record_retrieve.return_value = self.mock_record await test_module.delete_mediation_request(self.request) mock_response.assert_called_once_with(self.mock_record.serialize.return_value) @@ -168,38 +180,45 @@ async def test_delete_mediation_request(self): mock_delete_record.assert_called() async def test_delete_mediation_request_x_not_found(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), - ), mock.patch.object(test_module.web, "json_response"), self.assertRaises( - test_module.web.HTTPNotFound + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), + mock.patch.object(test_module.web, "json_response"), + self.assertRaises(test_module.web.HTTPNotFound), ): await test_module.delete_mediation_request(self.request) async def test_delete_mediation_request_x_storage_error(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), mock.patch.object(test_module.web, "json_response"), self.assertRaises( - test_module.web.HTTPBadRequest + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + mock.patch.object(test_module.web, "json_response"), + self.assertRaises(test_module.web.HTTPBadRequest), ): await test_module.delete_mediation_request(self.request) async def test_request_mediation(self): body = {} self.request.json.return_value = body - with mock.patch.object( - test_module, "MediationManager", autospec=True - ) as mock_med_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - test_module.MediationRecord, - "exists_for_connection_id", - mock.CoroutineMock(return_value=False), - ), mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "MediationManager", autospec=True + ) as mock_med_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + test_module.MediationRecord, + "exists_for_connection_id", + mock.CoroutineMock(return_value=False), + ), + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), ): mock_med_mgr.return_value.prepare_request = mock.CoroutineMock( return_value=( @@ -218,52 +237,68 @@ async def test_request_mediation(self): async def test_request_mediation_x_conn_not_ready(self): body = {} self.request.json.return_value = body - with mock.patch.object( - test_module.ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock.MagicMock(is_ready=False)), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock.MagicMock(is_ready=False)), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.request_mediation(self.request) async def test_request_mediation_x_already_exists(self): body = {} self.request.json.return_value = body - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module.MediationRecord, - "exists_for_connection_id", - mock.CoroutineMock(return_value=True), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object( + test_module.MediationRecord, + "exists_for_connection_id", + mock.CoroutineMock(return_value=True), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.request_mediation(self.request) async def test_request_mediation_x_conn_not_found(self): body = {} self.request.json.return_value = body - with mock.patch.object( - test_module.ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), - ), self.assertRaises(test_module.web.HTTPNotFound): + with ( + mock.patch.object( + test_module.ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), + self.assertRaises(test_module.web.HTTPNotFound), + ): await test_module.request_mediation(self.request) async def test_request_mediation_x_storage_error(self): body = {} self.request.json.return_value = body - with mock.patch.object( - test_module.ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.request_mediation(self.request) async def test_mediation_request_grant_role_server(self): self.mock_record.role = MediationRecord.ROLE_SERVER - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=self.mock_record), - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=self.mock_record), + ), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): await test_module.mediation_request_grant(self.request) mock_response.assert_called_once_with( self.mock_record.serialize.return_value, status=201 @@ -272,36 +307,48 @@ async def test_mediation_request_grant_role_server(self): async def test_mediation_request_grant_role_client_x(self): self.mock_record.role = MediationRecord.ROLE_CLIENT - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=self.mock_record), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=self.mock_record), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.mediation_request_grant(self.request) async def test_mediation_request_grant_x_rec_not_found(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), - ), self.assertRaises(test_module.web.HTTPNotFound): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), + self.assertRaises(test_module.web.HTTPNotFound), + ): await test_module.mediation_request_grant(self.request) async def test_mediation_request_grant_x_storage_error(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.mediation_request_grant(self.request) async def test_mediation_request_deny_role_server(self): self.mock_record.role = MediationRecord.ROLE_SERVER - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=self.mock_record), - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=self.mock_record), + ), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): await test_module.mediation_request_deny(self.request) mock_response.assert_called_once_with( self.mock_record.serialize.return_value, status=201 @@ -310,10 +357,11 @@ async def test_mediation_request_deny_role_server(self): async def test_mediation_request_deny_role_client_x(self): self.mock_record.role = MediationRecord.ROLE_CLIENT - with mock.patch.object( - test_module.MediationRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_mediation_record_retrieve, mock.patch.object( - test_module.web, "json_response" + with ( + mock.patch.object( + test_module.MediationRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_mediation_record_retrieve, + mock.patch.object(test_module.web, "json_response"), ): mock_mediation_record_retrieve.return_value = mock.MagicMock( role=MediationRecord.ROLE_CLIENT @@ -322,19 +370,25 @@ async def test_mediation_request_deny_role_client_x(self): await test_module.mediation_request_deny(self.request) async def test_mediation_request_deny_x_rec_not_found(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), - ), self.assertRaises(test_module.web.HTTPNotFound): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), + self.assertRaises(test_module.web.HTTPNotFound), + ): await test_module.mediation_request_deny(self.request) async def test_mediation_request_deny_x_storage_error(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.mediation_request_deny(self.request) async def test_get_keylist(self): @@ -348,17 +402,19 @@ async def test_get_keylist(self): ) ] - with mock.patch.object( - test_module.RouteRecord, - "query", - mock.CoroutineMock(return_value=query_results), - ) as mock_query, mock.patch.object( - self.profile, - "session", - mock.MagicMock(return_value=session), - ) as mock_session, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.RouteRecord, + "query", + mock.CoroutineMock(return_value=query_results), + ) as mock_query, + mock.patch.object( + self.profile, + "session", + mock.MagicMock(return_value=session), + ) as mock_session, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): await test_module.get_keylist(self.request) mock_response.assert_called_once_with( {"results": [{"serialized": "route record"}]}, status=200 @@ -370,27 +426,32 @@ async def test_get_keylist(self): async def test_get_keylist_no_matching_records(self): session = await self.profile.session() - with mock.patch.object( - test_module.RouteRecord, - "query", - mock.CoroutineMock(return_value=[]), - ) as mock_query, mock.patch.object( - self.profile, - "session", - mock.MagicMock(return_value=session), - ) as mock_session, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.RouteRecord, + "query", + mock.CoroutineMock(return_value=[]), + ) as mock_query, + mock.patch.object( + self.profile, + "session", + mock.MagicMock(return_value=session), + ) as mock_session, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): await test_module.get_keylist(self.request) mock_query.assert_called_once_with(mock_session.return_value, {}) mock_response.assert_called_once_with({"results": []}, status=200) async def test_get_keylist_storage_error(self): - with mock.patch.object( - test_module.RouteRecord, - "query", - mock.CoroutineMock(side_effect=test_module.StorageError), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.RouteRecord, + "query", + mock.CoroutineMock(side_effect=test_module.StorageError), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.get_keylist(self.request) async def test_send_keylist_update(self): @@ -421,18 +482,23 @@ async def test_send_keylist_update(self): self.request.json.return_value = body - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock( - return_value=mock.MagicMock( - state=MediationRecord.STATE_GRANTED, connection_id="test-conn-id" - ) + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock( + return_value=mock.MagicMock( + state=MediationRecord.STATE_GRANTED, connection_id="test-conn-id" + ) + ), + ), + mock.patch.object( + test_module.web, + "json_response", + mock.MagicMock( + side_effect=lambda *args, **kwargs: [*args, *kwargs.values()] + ), ), - ), mock.patch.object( - test_module.web, - "json_response", - mock.MagicMock(side_effect=lambda *args, **kwargs: [*args, *kwargs.values()]), ): results, status = await test_module.send_keylist_update(self.request) assert results["updates"] == body_with_didkey["updates"] @@ -461,15 +527,18 @@ async def test_send_keylist_update_bad_mediation_state(self): ] } - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock( - return_value=mock.MagicMock( - state=MediationRecord.STATE_DENIED, connection_id="test-conn-id" - ) + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock( + return_value=mock.MagicMock( + state=MediationRecord.STATE_DENIED, connection_id="test-conn-id" + ) + ), ), - ), self.assertRaises(test_module.web.HTTPBadRequest): + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.send_keylist_update(self.request) async def test_send_keylist_update_bad_updates(self): @@ -486,11 +555,14 @@ async def test_send_keylist_update_x_no_mediation_rec(self): }, ] } - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), - ), self.assertRaises(test_module.web.HTTPNotFound): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), + self.assertRaises(test_module.web.HTTPNotFound), + ): await test_module.send_keylist_update(self.request) async def test_send_keylist_update_x_storage_error(self): @@ -503,28 +575,33 @@ async def test_send_keylist_update_x_storage_error(self): ] } - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.send_keylist_update(self.request) @mock.patch.object(test_module, "MediationManager", autospec=True) async def test_send_keylist_query(self, mock_manager): self.request.json.return_value = {"filter": {"test": "filter"}} self.request.query = {"paginate_limit": 10, "paginate_offset": 20} - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=self.mock_record), - ), mock.patch.object( - mock_manager.return_value, - "prepare_keylist_query", - mock.CoroutineMock(), - ) as mock_prepare_keylist_query, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=self.mock_record), + ), + mock.patch.object( + mock_manager.return_value, + "prepare_keylist_query", + mock.CoroutineMock(), + ) as mock_prepare_keylist_query, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): await test_module.send_keylist_query(self.request) mock_prepare_keylist_query.assert_called_once_with( filter_={"test": "filter"}, paginate_limit=10, paginate_offset=20 @@ -536,29 +613,36 @@ async def test_send_keylist_query(self, mock_manager): ) async def test_send_keylist_query_x_no_mediation_record(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), - ), self.assertRaises(test_module.web.HTTPNotFound): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), + self.assertRaises(test_module.web.HTTPNotFound), + ): await test_module.send_keylist_query(self.request) async def test_send_keylist_query_x_storage_error(self): - with mock.patch.object( - test_module.MediationRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), self.assertRaises(test_module.web.HTTPBadRequest): + with ( + mock.patch.object( + test_module.MediationRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + self.assertRaises(test_module.web.HTTPBadRequest), + ): await test_module.send_keylist_query(self.request) async def test_get_default_mediator(self): self.request.query = {} - with mock.patch.object( - test_module.web, "json_response" - ) as json_response, mock.patch.object( - test_module.MediationManager, - "get_default_mediator", - mock.CoroutineMock(return_value=self.mock_record), + with ( + mock.patch.object(test_module.web, "json_response") as json_response, + mock.patch.object( + test_module.MediationManager, + "get_default_mediator", + mock.CoroutineMock(return_value=self.mock_record), + ), ): await test_module.get_default_mediator(self.request) json_response.assert_called_once_with( @@ -568,12 +652,13 @@ async def test_get_default_mediator(self): async def test_get_empty_default_mediator(self): self.request.query = {} - with mock.patch.object( - test_module.web, "json_response" - ) as json_response, mock.patch.object( - test_module.MediationManager, - "get_default_mediator", - mock.CoroutineMock(return_value=None), + with ( + mock.patch.object(test_module.web, "json_response") as json_response, + mock.patch.object( + test_module.MediationManager, + "get_default_mediator", + mock.CoroutineMock(return_value=None), + ), ): await test_module.get_default_mediator(self.request) json_response.assert_called_once_with( @@ -583,10 +668,13 @@ async def test_get_empty_default_mediator(self): async def test_get_default_mediator_storage_error(self): self.request.query = {} - with mock.patch.object(test_module.web, "json_response"), mock.patch.object( - test_module.MediationManager, - "get_default_mediator", - mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + with ( + mock.patch.object(test_module.web, "json_response"), + mock.patch.object( + test_module.MediationManager, + "get_default_mediator", + mock.CoroutineMock(side_effect=test_module.StorageNotFoundError()), + ), ): with self.assertRaises(test_module.web.HTTPBadRequest): await test_module.get_default_mediator(self.request) @@ -596,15 +684,19 @@ async def test_set_default_mediator(self): "mediation_id": "fake_id", } self.request.query = {} - with mock.patch.object( - test_module.MediationManager, - "get_default_mediator", - mock.CoroutineMock(return_value=self.mock_record), - ), mock.patch.object( - test_module.MediationManager, - "set_default_mediator_by_id", - mock.CoroutineMock(), - ), mock.patch.object(test_module.web, "json_response") as json_response: + with ( + mock.patch.object( + test_module.MediationManager, + "get_default_mediator", + mock.CoroutineMock(return_value=self.mock_record), + ), + mock.patch.object( + test_module.MediationManager, + "set_default_mediator_by_id", + mock.CoroutineMock(), + ), + mock.patch.object(test_module.web, "json_response") as json_response, + ): await test_module.set_default_mediator(self.request) json_response.assert_called_once_with( self.mock_record.serialize.return_value, @@ -616,29 +708,37 @@ async def test_set_default_mediator_storage_error(self): "mediation_id": "bad_id", } self.request.query = {} - with mock.patch.object( - test_module.MediationManager, - "get_default_mediator", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), mock.patch.object( - test_module.MediationManager, - "set_default_mediator_by_id", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.MediationManager, + "get_default_mediator", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + mock.patch.object( + test_module.MediationManager, + "set_default_mediator_by_id", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + mock.patch.object(test_module.web, "json_response"), + ): with self.assertRaises(test_module.web.HTTPBadRequest): await test_module.set_default_mediator(self.request) async def test_clear_default_mediator(self): self.request.query = {} - with mock.patch.object( - test_module.MediationManager, - "get_default_mediator", - mock.CoroutineMock(return_value=self.mock_record), - ), mock.patch.object( - test_module.MediationManager, - "clear_default_mediator", - mock.CoroutineMock(), - ), mock.patch.object(test_module.web, "json_response") as json_response: + with ( + mock.patch.object( + test_module.MediationManager, + "get_default_mediator", + mock.CoroutineMock(return_value=self.mock_record), + ), + mock.patch.object( + test_module.MediationManager, + "clear_default_mediator", + mock.CoroutineMock(), + ), + mock.patch.object(test_module.web, "json_response") as json_response, + ): await test_module.clear_default_mediator(self.request) json_response.assert_called_once_with( self.mock_record.serialize.return_value, @@ -647,15 +747,19 @@ async def test_clear_default_mediator(self): async def test_clear_default_mediator_storage_error(self): self.request.query = {} - with mock.patch.object( - test_module.MediationManager, - "get_default_mediator", - mock.CoroutineMock(side_effect=test_module.StorageError()), - ), mock.patch.object( - test_module.MediationManager, - "clear_default_mediator", - mock.CoroutineMock(), - ), mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.MediationManager, + "get_default_mediator", + mock.CoroutineMock(side_effect=test_module.StorageError()), + ), + mock.patch.object( + test_module.MediationManager, + "clear_default_mediator", + mock.CoroutineMock(), + ), + mock.patch.object(test_module.web, "json_response"), + ): with self.assertRaises(test_module.web.HTTPBadRequest): await test_module.clear_default_mediator(self.request) @@ -673,9 +777,12 @@ async def test_update_keylist_for_connection(self): ) mock_route_manager.mediation_record_for_connection = mock.CoroutineMock() self.context.injector.bind_instance(RouteManager, mock_route_manager) - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object(test_module.web, "json_response") as json_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object(test_module.web, "json_response") as json_response, + ): await test_module.update_keylist_for_connection(self.request) json_response.assert_called_once_with({"mock": "serialized"}, status=200) diff --git a/acapy_agent/protocols/did_rotate/v1_0/tests/test_manager.py b/acapy_agent/protocols/did_rotate/v1_0/tests/test_manager.py index b4bc7cd6d5..cf72da930e 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/did_rotate/v1_0/tests/test_manager.py @@ -92,9 +92,12 @@ async def test_receive_rotate_x(self): RotateProblemReport(problem_items=[{"did": test_to_did}]) ) - with mock.patch.object( - self.manager, "_ensure_supported_did", side_effect=test_problem_report - ), mock.patch.object(self.responder, "send", mock.CoroutineMock()) as mock_send: + with ( + mock.patch.object( + self.manager, "_ensure_supported_did", side_effect=test_problem_report + ), + mock.patch.object(self.responder, "send", mock.CoroutineMock()) as mock_send, + ): await self.manager.receive_rotate( mock_conn_record, Rotate(to_did=test_to_did) ) diff --git a/acapy_agent/protocols/didexchange/v1_0/tests/test_manager.py b/acapy_agent/protocols/didexchange/v1_0/tests/test_manager.py index 57c8752e23..5dae863727 100644 --- a/acapy_agent/protocols/didexchange/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/didexchange/v1_0/tests/test_manager.py @@ -174,13 +174,15 @@ async def test_receive_invitation(self): ) await mediation_record.save(session) - with mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - self.multitenant_mgr, "get_default_mediator" - ) as mock_get_default_mediator, mock.patch.object( - AdminResponder, "send_reply" - ) as mock_send_reply: + with ( + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object( + self.multitenant_mgr, "get_default_mediator" + ) as mock_get_default_mediator, + mock.patch.object(AdminResponder, "send_reply") as mock_send_reply, + ): mock_get_default_mediator.return_value = mediation_record invi_rec = await self.oob_manager.create_invitation( my_endpoint="testendpoint", @@ -206,15 +208,18 @@ async def test_receive_invitation_oob_public_did(self): ED25519, ) public_did_info = await wallet.get_public_did() - with mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - self.multitenant_mgr, "get_default_mediator" - ) as mock_get_default_mediator, mock.patch.object( - self.manager, "resolve_connection_targets", mock.CoroutineMock() - ) as mock_resolve_targets, mock.patch.object( - AdminResponder, "send_reply" - ) as mock_send_reply: + with ( + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object( + self.multitenant_mgr, "get_default_mediator" + ) as mock_get_default_mediator, + mock.patch.object( + self.manager, "resolve_connection_targets", mock.CoroutineMock() + ) as mock_resolve_targets, + mock.patch.object(AdminResponder, "send_reply") as mock_send_reply, + ): mock_resolve_targets.return_value = [ mock.MagicMock(recipient_keys=["test"]) ] @@ -289,11 +294,14 @@ async def test_create_request_implicit(self): ) await mediation_record.save(session) - with mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc, mock.patch.object( - self.multitenant_mgr, "get_default_mediator" - ) as mock_get_default_mediator: + with ( + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + mock.patch.object( + self.multitenant_mgr, "get_default_mediator" + ) as mock_get_default_mediator, + ): mock_get_default_mediator.return_value = mediation_record mock_create_did_doc.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={}) @@ -370,8 +378,11 @@ async def test_create_request_implicit_x_public_already_connected(self): SOV, ED25519, ) - with self.assertRaises(DIDXManagerError) as context, mock.patch.object( - test_module.ConnRecord, "retrieve_by_did", mock.CoroutineMock() + with ( + self.assertRaises(DIDXManagerError) as context, + mock.patch.object( + test_module.ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ), ): await self.manager.create_request_implicit( their_public_did=TestConfig.test_target_did, @@ -414,13 +425,17 @@ async def test_create_request_multitenant(self): {"multitenant.enabled": True, "wallet.id": "test_wallet"} ) - with mock.patch.object( - AskarWallet, "create_local_did", autospec=True - ) as mock_wallet_create_local_did, mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco: + with ( + mock.patch.object( + AskarWallet, "create_local_did", autospec=True + ) as mock_wallet_create_local_did, + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + ): mock_create_did_doc.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={}) ) @@ -625,24 +640,35 @@ async def test_receive_request_explicit_public_did(self): STATE_REQUEST = ConnRecord.State.REQUEST self.profile.context.update_settings({"public_invites": True}) ACCEPT_AUTO = ConnRecord.ACCEPT_AUTO - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - test_module, "DIDXResponse", autospec=True - ) as mock_response, mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(return_value={"id": "did:sov:" + TestConfig.test_did}), - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc, mock.patch.object( - MediationManager, "prepare_request", autospec=True - ) as mock_mediation_mgr_prep_req, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object( + test_module, "DIDXResponse", autospec=True + ) as mock_response, + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock( + return_value={"id": "did:sov:" + TestConfig.test_did} + ), + ), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + mock.patch.object( + MediationManager, "prepare_request", autospec=True + ) as mock_mediation_mgr_prep_req, + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_create_did_doc.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={}) @@ -760,27 +786,36 @@ async def test_receive_request_public_did_no_did_doc_attachment(self): STATE_REQUEST = ConnRecord.State.REQUEST self.profile.context.update_settings({"public_invites": True}) ACCEPT_AUTO = ConnRecord.ACCEPT_AUTO - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - test_module, "DIDXResponse", autospec=True - ) as mock_response, mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(return_value=DIDDoc(TestConfig.test_did)), - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc, mock.patch.object( - self.manager, - "record_keys_for_resolvable_did", - mock.CoroutineMock(), - ), mock.patch.object( - MediationManager, "prepare_request", autospec=True - ) as mock_mediation_mgr_prep_req: + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object( + test_module, "DIDXResponse", autospec=True + ) as mock_response, + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock(return_value=DIDDoc(TestConfig.test_did)), + ), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + mock.patch.object( + self.manager, + "record_keys_for_resolvable_did", + mock.CoroutineMock(), + ), + mock.patch.object( + MediationManager, "prepare_request", autospec=True + ) as mock_mediation_mgr_prep_req, + ): mock_create_did_doc.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={}) ) @@ -856,11 +891,14 @@ async def test_receive_request_public_did_no_did_doc_attachment_no_did(self): STATE_REQUEST = ConnRecord.State.REQUEST self.profile.context.update_settings({"public_invites": True}) ACCEPT_AUTO = ConnRecord.ACCEPT_AUTO - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture: + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + ): mock_conn_record = mock.MagicMock( accept=ACCEPT_AUTO, my_did=None, @@ -964,16 +1002,21 @@ async def test_receive_request_public_did_x_wrong_did(self): self.profile.context.update_settings({"public_invites": True}) mock_conn_rec_state_request = ConnRecord.State.REQUEST - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture, mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(return_value={"id": "LjgpST2rjsoxYegQDRm7EL"}), - ), mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock(return_value={"id": "LjgpST2rjsoxYegQDRm7EL"}), + ), + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_conn_record = mock.MagicMock( accept=ConnRecord.ACCEPT_MANUAL, @@ -1028,14 +1071,18 @@ async def test_receive_request_public_did_x_did_doc_attach_bad_sig(self): self.profile.context.update_settings({"public_invites": True}) mock_conn_rec_state_request = ConnRecord.State.REQUEST - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture, mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(side_effect=DIDXManagerError), + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock(side_effect=DIDXManagerError), + ), ): mock_conn_record = mock.MagicMock( accept=ConnRecord.ACCEPT_MANUAL, @@ -1088,14 +1135,13 @@ async def test_receive_request_public_did_no_public_invites(self): ) self.profile.context.update_settings({"public_invites": False}) - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ), mock.patch.object( - test_module, "DIDXResponse", autospec=True - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() + with ( + mock.patch.object(test_module, "ConnRecord", mock.MagicMock()), + mock.patch.object(test_module, "AttachDecorator", autospec=True), + mock.patch.object(test_module, "DIDXResponse", autospec=True), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ), ): with self.assertRaises(DIDXManagerError) as context: await self.manager.receive_request( @@ -1133,22 +1179,28 @@ async def test_receive_request_public_did_no_auto_accept(self): {"public_invites": True, "debug.auto_accept_requests": False} ) mock_conn_rec_state_request = ConnRecord.State.REQUEST - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ), mock.patch.object( - test_module, "DIDXResponse", autospec=True - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ), mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(return_value={"id": "did:sov:" + TestConfig.test_did}), - ), mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + mock.patch.object(test_module, "AttachDecorator", autospec=True), + mock.patch.object(test_module, "DIDXResponse", autospec=True), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ), + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock( + return_value={"id": "did:sov:" + TestConfig.test_did} + ), + ), + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_conn_record = mock.MagicMock( accept=ConnRecord.ACCEPT_MANUAL, @@ -1213,16 +1265,23 @@ async def test_receive_request_implicit_public_did_not_enabled(self): self.profile.context.update_settings({"public_invites": True}) - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture, mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(return_value={"id": "did:sov:" + TestConfig.test_did}), - ), mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock( + return_value={"id": "did:sov:" + TestConfig.test_did} + ), + ), + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_did_posture.get = mock.MagicMock( return_value=test_module.DIDPosture.PUBLIC @@ -1279,16 +1338,23 @@ async def test_receive_request_implicit_public_did(self): ACCEPT_AUTO = ConnRecord.ACCEPT_AUTO STATE_REQUEST = ConnRecord.State.REQUEST - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "DIDPosture", autospec=True - ) as mock_did_posture, mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(return_value={"id": "did:sov:" + TestConfig.test_did}), - ), mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "DIDPosture", autospec=True + ) as mock_did_posture, + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock( + return_value={"id": "did:sov:" + TestConfig.test_did} + ), + ), + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_did_posture.get = mock.MagicMock( return_value=test_module.DIDPosture.PUBLIC @@ -1363,18 +1429,26 @@ async def test_receive_request_peer_did(self): ) self.profile.context.update_settings({"public_invites": True}) - with mock.patch.object( - test_module, "ConnRecord", mock.MagicMock() - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - test_module, "DIDXResponse", autospec=True - ) as mock_response, mock.patch.object( - self.manager, - "verify_diddoc", - mock.CoroutineMock(return_value={"id": "did:sov:" + TestConfig.test_did}), - ), mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "ConnRecord", mock.MagicMock() + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object( + test_module, "DIDXResponse", autospec=True + ) as mock_response, + mock.patch.object( + self.manager, + "verify_diddoc", + mock.CoroutineMock( + return_value={"id": "did:sov:" + TestConfig.test_did} + ), + ), + mock.patch.object( + self.manager, "store_did_document", mock.CoroutineMock() + ), ): mock_conn_rec_cls.retrieve_by_invitation_msg_id = mock.CoroutineMock( return_value=mock_conn @@ -1451,15 +1525,19 @@ async def test_receive_request_peer_did_not_found_x(self): async def test_create_response(self): conn_rec = ConnRecord(connection_id="dummy", state=ConnRecord.State.REQUEST.rfc23) - with mock.patch.object( - test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - test_module, "DIDXResponse", autospec=True - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() + ), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object(test_module, "DIDXResponse", autospec=True), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + ): mock_create_did_doc.return_value = mock.MagicMock(serialize=mock.MagicMock()) mock_attach_deco.data_base64 = mock.MagicMock( return_value=mock.MagicMock( @@ -1499,15 +1577,17 @@ async def test_create_response_mediation_id(self): await record.save(session) await record.attach_invitation(session, invi) - with mock.patch.object( - ConnRecord, "log_state", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - record, "metadata_get", mock.CoroutineMock(return_value=False) - ), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco: + with ( + mock.patch.object(ConnRecord, "log_state", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + record, "metadata_get", mock.CoroutineMock(return_value=False) + ), + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + ): mock_attach_deco.data_base64 = mock.MagicMock( return_value=mock.MagicMock( data=mock.MagicMock(sign=mock.CoroutineMock()) @@ -1548,12 +1628,13 @@ async def test_create_response_mediation_id_invalid_conn_state(self): await record.save(session) await record.attach_invitation(session, invi) - with mock.patch.object( - ConnRecord, "log_state", autospec=True - ), mock.patch.object( - ConnRecord, "retrieve_request", autospec=True - ), mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - record, "metadata_get", mock.CoroutineMock(return_value=False) + with ( + mock.patch.object(ConnRecord, "log_state", autospec=True), + mock.patch.object(ConnRecord, "retrieve_request", autospec=True), + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + record, "metadata_get", mock.CoroutineMock(return_value=False) + ), ): with self.assertRaises(DIDXManagerError) as context: await self.manager.create_response( @@ -1571,15 +1652,19 @@ async def test_create_response_multitenant(self): } ) - with mock.patch.object( - test_module.ConnRecord, "retrieve_request" - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc, mock.patch.object( - AskarWallet, "create_local_did", autospec=True - ) as mock_wallet_create_local_did: + with ( + mock.patch.object(test_module.ConnRecord, "retrieve_request"), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + mock.patch.object( + AskarWallet, "create_local_did", autospec=True + ) as mock_wallet_create_local_did, + ): mock_wallet_create_local_did.return_value = DIDInfo( TestConfig.test_did, TestConfig.test_verkey, @@ -1604,17 +1689,22 @@ async def test_create_response_conn_rec_my_did(self): state=ConnRecord.State.REQUEST.rfc23, ) - with mock.patch.object( - test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - test_module, "DIDXResponse", autospec=True - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc, mock.patch.object( - AskarWallet, "get_local_did", mock.CoroutineMock() - ) as mock_get_loc_did: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() + ), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object(test_module, "DIDXResponse", autospec=True), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + mock.patch.object( + AskarWallet, "get_local_did", mock.CoroutineMock() + ) as mock_get_loc_did, + ): mock_get_loc_did.return_value = self.did_info mock_create_did_doc.return_value = mock.MagicMock(serialize=mock.MagicMock()) mock_attach_deco.data_base64 = mock.MagicMock( @@ -1635,11 +1725,15 @@ async def test_create_response_inkind_peer_did_2(self): self.profile.context.update_settings({"emit_did_peer_2": False}) - with mock.patch.object( - self.manager, "create_did_peer_2", mock.CoroutineMock() - ) as mock_create_did_peer_2, mock.patch.object( - test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()): + with ( + mock.patch.object( + self.manager, "create_did_peer_2", mock.CoroutineMock() + ) as mock_create_did_peer_2, + mock.patch.object( + test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() + ), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + ): mock_create_did_peer_2.return_value = DIDInfo( TestConfig.test_did_peer_2, TestConfig.test_verkey, @@ -1663,11 +1757,15 @@ async def test_create_response_inkind_peer_did_4(self): self.profile.context.update_settings({"emit_did_peer_4": False}) - with mock.patch.object( - self.manager, "create_did_peer_4", mock.CoroutineMock() - ) as mock_create_did_peer_4, mock.patch.object( - test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()): + with ( + mock.patch.object( + self.manager, "create_did_peer_4", mock.CoroutineMock() + ) as mock_create_did_peer_4, + mock.patch.object( + test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() + ), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + ): mock_create_did_peer_4.return_value = DIDInfo( TestConfig.test_did_peer_4, TestConfig.test_verkey, @@ -1691,11 +1789,15 @@ async def test_create_response_peer_1_gets_peer_4(self): self.profile.context.update_settings({"emit_did_peer_4": False}) - with mock.patch.object( - self.manager, "create_did_peer_4", mock.CoroutineMock() - ) as mock_create_did_peer_4, mock.patch.object( - test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()): + with ( + mock.patch.object( + self.manager, "create_did_peer_4", mock.CoroutineMock() + ) as mock_create_did_peer_4, + mock.patch.object( + test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() + ), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + ): mock_create_did_peer_4.return_value = DIDInfo( TestConfig.test_did_peer_4, TestConfig.test_verkey, @@ -1731,15 +1833,19 @@ async def test_create_response_use_public_did(self): conn_rec = ConnRecord(connection_id="dummy", state=ConnRecord.State.REQUEST.rfc23) - with mock.patch.object( - test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - test_module, "DIDXResponse", autospec=True - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() + ), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object(test_module, "DIDXResponse", autospec=True), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + ): mock_create_did_doc.return_value = mock.MagicMock(serialize=mock.MagicMock()) mock_attach_deco.data_base64 = mock.MagicMock( return_value=mock.MagicMock( @@ -1754,15 +1860,19 @@ async def test_create_response_use_public_did(self): async def test_create_response_use_public_did_x_no_public_did(self): conn_rec = ConnRecord(connection_id="dummy", state=ConnRecord.State.REQUEST.rfc23) - with mock.patch.object( - test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() - ), mock.patch.object(conn_rec, "save", mock.CoroutineMock()), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_deco, mock.patch.object( - test_module, "DIDXResponse", autospec=True - ), mock.patch.object( - self.manager, "create_did_document", mock.CoroutineMock() - ) as mock_create_did_doc: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_request", mock.CoroutineMock() + ), + mock.patch.object(conn_rec, "save", mock.CoroutineMock()), + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_deco, + mock.patch.object(test_module, "DIDXResponse", autospec=True), + mock.patch.object( + self.manager, "create_did_document", mock.CoroutineMock() + ) as mock_create_did_doc, + ): mock_create_did_doc.return_value = mock.MagicMock(serialize=mock.MagicMock()) mock_attach_deco.data_base64 = mock.MagicMock( return_value=mock.MagicMock( @@ -1798,12 +1908,15 @@ async def test_accept_response_find_by_thread_id(self): recipient_did_public=True, ) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_id, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_id, + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=TestConfig.test_target_did, @@ -1856,14 +1969,18 @@ async def test_accept_response_find_by_thread_id_auto_disclose_features(self): ) self.context.update_settings({"auto_disclose_features": True}) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_id, mock.patch.object( - V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() - ) as mock_proactive_disclose_features, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_id, + mock.patch.object( + V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() + ) as mock_proactive_disclose_features, + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=TestConfig.test_target_did, @@ -1912,12 +2029,15 @@ async def test_accept_response_not_found_by_thread_id_receipt_has_sender_did(sel receipt = MessageReceipt(sender_did=TestConfig.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_did", mock.CoroutineMock() - ) as mock_conn_retrieve_by_did, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ) as mock_conn_retrieve_by_did, + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), ): mock_conn_retrieve_by_req_id.side_effect = StorageNotFoundError() mock_conn_retrieve_by_did.return_value = mock.MagicMock( @@ -1958,11 +2078,15 @@ async def test_accept_response_not_found_by_thread_id_nor_receipt_sender_did(sel receipt = MessageReceipt(sender_did=TestConfig.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_did", mock.CoroutineMock() - ) as mock_conn_retrieve_by_did: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_did", mock.CoroutineMock() + ) as mock_conn_retrieve_by_did, + ): mock_conn_retrieve_by_req_id.side_effect = StorageNotFoundError() mock_conn_retrieve_by_did.side_effect = StorageNotFoundError() @@ -1984,9 +2108,12 @@ async def test_accept_response_find_by_thread_id_bad_state(self): receipt = MessageReceipt(sender_did=TestConfig.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id: + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( state=ConnRecord.State.ABANDONED.rfc23 ) @@ -2007,14 +2134,20 @@ async def test_accept_response_find_by_thread_id_no_did_doc_attached(self): recipient_did_public=True, ) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_id, mock.patch.object( - DIDDoc, "deserialize", mock.MagicMock() - ) as mock_did_doc_deser, mock.patch.object( - self.manager, "record_keys_for_resolvable_did", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_id, + mock.patch.object( + DIDDoc, "deserialize", mock.MagicMock() + ) as mock_did_doc_deser, + mock.patch.object( + self.manager, "record_keys_for_resolvable_did", mock.CoroutineMock() + ), ): mock_did_doc_deser.return_value = mock.MagicMock( did=TestConfig.test_target_did @@ -2047,14 +2180,20 @@ async def test_accept_response_find_by_thread_id_no_did_doc_attached_no_did(self recipient_did_public=True, ) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_id, mock.patch.object( - DIDDoc, "deserialize", mock.MagicMock() - ) as mock_did_doc_deser, mock.patch.object( - self.manager, "record_keys_for_resolvable_did", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_id, + mock.patch.object( + DIDDoc, "deserialize", mock.MagicMock() + ) as mock_did_doc_deser, + mock.patch.object( + self.manager, "record_keys_for_resolvable_did", mock.CoroutineMock() + ), ): mock_did_doc_deser.return_value = mock.MagicMock( did=TestConfig.test_target_did @@ -2092,12 +2231,15 @@ async def test_accept_response_find_by_thread_id_did_mismatch(self): receipt = MessageReceipt(sender_did=TestConfig.test_target_did) - with mock.patch.object(ConnRecord, "save", autospec=True), mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_id, mock.patch.object( - self.manager, "store_did_document", mock.CoroutineMock() + with ( + mock.patch.object(ConnRecord, "save", autospec=True), + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_id, + mock.patch.object(self.manager, "store_did_document", mock.CoroutineMock()), ): mock_conn_retrieve_by_req_id.return_value = mock.MagicMock( did=TestConfig.test_target_did, @@ -2139,11 +2281,14 @@ async def test_accept_complete_with_disclose(self): mock_complete = mock.MagicMock() receipt = MessageReceipt(sender_did=TestConfig.test_target_did) self.context.update_settings({"auto_disclose_features": True}) - with mock.patch.object( - ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_req_id, mock.patch.object( - V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() - ) as mock_proactive_disclose_features: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_request_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_req_id, + mock.patch.object( + V20DiscoveryMgr, "proactive_disclose_features", mock.CoroutineMock() + ) as mock_proactive_disclose_features, + ): mock_conn_retrieve_by_req_id.return_value.save = mock.CoroutineMock() mock_conn_retrieve_by_req_id.return_value.my_did = None mock_conn_retrieve_by_req_id.return_value.their_did = None diff --git a/acapy_agent/protocols/didexchange/v1_0/tests/test_routes.py b/acapy_agent/protocols/didexchange/v1_0/tests/test_routes.py index 20b0eace36..81be5fda3d 100644 --- a/acapy_agent/protocols/didexchange/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/didexchange/v1_0/tests/test_routes.py @@ -43,13 +43,13 @@ async def test_didx_accept_invitation(self): mock_conn_rec = mock.MagicMock(save=mock.CoroutineMock()) mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_class, mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_class, + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_class.retrieve_by_id.return_value = mock_conn_rec mock_didx_mgr.return_value.create_request = mock.CoroutineMock() @@ -70,9 +70,12 @@ async def test_didx_accept_invitation_not_found(self): async def test_didx_accept_invitation_x(self): self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + ): mock_didx_mgr.return_value.create_request = mock.CoroutineMock( side_effect=test_module.DIDXManagerError() ) @@ -88,11 +91,10 @@ async def test_didx_create_request_implicit(self): "mediator_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", } - with mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_didx_mgr.return_value.create_request_implicit = mock.CoroutineMock( return_value=mock.MagicMock( serialize=mock.MagicMock(return_value="mock serialization") @@ -111,9 +113,10 @@ async def test_didx_create_request_implicit_not_found_x(self): "auto_accept": "true", } - with mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_didx_mgr.return_value.create_request_implicit = mock.CoroutineMock( side_effect=StorageNotFoundError("not found") ) @@ -130,9 +133,10 @@ async def test_didx_create_request_implicit_wallet_x(self): "auto_accept": "true", } - with mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_didx_mgr.return_value.create_request_implicit = mock.CoroutineMock( side_effect=test_module.WalletError("wallet error") ) @@ -152,13 +156,11 @@ async def test_didx_receive_request_implicit(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module.DIDXRequest, "deserialize", mock.MagicMock() - ), mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module.DIDXRequest, "deserialize", mock.MagicMock()), + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_didx_mgr.return_value.receive_request = mock.CoroutineMock( return_value=mock_conn_rec ) @@ -174,11 +176,11 @@ async def test_didx_receive_request_implicit_not_found_x(self): self.request._thread.pthid = "did:sov:0000000000000000000000" self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module.DIDXRequest, "deserialize", mock.MagicMock() - ), mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module.DIDXRequest, "deserialize", mock.MagicMock()), + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_didx_mgr.return_value.receive_request = mock.CoroutineMock( side_effect=StorageNotFoundError("tricorder must be broken") ) @@ -195,11 +197,13 @@ async def test_didx_receive_request_implicit_bad_request_x(self): self.request._thread.pthid = "did:sov:0000000000000000000000" self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module.DIDXRequest, "deserialize", mock.MagicMock() - ) as mock_didx_req_deser, mock.patch.object( - test_module, "DIDXManager", autospec=True - ), mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.DIDXRequest, "deserialize", mock.MagicMock() + ) as mock_didx_req_deser, + mock.patch.object(test_module, "DIDXManager", autospec=True), + mock.patch.object(test_module.web, "json_response"), + ): mock_didx_req_deser.side_effect = test_module.BaseModelError("bad bits") with self.assertRaises(test_module.web.HTTPBadRequest) as context: await test_module.didx_receive_request_implicit(self.request) @@ -214,13 +218,13 @@ async def test_didx_accept_request(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve_by_id, mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve_by_id, + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_didx_mgr.return_value.create_response = mock.CoroutineMock() @@ -241,11 +245,13 @@ async def test_didx_accept_request_not_found(self): async def test_didx_accept_request_x(self): self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_didx_mgr.return_value.create_response = mock.CoroutineMock( side_effect=test_module.DIDXManagerError() ) @@ -257,11 +263,13 @@ async def test_didx_reject(self): self.request.match_info = {"conn_id": "dummy"} self.request.json = mock.CoroutineMock(return_value={"reason": "asdf"}) - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_didx_mgr.return_value.reject = mock.CoroutineMock() await test_module.didx_reject(self.request) @@ -282,11 +290,13 @@ async def test_didx_reject_x_bad_conn_state(self): self.request.match_info = {"conn_id": "dummy"} self.request.json = mock.CoroutineMock(return_value={"reason": "asdf"}) - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ), mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as mock_didx_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ), + mock.patch.object(test_module, "DIDXManager", autospec=True) as mock_didx_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_didx_mgr.return_value.reject = mock.CoroutineMock( side_effect=test_module.DIDXManagerError() ) diff --git a/acapy_agent/protocols/discovery/v1_0/handlers/tests/test_query_handler.py b/acapy_agent/protocols/discovery/v1_0/handlers/tests/test_query_handler.py index efb99110cb..9e428c958a 100644 --- a/acapy_agent/protocols/discovery/v1_0/handlers/tests/test_query_handler.py +++ b/acapy_agent/protocols/discovery/v1_0/handlers/tests/test_query_handler.py @@ -69,11 +69,14 @@ async def test_receive_query_process_disclosed(self, request_context): request_context.connection_ready = True handler = QueryHandler() responder = MockResponder() - with mock.patch.object( - ProtocolRegistry, "protocols_matching_query", mock.MagicMock() - ), mock.patch.object( - ProtocolRegistry, "prepare_disclosed", mock.CoroutineMock() - ) as mock_prepare_disclosed: + with ( + mock.patch.object( + ProtocolRegistry, "protocols_matching_query", mock.MagicMock() + ), + mock.patch.object( + ProtocolRegistry, "prepare_disclosed", mock.CoroutineMock() + ) as mock_prepare_disclosed, + ): mock_prepare_disclosed.return_value = [ {"test": "test"}, { diff --git a/acapy_agent/protocols/discovery/v1_0/tests/test_manager.py b/acapy_agent/protocols/discovery/v1_0/tests/test_manager.py index 88ccfcecde..134b7a736b 100644 --- a/acapy_agent/protocols/discovery/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/discovery/v1_0/tests/test_manager.py @@ -43,11 +43,14 @@ async def asyncSetUp(self): async def test_receive_disclosure(self): test_conn_id = "test123" self.disclose.assign_thread_id("test123") - with mock.patch.object( - V10DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve: + with ( + mock.patch.object( + V10DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + ): mock_retrieve.return_value = TEST_DISCOVERY_EX_REC ex_rec = await self.manager.receive_disclose( disclose_msg=self.disclose, connection_id=test_conn_id @@ -62,19 +65,24 @@ async def test_receive_disclosure(self): async def test_receive_disclosure_retrieve_by_conn(self): test_conn_id = "test123" self.disclose.assign_thread_id("test123") - with mock.patch.object( - V10DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V10DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V10DiscoveryExchangeRecord, - "retrieve_by_connection_id", - mock.CoroutineMock(), - ) as mock_retrieve_by_connection_id, mock.patch.object( - V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve_by_id: + with ( + mock.patch.object( + V10DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V10DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V10DiscoveryExchangeRecord, + "retrieve_by_connection_id", + mock.CoroutineMock(), + ) as mock_retrieve_by_connection_id, + mock.patch.object( + V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve_by_id, + ): mock_retrieve_by_id.side_effect = StorageNotFoundError mock_exists_for_connection_id.return_value = True mock_retrieve_by_connection_id.return_value = TEST_DISCOVERY_EX_REC @@ -91,15 +99,19 @@ async def test_receive_disclosure_retrieve_by_conn(self): async def test_receive_disclosure_retrieve_by_conn_not_found(self): test_conn_id = "test123" self.disclose.assign_thread_id("test123") - with mock.patch.object( - V10DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V10DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve_by_id: + with ( + mock.patch.object( + V10DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V10DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve_by_id, + ): mock_retrieve_by_id.side_effect = StorageNotFoundError mock_exists_for_connection_id.return_value = False ex_rec = await self.manager.receive_disclose( @@ -114,15 +126,19 @@ async def test_receive_disclosure_retrieve_by_conn_not_found(self): async def test_receive_disclosure_retrieve_new_ex_rec(self): test_conn_id = "test123" - with mock.patch.object( - V10DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V10DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve_by_id: + with ( + mock.patch.object( + V10DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V10DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V10DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve_by_id, + ): mock_retrieve_by_id.side_effect = StorageNotFoundError mock_exists_for_connection_id.return_value = False ex_rec = await self.manager.receive_disclose( @@ -148,23 +164,27 @@ async def test_check_if_disclosure_received(self): async def test_create_and_send_query_with_connection(self): return_ex_rec = V10DiscoveryExchangeRecord(query_msg=Query(query="*")) - with mock.patch.object( - V10DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V10DiscoveryExchangeRecord, - "retrieve_by_connection_id", - mock.CoroutineMock(), - ) as mock_retrieve_by_connection_id, mock.patch.object( - V10DiscoveryExchangeRecord, - "save", - mock.CoroutineMock(), - ), mock.patch.object( - V10DiscoveryMgr, "check_if_disclosure_received", mock.CoroutineMock() - ) as mock_disclosure_received, mock.patch.object( - self.responder, "send", mock.CoroutineMock() - ) as mock_send: + with ( + mock.patch.object( + V10DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V10DiscoveryExchangeRecord, + "retrieve_by_connection_id", + mock.CoroutineMock(), + ) as mock_retrieve_by_connection_id, + mock.patch.object( + V10DiscoveryExchangeRecord, + "save", + mock.CoroutineMock(), + ), + mock.patch.object( + V10DiscoveryMgr, "check_if_disclosure_received", mock.CoroutineMock() + ) as mock_disclosure_received, + mock.patch.object(self.responder, "send", mock.CoroutineMock()) as mock_send, + ): mock_exists_for_connection_id.return_value = True mock_retrieve_by_connection_id.return_value = V10DiscoveryExchangeRecord() mock_disclosure_received.return_value = return_ex_rec diff --git a/acapy_agent/protocols/discovery/v1_0/tests/test_routes.py b/acapy_agent/protocols/discovery/v1_0/tests/test_routes.py index d644c0bfce..3269bbafe2 100644 --- a/acapy_agent/protocols/discovery/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/discovery/v1_0/tests/test_routes.py @@ -40,11 +40,12 @@ async def test_query_features(self): discovery_exchange_id="3fa85f64-5717-4562-b3fc-2c963f66afa6", query_msg=Query(query="*"), ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - V10DiscoveryMgr, "create_and_send_query", autospec=True - ) as mock_create_query: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + V10DiscoveryMgr, "create_and_send_query", autospec=True + ) as mock_create_query, + ): mock_create_query.return_value = test_rec await test_module.query_features(self.request) mock_response.assert_called_once_with(test_rec.serialize()) @@ -59,11 +60,12 @@ async def test_query_features_with_connection(self): query_msg=Query(query="*"), ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - V10DiscoveryMgr, "create_and_send_query", autospec=True - ) as mock_create_query: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + V10DiscoveryMgr, "create_and_send_query", autospec=True + ) as mock_create_query, + ): mock_create_query.return_value = test_rec await test_module.query_features(self.request) mock_response.assert_called_once_with(test_rec.serialize()) @@ -78,11 +80,12 @@ async def test_query_records(self): query_msg=Query(query="*"), ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - test_module, "V10DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + test_module, "V10DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.retrieve_by_connection_id.return_value = test_rec await test_module.query_records(self.request) mock_response.assert_called_once_with({"results": [test_rec.serialize()]}) @@ -92,9 +95,12 @@ async def test_query_records_x(self): self.request.query = {"connection_id": "test"} - with mock.patch.object(test_module.web, "json_response"), mock.patch.object( - test_module, "V10DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response"), + mock.patch.object( + test_module, "V10DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.retrieve_by_connection_id.side_effect = StorageError with self.assertRaises(test_module.web.HTTPBadRequest): await test_module.query_records(self.request) @@ -113,11 +119,12 @@ async def test_query_records_all(self): ), ] - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - test_module, "V10DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + test_module, "V10DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.query.return_value = test_recs await test_module.query_records(self.request) mock_response.assert_called_once_with( @@ -127,9 +134,12 @@ async def test_query_records_all(self): async def test_query_records_connection_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object(test_module.web, "json_response"), mock.patch.object( - test_module, "V10DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response"), + mock.patch.object( + test_module, "V10DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.query.side_effect = StorageError with self.assertRaises(test_module.web.HTTPBadRequest): await test_module.query_records(self.request) diff --git a/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_disclosures_handler.py b/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_disclosures_handler.py index 0405014557..11bf227dae 100644 --- a/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_disclosures_handler.py +++ b/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_disclosures_handler.py @@ -94,14 +94,17 @@ async def test_disclosures_connection_id_no_thid(self, request_context): handler = DisclosuresHandler() mock_responder = MockResponder() - with mock.patch.object( - V20DiscoveryExchangeRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=StorageNotFoundError), - ), mock.patch.object( - V20DiscoveryExchangeRecord, - "retrieve_by_connection_id", - mock.CoroutineMock(return_value=discovery_record), + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=StorageNotFoundError), + ), + mock.patch.object( + V20DiscoveryExchangeRecord, + "retrieve_by_connection_id", + mock.CoroutineMock(return_value=discovery_record), + ), ): await handler.handle(request_context, mock_responder) assert not mock_responder.messages @@ -127,14 +130,17 @@ async def test_disclosures_no_conn_id_no_thid(self, request_context): handler = DisclosuresHandler() mock_responder = MockResponder() - with mock.patch.object( - V20DiscoveryExchangeRecord, - "retrieve_by_id", - mock.CoroutineMock(side_effect=StorageNotFoundError), - ), mock.patch.object( - V20DiscoveryExchangeRecord, - "retrieve_by_connection_id", - mock.CoroutineMock(side_effect=StorageNotFoundError), + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, + "retrieve_by_id", + mock.CoroutineMock(side_effect=StorageNotFoundError), + ), + mock.patch.object( + V20DiscoveryExchangeRecord, + "retrieve_by_connection_id", + mock.CoroutineMock(side_effect=StorageNotFoundError), + ), ): await handler.handle(request_context, mock_responder) assert not mock_responder.messages diff --git a/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_queries_handler.py b/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_queries_handler.py index adf63001da..b988702070 100644 --- a/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_queries_handler.py +++ b/acapy_agent/protocols/discovery/v2_0/handlers/tests/test_queries_handler.py @@ -134,11 +134,14 @@ async def test_receive_query_process_disclosed(self, request_context): request_context.connection_ready = True handler = QueriesHandler() responder = MockResponder() - with mock.patch.object( - V20DiscoveryMgr, "execute_protocol_query", mock.CoroutineMock() - ) as mock_exec_protocol_query, mock.patch.object( - V20DiscoveryMgr, "execute_goal_code_query", mock.CoroutineMock() - ) as mock_goal_code_protocol_query: + with ( + mock.patch.object( + V20DiscoveryMgr, "execute_protocol_query", mock.CoroutineMock() + ) as mock_exec_protocol_query, + mock.patch.object( + V20DiscoveryMgr, "execute_goal_code_query", mock.CoroutineMock() + ) as mock_goal_code_protocol_query, + ): mock_exec_protocol_query.return_value = [ {"test": "test"}, { diff --git a/acapy_agent/protocols/discovery/v2_0/tests/test_manager.py b/acapy_agent/protocols/discovery/v2_0/tests/test_manager.py index 3778d0784e..0473161c73 100644 --- a/acapy_agent/protocols/discovery/v2_0/tests/test_manager.py +++ b/acapy_agent/protocols/discovery/v2_0/tests/test_manager.py @@ -52,11 +52,14 @@ async def asyncSetUp(self): async def test_receive_disclosure(self): test_conn_id = "test123" self.queries.assign_thread_id("test123") - with mock.patch.object( - V20DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve: + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V20DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + ): mock_retrieve.return_value = TEST_DISCOVERY_EX_REC ex_rec = await self.manager.receive_disclose( disclose_msg=self.disclosures, connection_id=test_conn_id @@ -71,19 +74,24 @@ async def test_receive_disclosure(self): async def test_receive_disclosure_retrieve_by_conn(self): test_conn_id = "test123" self.queries.assign_thread_id("test123") - with mock.patch.object( - V20DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V20DiscoveryExchangeRecord, - "retrieve_by_connection_id", - mock.CoroutineMock(), - ) as mock_retrieve_by_connection_id, mock.patch.object( - V20DiscoveryExchangeRecord, "retrieve_by_id", autospec=True - ) as mock_retrieve_by_id: + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V20DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V20DiscoveryExchangeRecord, + "retrieve_by_connection_id", + mock.CoroutineMock(), + ) as mock_retrieve_by_connection_id, + mock.patch.object( + V20DiscoveryExchangeRecord, "retrieve_by_id", autospec=True + ) as mock_retrieve_by_id, + ): mock_retrieve_by_id.side_effect = StorageNotFoundError mock_exists_for_connection_id.return_value = True mock_retrieve_by_connection_id.return_value = TEST_DISCOVERY_EX_REC @@ -100,15 +108,19 @@ async def test_receive_disclosure_retrieve_by_conn(self): async def test_receive_disclosure_retrieve_by_conn_not_found(self): test_conn_id = "test123" self.queries.assign_thread_id("test123") - with mock.patch.object( - V20DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V20DiscoveryExchangeRecord, "retrieve_by_id", autospec=True - ) as mock_retrieve_by_id: + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V20DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V20DiscoveryExchangeRecord, "retrieve_by_id", autospec=True + ) as mock_retrieve_by_id, + ): mock_retrieve_by_id.side_effect = StorageNotFoundError mock_exists_for_connection_id.return_value = False ex_rec = await self.manager.receive_disclose( @@ -123,15 +135,19 @@ async def test_receive_disclosure_retrieve_by_conn_not_found(self): async def test_receive_disclosure_retrieve_new_ex_rec(self): test_conn_id = "test123" - with mock.patch.object( - V20DiscoveryExchangeRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V20DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve_by_id: + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, "save", autospec=True + ) as save_ex, + mock.patch.object( + V20DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V20DiscoveryExchangeRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve_by_id, + ): mock_retrieve_by_id.side_effect = StorageNotFoundError mock_exists_for_connection_id.return_value = False ex_rec = await self.manager.receive_disclose( @@ -144,25 +160,27 @@ async def test_receive_disclosure_retrieve_new_ex_rec(self): ) async def test_proactive_disclosure(self): - with mock.patch.object( - V20DiscoveryMgr, - "receive_query", - mock.CoroutineMock(), - ) as mock_receive_query, mock.patch.object( - self.responder, "send", mock.CoroutineMock() - ) as mock_send: + with ( + mock.patch.object( + V20DiscoveryMgr, + "receive_query", + mock.CoroutineMock(), + ) as mock_receive_query, + mock.patch.object(self.responder, "send", mock.CoroutineMock()) as mock_send, + ): mock_receive_query.return_value = Disclosures() await self.manager.proactive_disclose_features("test123") mock_send.assert_called_once() async def test_proactive_disclosure_no_responder(self): self.profile.context.injector.clear_binding(BaseResponder) - with mock.patch.object( - V20DiscoveryMgr, - "receive_query", - mock.CoroutineMock(), - ) as mock_receive_query, mock.patch.object( - self.responder, "send", mock.CoroutineMock() + with ( + mock.patch.object( + V20DiscoveryMgr, + "receive_query", + mock.CoroutineMock(), + ) as mock_receive_query, + mock.patch.object(self.responder, "send", mock.CoroutineMock()), ): self._caplog.set_level(logging.WARNING) mock_receive_query.return_value = Disclosures() @@ -195,23 +213,27 @@ async def test_create_and_send_query_with_connection(self): ] ) ) - with mock.patch.object( - V20DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V20DiscoveryExchangeRecord, - "retrieve_by_connection_id", - mock.CoroutineMock(), - ) as mock_retrieve_by_connection_id, mock.patch.object( - V20DiscoveryExchangeRecord, - "save", - mock.CoroutineMock(), - ), mock.patch.object( - V20DiscoveryMgr, "check_if_disclosure_received", mock.CoroutineMock() - ) as mock_disclosure_received, mock.patch.object( - self.responder, "send", mock.CoroutineMock() - ) as mock_send: + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V20DiscoveryExchangeRecord, + "retrieve_by_connection_id", + mock.CoroutineMock(), + ) as mock_retrieve_by_connection_id, + mock.patch.object( + V20DiscoveryExchangeRecord, + "save", + mock.CoroutineMock(), + ), + mock.patch.object( + V20DiscoveryMgr, "check_if_disclosure_received", mock.CoroutineMock() + ) as mock_disclosure_received, + mock.patch.object(self.responder, "send", mock.CoroutineMock()) as mock_send, + ): mock_exists_for_connection_id.return_value = True mock_retrieve_by_connection_id.return_value = V20DiscoveryExchangeRecord() mock_disclosure_received.return_value = return_ex_rec @@ -223,17 +245,21 @@ async def test_create_and_send_query_with_connection(self): async def test_create_and_send_query_with_connection_no_responder(self): self.profile.context.injector.clear_binding(BaseResponder) - with mock.patch.object( - V20DiscoveryExchangeRecord, - "exists_for_connection_id", - mock.CoroutineMock(), - ) as mock_exists_for_connection_id, mock.patch.object( - V20DiscoveryExchangeRecord, - "save", - mock.CoroutineMock(), - ), mock.patch.object( - V20DiscoveryMgr, "check_if_disclosure_received", mock.CoroutineMock() - ) as mock_disclosure_received: + with ( + mock.patch.object( + V20DiscoveryExchangeRecord, + "exists_for_connection_id", + mock.CoroutineMock(), + ) as mock_exists_for_connection_id, + mock.patch.object( + V20DiscoveryExchangeRecord, + "save", + mock.CoroutineMock(), + ), + mock.patch.object( + V20DiscoveryMgr, "check_if_disclosure_received", mock.CoroutineMock() + ) as mock_disclosure_received, + ): self._caplog.set_level(logging.WARNING) mock_exists_for_connection_id.return_value = False mock_disclosure_received.side_effect = asyncio.TimeoutError diff --git a/acapy_agent/protocols/discovery/v2_0/tests/test_routes.py b/acapy_agent/protocols/discovery/v2_0/tests/test_routes.py index 464916b963..dc06abcb00 100644 --- a/acapy_agent/protocols/discovery/v2_0/tests/test_routes.py +++ b/acapy_agent/protocols/discovery/v2_0/tests/test_routes.py @@ -46,11 +46,12 @@ async def test_query_features(self): ), ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - V20DiscoveryMgr, "create_and_send_query", autospec=True - ) as mock_create_query: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + V20DiscoveryMgr, "create_and_send_query", autospec=True + ) as mock_create_query, + ): mock_create_query.return_value = test_rec await test_module.query_features(self.request) mock_response.assert_called_once_with(test_rec.serialize()) @@ -74,11 +75,12 @@ async def test_query_features_with_connection(self): ), ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - V20DiscoveryMgr, "create_and_send_query", autospec=True - ) as mock_create_query: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + V20DiscoveryMgr, "create_and_send_query", autospec=True + ) as mock_create_query, + ): mock_create_query.return_value = test_rec await test_module.query_features(self.request) mock_response.assert_called_once_with(test_rec.serialize()) @@ -98,11 +100,12 @@ async def test_query_records(self): ), ) - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - test_module, "V20DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + test_module, "V20DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.retrieve_by_connection_id.return_value = test_rec await test_module.query_records(self.request) mock_response.assert_called_once_with({"results": [test_rec.serialize()]}) @@ -112,9 +115,12 @@ async def test_query_records_x(self): self.request.query = {"connection_id": "test"} - with mock.patch.object(test_module.web, "json_response"), mock.patch.object( - test_module, "V20DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response"), + mock.patch.object( + test_module, "V20DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.retrieve_by_connection_id.side_effect = StorageError with self.assertRaises(test_module.web.HTTPBadRequest): await test_module.query_records(self.request) @@ -143,11 +149,12 @@ async def test_query_records_all(self): ), ] - with mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - test_module, "V20DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + test_module, "V20DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.query.return_value = test_recs await test_module.query_records(self.request) mock_response.assert_called_once_with( @@ -157,9 +164,12 @@ async def test_query_records_all(self): async def test_query_records_connection_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object(test_module.web, "json_response"), mock.patch.object( - test_module, "V20DiscoveryExchangeRecord", autospec=True - ) as mock_ex_rec: + with ( + mock.patch.object(test_module.web, "json_response"), + mock.patch.object( + test_module, "V20DiscoveryExchangeRecord", autospec=True + ) as mock_ex_rec, + ): mock_ex_rec.query.side_effect = StorageError with self.assertRaises(test_module.web.HTTPBadRequest): await test_module.query_records(self.request) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_manager.py b/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_manager.py index 6519e9b27e..d333948eda 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_manager.py @@ -476,11 +476,10 @@ async def test_complete_transaction(self): ) ) - with mock.patch.object( - TransactionRecord, "save", autospec=True - ) as save_record, mock.patch.object( - ConnRecord, "retrieve_by_id" - ) as mock_conn_rec_retrieve: + with ( + mock.patch.object(TransactionRecord, "save", autospec=True) as save_record, + mock.patch.object(ConnRecord, "retrieve_by_id") as mock_conn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -534,11 +533,10 @@ async def test_complete_transaction_anoncreds( ) self.ledger.get_indy_storage = future - with mock.patch.object( - TransactionRecord, "save", autospec=True - ) as save_record, mock.patch.object( - ConnRecord, "retrieve_by_id" - ) as mock_conn_rec_retrieve: + with ( + mock.patch.object(TransactionRecord, "save", autospec=True) as save_record, + mock.patch.object(ConnRecord, "retrieve_by_id") as mock_conn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_routes.py b/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_routes.py index 66bf109838..65dd81e8c7 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/tests/test_routes.py @@ -62,11 +62,12 @@ async def asyncSetUp(self): self.test_did = "sample-did" async def test_transactions_list(self): - with mock.patch.object( - TransactionRecord, "query", mock.CoroutineMock() - ) as mock_query, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + TransactionRecord, "query", mock.CoroutineMock() + ) as mock_query, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_query.return_value = [ mock.MagicMock(serialize=mock.MagicMock(return_value={"...": "..."})) ] @@ -75,9 +76,12 @@ async def test_transactions_list(self): mock_response.assert_called_once_with({"results": [{"...": "..."}]}) async def test_transactions_list_x(self): - with mock.patch.object( - TransactionRecord, "query", mock.CoroutineMock() - ) as mock_query, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + TransactionRecord, "query", mock.CoroutineMock() + ) as mock_query, + mock.patch.object(test_module.web, "json_response"), + ): mock_query.side_effect = test_module.StorageError() with self.assertRaises(test_module.web.HTTPBadRequest): @@ -86,11 +90,12 @@ async def test_transactions_list_x(self): async def test_transactions_retrieve(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={"...": "..."}) ) @@ -129,15 +134,18 @@ async def test_transaction_create_request(self): "expires_time": "2021-03-29T05:22:19Z", } ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( create_request=mock.CoroutineMock( return_value=( @@ -193,11 +201,14 @@ async def test_transaction_create_request_base_model_x(self): "expires_time": "2021-03-29T05:22:19Z", } ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -224,13 +235,17 @@ async def test_transaction_create_request_no_jobs_x(self): "expires_time": "2021-03-29T05:22:19Z", } ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_request=mock.CoroutineMock( return_value=( @@ -260,13 +275,17 @@ async def test_transaction_create_request_no_my_job_x(self): "expires_time": "2021-03-29T05:22:19Z", } ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_request=mock.CoroutineMock( return_value=( @@ -302,13 +321,17 @@ async def test_transaction_create_request_no_their_job_x(self): "expires_time": "2021-03-29T05:22:19Z", } ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_request=mock.CoroutineMock( return_value=( @@ -344,11 +367,14 @@ async def test_transaction_create_request_my_wrong_job_x(self): "expires_time": "2021-03-29T05:22:19Z", } ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -375,13 +401,17 @@ async def test_transaction_create_request_mgr_create_request_x(self): "expires_time": "2021-03-29T05:22:19Z", } ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_request=mock.CoroutineMock( side_effect=test_module.TransactionManagerError() @@ -423,15 +453,18 @@ async def test_endorse_transaction_response(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( create_endorse_response=mock.CoroutineMock( return_value=( @@ -523,11 +556,14 @@ async def test_endorse_transaction_response_base_model_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.side_effect = test_module.BaseModelError() mock_txn_rec_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={"...": "..."}) @@ -554,11 +590,14 @@ async def test_endorse_transaction_response_no_jobs_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock(return_value=None) ) @@ -588,13 +627,17 @@ async def test_endorse_transaction_response_no_ledger_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_endorse_response=mock.CoroutineMock( return_value=( @@ -639,11 +682,14 @@ async def test_endorse_transaction_response_wrong_my_job_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -682,13 +728,17 @@ async def test_endorse_transaction_response_ledger_x(self): side_effect=test_module.LedgerError() ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( create_endorse_response=mock.CoroutineMock( return_value=( @@ -733,13 +783,18 @@ async def test_endorse_transaction_response_txn_mgr_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_txn_mgr.return_value = mock.MagicMock( create_endorse_response=mock.CoroutineMock( side_effect=test_module.TransactionManagerError() @@ -779,15 +834,18 @@ async def test_refuse_transaction_response(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( create_refuse_response=mock.CoroutineMock( return_value=( @@ -859,11 +917,14 @@ async def test_refuse_transaction_response_conn_base_model_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.side_effect = test_module.BaseModelError() mock_txn_rec_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={"...": "..."}) @@ -890,11 +951,14 @@ async def test_refuse_transaction_response_no_jobs_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock(return_value=None) ) @@ -923,11 +987,14 @@ async def test_refuse_transaction_response_wrong_my_job_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -962,13 +1029,18 @@ async def test_refuse_transaction_response_txn_mgr_x(self): ), ) - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_txn_mgr.return_value = mock.MagicMock( create_refuse_response=mock.CoroutineMock( side_effect=test_module.TransactionManagerError() @@ -993,15 +1065,18 @@ async def test_refuse_transaction_response_txn_mgr_x(self): async def test_cancel_transaction(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( cancel_transaction=mock.CoroutineMock( return_value=( @@ -1043,11 +1118,14 @@ async def test_cancel_transaction_not_found_x(self): async def test_cancel_transaction_conn_rec_base_model_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.side_effect = test_module.BaseModelError() mock_txn_rec_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={"...": "..."}) @@ -1059,11 +1137,14 @@ async def test_cancel_transaction_conn_rec_base_model_x(self): async def test_cancel_transaction_no_jobs_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock(return_value=None) ) @@ -1077,11 +1158,14 @@ async def test_cancel_transaction_no_jobs_x(self): async def test_cancel_transaction_wrong_my_job_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -1101,13 +1185,18 @@ async def test_cancel_transaction_wrong_my_job_x(self): async def test_cancel_transaction_txn_mgr_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_txn_mgr.return_value = mock.MagicMock( cancel_transaction=mock.CoroutineMock( side_effect=test_module.TransactionManagerError() @@ -1132,15 +1221,18 @@ async def test_cancel_transaction_txn_mgr_x(self): async def test_transaction_resend(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( transaction_resend=mock.CoroutineMock( return_value=( @@ -1182,11 +1274,14 @@ async def test_transaction_resend_not_found_x(self): async def test_transaction_resend_conn_rec_base_model_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.side_effect = test_module.BaseModelError() mock_txn_rec_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value={"...": "..."}) @@ -1198,11 +1293,14 @@ async def test_transaction_resend_conn_rec_base_model_x(self): async def test_transaction_resend_no_jobs_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock(return_value=None) ) @@ -1216,11 +1314,14 @@ async def test_transaction_resend_no_jobs_x(self): async def test_transaction_resend_my_wrong_job_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -1241,13 +1342,18 @@ async def test_transaction_resend_my_wrong_job_x(self): async def test_transaction_resend_txn_mgr_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_txn_mgr.return_value = mock.MagicMock( transaction_resend=mock.CoroutineMock( side_effect=test_module.TransactionManagerError() @@ -1272,13 +1378,15 @@ async def test_transaction_resend_txn_mgr_x(self): async def test_set_endorser_role(self): self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_txn_mgr.return_value = mock.MagicMock( set_transaction_my_job=mock.CoroutineMock() ) @@ -1322,11 +1430,12 @@ async def test_set_endorser_role_base_model_x(self): async def test_set_endorser_info(self): self.request.match_info = {"conn_id": "dummy"} self.request.query = {"endorser_did": "did", "endorser_name": "name"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( return_value={ @@ -1354,11 +1463,12 @@ async def test_set_endorser_info(self): async def test_set_endorser_info_no_prior_value(self): self.request.match_info = {"conn_id": "dummy"} self.request.query = {"endorser_did": "did", "endorser_name": "name"} - with mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_rec_retrieve, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_rec_retrieve, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_conn_rec_retrieve.return_value = mock.MagicMock( metadata_get=mock.CoroutineMock( side_effect=[ @@ -1466,13 +1576,15 @@ async def test_set_endorser_info_my_wrong_job_x(self): async def test_transaction_write_schema_txn(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_txn_mgr.return_value.complete_transaction = mock.CoroutineMock() mock_txn_mgr.return_value.complete_transaction.return_value = ( @@ -1526,11 +1638,14 @@ async def test_transaction_write_wrong_state_x(self): async def test_transaction_write_schema_txn_complete_x(self): self.request.match_info = {"tran_id": "dummy"} - with mock.patch.object( - TransactionRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_txn_rec_retrieve, mock.patch.object( - test_module, "TransactionManager", mock.MagicMock() - ) as mock_txn_mgr: + with ( + mock.patch.object( + TransactionRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_txn_rec_retrieve, + mock.patch.object( + test_module, "TransactionManager", mock.MagicMock() + ) as mock_txn_mgr, + ): mock_txn_mgr.return_value = mock.MagicMock( complete_transaction=mock.CoroutineMock( side_effect=test_module.StorageError() diff --git a/acapy_agent/protocols/introduction/v0_1/tests/test_routes.py b/acapy_agent/protocols/introduction/v0_1/tests/test_routes.py index 656b3db249..c8a0e94d52 100644 --- a/acapy_agent/protocols/introduction/v0_1/tests/test_routes.py +++ b/acapy_agent/protocols/introduction/v0_1/tests/test_routes.py @@ -70,11 +70,12 @@ async def test_introduction_start(self): mock_conn_rec = mock.MagicMock() mock_conn_rec.serialize = mock.MagicMock() - with mock.patch.object( - self.context, "inject_or", mock.MagicMock() - ) as mock_ctx_inject, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + self.context, "inject_or", mock.MagicMock() + ) as mock_ctx_inject, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_ctx_inject.return_value = mock.MagicMock( start_introduction=mock.CoroutineMock() ) diff --git a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_issue_handler.py b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_issue_handler.py index 32aa553b2e..43eeb5e1ff 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_issue_handler.py +++ b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_issue_handler.py @@ -117,11 +117,12 @@ async def test_called_auto_store_x(self): handler = test_module.CredentialIssueHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ), mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(responder, "send_reply", mock.CoroutineMock()), + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_offer_handler.py b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_offer_handler.py index 4b3982431d..c6fe03eafc 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_offer_handler.py +++ b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_offer_handler.py @@ -109,11 +109,12 @@ async def test_called_auto_request_x(self): handler = test_module.CredentialOfferHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ), mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(responder, "send_reply", mock.CoroutineMock()), + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_proposal_handler.py b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_proposal_handler.py index 94b0ee83e3..905b7c2e46 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_proposal_handler.py +++ b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_proposal_handler.py @@ -86,11 +86,12 @@ async def test_called_auto_offer_x(self): handler = test_module.CredentialProposalHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ), mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(responder, "send_reply", mock.CoroutineMock()), + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_request_handler.py b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_request_handler.py index 7050d754e6..740a3f759c 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_request_handler.py +++ b/acapy_agent/protocols/issue_credential/v1_0/handlers/tests/test_credential_request_handler.py @@ -128,10 +128,11 @@ async def test_called_auto_issue_x(self): }, ) - with mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - cred_ex_rec, "save_error_state", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(cred_ex_rec, "save_error_state", mock.CoroutineMock()), ): mock_cred_mgr.return_value.receive_request = mock.CoroutineMock( return_value=cred_ex_rec @@ -146,11 +147,12 @@ async def test_called_auto_issue_x(self): handler = test_module.CredentialRequestHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ), mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(responder, "send_reply", mock.CoroutineMock()), + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v1_0/models/tests/test_credential_exchange.py b/acapy_agent/protocols/issue_credential/v1_0/models/tests/test_credential_exchange.py index dabca65888..661504d4c2 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/models/tests/test_credential_exchange.py +++ b/acapy_agent/protocols/issue_credential/v1_0/models/tests/test_credential_exchange.py @@ -77,11 +77,12 @@ async def test_save_error_state(self): record.state = V10CredentialExchange.STATE_PROPOSAL_RECEIVED await record.save(session) - with mock.patch.object( - record, "save", mock.CoroutineMock() - ) as mock_save, mock.patch.object( - test_module.LOGGER, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(record, "save", mock.CoroutineMock()) as mock_save, + mock.patch.object( + test_module.LOGGER, "exception", mock.MagicMock() + ) as mock_log_exc, + ): mock_save.side_effect = test_module.StorageError() await record.save_error_state(session, reason="test") mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v1_0/tests/test_manager.py b/acapy_agent/protocols/issue_credential/v1_0/tests/test_manager.py index a8bed3b72b..af7a358fec 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/issue_credential/v1_0/tests/test_manager.py @@ -402,12 +402,12 @@ async def test_create_bound_offer(self): async with self.profile.session() as session: await stored_exchange.save(session) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10CredentialExchange, "get_cached_key", autospec=True - ) as get_cached_key, mock.patch.object( - V10CredentialExchange, "set_cached_key", autospec=True + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10CredentialExchange, "get_cached_key", autospec=True + ) as get_cached_key, + mock.patch.object(V10CredentialExchange, "set_cached_key", autospec=True), ): get_cached_key.return_value = None issuer = mock.MagicMock(IndyIssuer, autospec=True) @@ -473,12 +473,12 @@ async def test_create_bound_offer_no_cred_def(self): async with self.profile.session() as session: await stored_exchange.save(session) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ), mock.patch.object( - V10CredentialExchange, "get_cached_key", autospec=True - ) as get_cached_key, mock.patch.object( - V10CredentialExchange, "set_cached_key", autospec=True + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True), + mock.patch.object( + V10CredentialExchange, "get_cached_key", autospec=True + ) as get_cached_key, + mock.patch.object(V10CredentialExchange, "set_cached_key", autospec=True), ): get_cached_key.return_value = None issuer = mock.MagicMock() @@ -526,12 +526,13 @@ async def test_receive_offer_proposed(self): async with self.profile.session() as session: await stored_exchange.save(session) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ), mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(return_value=stored_exchange), + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True), + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(return_value=stored_exchange), + ), ): exchange = await self.manager.receive_offer(offer, connection_id) @@ -565,12 +566,13 @@ async def test_receive_free_offer(self): self.profile.context.connection_record = mock.MagicMock() self.profile.context.connection_record.connection_id = connection_id - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ), mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(side_effect=StorageNotFoundError), + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True), + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(side_effect=StorageNotFoundError), + ), ): exchange = await self.manager.receive_offer(offer, connection_id) @@ -752,13 +754,16 @@ async def test_receive_request(self): requests_attach=[CredentialRequest.wrap_indy_cred_req(INDY_CRED_REQ)] ) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(return_value=stored_exchange), - ) as retrieve_ex: + with ( + mock.patch.object( + V10CredentialExchange, "save", autospec=True + ) as save_ex, + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(return_value=stored_exchange), + ) as retrieve_ex, + ): exchange = await self.manager.receive_request(request, mock_conn, None) retrieve_ex.assert_called() @@ -787,13 +792,14 @@ async def test_receive_request_no_connection_cred_request(self): ) mock_oob = mock.MagicMock() - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as mock_save, mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(), - ) as mock_retrieve: + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True) as mock_save, + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(), + ) as mock_retrieve, + ): mock_retrieve.return_value = stored_exchange cx_rec = await self.manager.receive_request(request, mock_conn, mock_oob) @@ -822,13 +828,14 @@ async def test_receive_request_no_cred_ex_with_offer_found(self): connection_id="test_conn_id", ) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ), mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(), - ) as mock_retrieve: + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True), + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(), + ) as mock_retrieve, + ): mock_retrieve.side_effect = (StorageNotFoundError(),) with self.assertRaises(StorageNotFoundError): await self.manager.receive_request(request, mock_conn, None) @@ -870,11 +877,10 @@ async def test_issue_credential_revocable(self): ) self.profile.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex: + with ( + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + ): revoc.return_value.get_or_create_active_registry = mock.CoroutineMock( return_value=( mock.MagicMock( # active_rev_reg_rec @@ -959,12 +965,13 @@ async def test_issue_credential_non_revocable(self): self.ledger.__aenter__ = mock.CoroutineMock(return_value=self.ledger) self.profile.context.injector.clear_binding(BaseLedger) self.profile.context.injector.bind_instance(BaseLedger, self.ledger) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), ): (ret_exchange, ret_cred_issue) = await self.manager.issue_credential( stored_exchange, comment=comment, retries=0 @@ -1022,11 +1029,10 @@ async def test_issue_credential_fills_rr(self): ) self.profile.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex: + with ( + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + ): revoc.return_value = mock.MagicMock( get_or_create_active_registry=( mock.CoroutineMock( @@ -1216,13 +1222,14 @@ async def test_receive_credential(self): credentials_attach=[CredentialIssue.wrap_indy_credential(INDY_CRED)] ) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(return_value=stored_exchange), - ) as retrieve_ex: + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(return_value=stored_exchange), + ) as retrieve_ex, + ): exchange = await self.manager.receive_credential(issue, connection_id) assert retrieve_ex.call_args.args[1] == connection_id @@ -1283,12 +1290,12 @@ async def test_store_credential(self): return_value=("test_ledger_id", self.ledger) ) self.profile.context.injector.bind_instance(IndyLedgerRequestsExecutor, executor) - with mock.patch.object( - test_module, "RevocationRegistry", autospec=True - ) as mock_rev_reg, mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10CredentialExchange, "delete_record", autospec=True + with ( + mock.patch.object( + test_module, "RevocationRegistry", autospec=True + ) as mock_rev_reg, + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + mock.patch.object(V10CredentialExchange, "delete_record", autospec=True), ): mock_rev_reg.from_definition = mock.MagicMock( return_value=mock.MagicMock( @@ -1389,10 +1396,9 @@ async def test_store_credential_no_preview(self): return_value=("test_ledger_id", self.ledger) ) self.profile.context.injector.bind_instance(IndyLedgerRequestsExecutor, executor) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10CredentialExchange, "delete_record", autospec=True + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + mock.patch.object(V10CredentialExchange, "delete_record", autospec=True), ): ret_exchange = await self.manager.store_credential(stored_exchange) @@ -1480,15 +1486,18 @@ async def test_send_credential_ack(self): async with self.profile.session() as session: await stored_exchange.save(session) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ), mock.patch.object( - V10CredentialExchange, "delete_record", autospec=True - ) as mock_delete_ex, mock.patch.object( - test_module.LOGGER, "exception", mock.MagicMock() - ) as mock_log_exception, mock.patch.object( - test_module.LOGGER, "warning", mock.MagicMock() - ) as mock_log_warning: + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True), + mock.patch.object( + V10CredentialExchange, "delete_record", autospec=True + ) as mock_delete_ex, + mock.patch.object( + test_module.LOGGER, "exception", mock.MagicMock() + ) as mock_log_exception, + mock.patch.object( + test_module.LOGGER, "warning", mock.MagicMock() + ) as mock_log_warning, + ): mock_delete_ex.side_effect = test_module.StorageError() (exch, ack) = await self.manager.send_credential_ack(stored_exchange) assert ack._thread @@ -1516,15 +1525,17 @@ async def test_receive_credential_ack(self): ack = CredentialAck() - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10CredentialExchange, "delete_record", autospec=True - ) as delete_ex, mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(), - ) as retrieve_ex: + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10CredentialExchange, "delete_record", autospec=True + ) as delete_ex, + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(), + ) as retrieve_ex, + ): retrieve_ex.return_value = stored_exchange ret_exchange = await self.manager.receive_credential_ack(ack, connection_id) @@ -1557,13 +1568,14 @@ async def test_receive_problem_report(self): } ) - with mock.patch.object( - V10CredentialExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10CredentialExchange, - "retrieve_by_connection_and_thread", - mock.CoroutineMock(), - ) as retrieve_ex: + with ( + mock.patch.object(V10CredentialExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10CredentialExchange, + "retrieve_by_connection_and_thread", + mock.CoroutineMock(), + ) as retrieve_ex, + ): retrieve_ex.return_value = stored_exchange ret_exchange = await self.manager.receive_problem_report( diff --git a/acapy_agent/protocols/issue_credential/v1_0/tests/test_routes.py b/acapy_agent/protocols/issue_credential/v1_0/tests/test_routes.py index a5fe618496..dddac2e214 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/issue_credential/v1_0/tests/test_routes.py @@ -120,13 +120,16 @@ async def test_credential_exchange_retrieve_x(self): async def test_credential_exchange_create(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.CredentialPreview, "deserialize", autospec=True - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module.CredentialPreview, "deserialize", autospec=True + ), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_credential_manager.return_value.create_offer = mock.CoroutineMock() mock_credential_manager.return_value.create_offer.return_value = ( @@ -151,13 +154,16 @@ async def test_credential_exchange_create(self): async def test_credential_exchange_create_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.CredentialPreview, "deserialize", autospec=True - ), mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module.CredentialPreview, "deserialize", autospec=True + ), + mock.patch.object(test_module.web, "json_response"), + ): mock_credential_manager.return_value.create_offer = mock.CoroutineMock() mock_credential_manager.return_value.create_offer.return_value = ( @@ -184,13 +190,16 @@ async def test_credential_exchange_create_no_proposal(self): async def test_credential_exchange_send(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.CredentialPreview, "deserialize", autospec=True - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module.CredentialPreview, "deserialize", autospec=True + ), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_credential_manager.return_value.create_offer = mock.CoroutineMock() mock_credential_manager.return_value.create_offer.return_value = ( @@ -229,11 +238,12 @@ async def test_credential_exchange_send_no_conn_record(self): return_value={"connection_id": conn_id, "credential_proposal": preview_spec} ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + ): # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -255,11 +265,12 @@ async def test_credential_exchange_send_not_ready(self): return_value={"connection_id": conn_id, "credential_proposal": preview_spec} ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + ): # Emulate connection not ready mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -274,12 +285,14 @@ async def test_credential_exchange_send_not_ready(self): async def test_credential_exchange_send_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.CredentialPreview, "deserialize", autospec=True + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module.CredentialPreview, "deserialize", autospec=True + ), ): mock_cred_ex_record = mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), @@ -313,13 +326,13 @@ async def test_credential_exchange_send_proposal(self): return_value={"connection_id": conn_id, "credential_proposal": preview_spec} ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex_record = mock.MagicMock() mock_credential_manager.return_value.create_proposal.return_value = ( mock_cred_ex_record @@ -336,12 +349,14 @@ async def test_credential_exchange_send_proposal(self): async def test_credential_exchange_send_proposal_no_conn_record(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.CredentialPreview, "deserialize", autospec=True + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module.CredentialPreview, "deserialize", autospec=True + ), ): # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = mock.CoroutineMock( @@ -373,12 +388,14 @@ async def test_credential_exchange_send_proposal_deser_x(self): async def test_credential_exchange_send_proposal_not_ready(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.CredentialPreview, "deserialize", autospec=True + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module.CredentialPreview, "deserialize", autospec=True + ), ): # Emulate connection not ready mock_conn_rec.retrieve_by_id = mock.CoroutineMock() @@ -399,11 +416,12 @@ async def test_credential_exchange_send_proposal_x(self): return_value={"connection_id": conn_id, "credential_proposal": preview_spec} ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + ): mock_cred_ex_record = mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), save_error_state=mock.CoroutineMock(), @@ -428,13 +446,13 @@ async def test_credential_exchange_create_free_offer(self): self.context.update_settings({"debug.auto_respond_credential_offer": True}) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_credential_manager.return_value.create_offer = mock.CoroutineMock() mock_cred_ex_record = mock.MagicMock() mock_credential_manager.return_value.create_offer.return_value = ( @@ -498,11 +516,12 @@ async def test_credential_exchange_create_free_offer_deser_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + ): mock_credential_manager.return_value.create_offer = mock.CoroutineMock() mock_credential_manager.return_value.create_offer.side_effect = ( test_module.BaseModelError() @@ -522,11 +541,12 @@ async def test_credential_exchange_create_free_offer_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + ): mock_cred_ex_record = mock.MagicMock( serialize=mock.MagicMock( side_effect=test_module.BaseModelError(), @@ -555,13 +575,13 @@ async def test_credential_exchange_send_free_offer(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_credential_manager.return_value.create_offer = mock.CoroutineMock() mock_cred_ex_record = mock.MagicMock() @@ -606,11 +626,12 @@ async def test_credential_exchange_send_free_offer_no_conn_record(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + ): # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -629,11 +650,12 @@ async def test_credential_exchange_send_free_offer_not_ready(self): self.request.json = mock.CoroutineMock() self.request.json.return_value["auto_issue"] = True - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + ): # Emulate connection not ready mock_conn_rec.retrieve_by_id = mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -658,11 +680,13 @@ async def test_credential_exchange_send_free_offer_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object(test_module.web, "json_response"), + ): mock_cred_ex_record = mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), save_error_state=mock.CoroutineMock(), @@ -684,15 +708,16 @@ async def test_credential_exchange_send_bound_offer(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_PROPOSAL_RECEIVED @@ -732,13 +757,15 @@ async def test_credential_exchange_send_bound_offer_no_conn_record(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.connection_id = "conn-123" mock_cred_ex.thread_id = "conn-123" mock_cred_ex.retrieve_by_id = mock.CoroutineMock( @@ -785,13 +812,15 @@ async def test_credential_exchange_send_bound_offer_not_ready(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.connection_id = "conn-123" mock_cred_ex.thread_id = "conn-123" mock_cred_ex.retrieve_by_id = mock.CoroutineMock() @@ -816,15 +845,16 @@ async def test_credential_exchange_send_request(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_OFFER_RECEIVED @@ -847,17 +877,19 @@ async def test_credential_exchange_send_request_no_conn(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "OobRecord", autospec=True - ) as mock_oob_rec, mock.patch.object( - test_module, "default_did_from_verkey", autospec=True - ) as mock_default_did_from_verkey, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "OobRecord", autospec=True) as mock_oob_rec, + mock.patch.object( + test_module, "default_did_from_verkey", autospec=True + ) as mock_default_did_from_verkey, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_oob_rec.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock.MagicMock(our_recipient_key="our-recipient_key") ) @@ -905,13 +937,15 @@ async def test_credential_exchange_send_request_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.connection_id = "conn-123" mock_cred_ex.thread_id = "conn-123" mock_cred_ex.retrieve_by_id = mock.CoroutineMock() @@ -938,13 +972,15 @@ async def test_credential_exchange_send_request_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.connection_id = "conn-123" mock_cred_ex.thread_id = "conn-123" mock_cred_ex.retrieve_by_id = mock.CoroutineMock() @@ -969,15 +1005,16 @@ async def test_credential_exchange_issue(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_REQUEST_RECEIVED @@ -1020,13 +1057,15 @@ async def test_credential_exchange_issue_no_conn_record(self): serialize=mock.MagicMock(), save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex_cls: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex_cls, + ): mock_cred_ex_rec.state = mock_cred_ex_cls.STATE_REQUEST_RECEIVED mock_cred_ex_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock_cred_ex_rec @@ -1050,13 +1089,15 @@ async def test_credential_exchange_issue_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_REQUEST_RECEIVED @@ -1084,13 +1125,15 @@ async def test_credential_exchange_issue_rev_reg_full(self): serialize=mock.MagicMock(), save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex_cls: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex_cls, + ): mock_cred_ex_cls.state = mock_cred_ex_cls.STATE_REQUEST_RECEIVED mock_cred_ex_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock_cred_ex_rec @@ -1116,13 +1159,15 @@ async def test_credential_exchange_issue_deser_x(self): serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex_cls: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex_cls, + ): mock_cred_ex_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock_cred_ex_rec ) @@ -1141,15 +1186,16 @@ async def test_credential_exchange_store(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_CREDENTIAL_RECEIVED @@ -1177,15 +1223,16 @@ async def test_credential_exchange_store_bad_cred_id_json(self): ) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_CREDENTIAL_RECEIVED @@ -1226,13 +1273,15 @@ async def test_credential_exchange_store_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.connection_id = "conn-123" mock_cred_ex.thread_id = "conn-123" mock_cred_ex.retrieve_by_id = mock.CoroutineMock( @@ -1262,13 +1311,13 @@ async def test_credential_exchange_store_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "CredentialManager", autospec=True - ), mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object(test_module, "CredentialManager", autospec=True), + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.connection_id = "conn-123" mock_cred_ex.thread_id = "conn-123" mock_cred_ex.retrieve_by_id = mock.CoroutineMock() @@ -1287,13 +1336,16 @@ async def test_credential_exchange_store_x(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "CredentialManager", autospec=True - ) as mock_credential_manager, mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex_cls, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "CredentialManager", autospec=True + ) as mock_credential_manager, + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex_cls, + mock.patch.object(test_module.web, "json_response"), + ): mock_cred_ex_record = mock.MagicMock( state=mock_cred_ex_cls.STATE_CREDENTIAL_RECEIVED, serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), @@ -1316,11 +1368,12 @@ async def test_credential_exchange_store_x(self): async def test_credential_exchange_remove(self): self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value = mock_cred_ex @@ -1366,15 +1419,17 @@ async def test_credential_exchange_problem_report(self): self.request.match_info = {"cred_ex_id": "dummy"} magic_report = mock.MagicMock() - with mock.patch.object( - test_module, "CredentialManager", autospec=True - ), mock.patch.object(test_module, "ConnRecord", autospec=True), mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ) as mock_problem_report, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "CredentialManager", autospec=True), + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + mock.patch.object( + test_module, "problem_report_for_record", mock.MagicMock() + ) as mock_problem_report, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(save_error_state=mock.CoroutineMock()) ) @@ -1410,13 +1465,13 @@ async def test_credential_exchange_problem_report_x(self): ) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "CredentialManager", autospec=True - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ), mock.patch.object( - test_module, "V10CredentialExchange", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "CredentialManager", autospec=True), + mock.patch.object(test_module, "problem_report_for_record", mock.MagicMock()), + mock.patch.object( + test_module, "V10CredentialExchange", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock( save_error_state=mock.CoroutineMock( diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/tests/test_handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/tests/test_handler.py index fed47beaf3..f795929e8b 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/tests/test_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/tests/test_handler.py @@ -1146,15 +1146,19 @@ async def test_store_credential(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object( - test_module, "RevocationRegistry", autospec=True - ) as mock_rev_reg, mock.patch.object( - test_module.AnonCredsCredFormatHandler, "get_detail_record", autospec=True - ) as mock_get_detail_record: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object( + test_module, "RevocationRegistry", autospec=True + ) as mock_rev_reg, + mock.patch.object( + test_module.AnonCredsCredFormatHandler, "get_detail_record", autospec=True + ) as mock_get_detail_record, + ): mock_rev_reg.from_definition = mock.MagicMock( return_value=mock.MagicMock( get_or_fetch_local_tails_path=mock.CoroutineMock() @@ -1251,11 +1255,14 @@ async def test_store_credential_holder_store_indy_error(self): side_effect=test_module.AnonCredsHolderError("Problem", {"message": "Nope"}) ) - with mock.patch.object( - test_module.AnonCredsCredFormatHandler, "get_detail_record", autospec=True - ) as mock_get_detail_record, mock.patch.object( - test_module.RevocationRegistry, "from_definition", mock.MagicMock() - ) as mock_rev_reg: + with ( + mock.patch.object( + test_module.AnonCredsCredFormatHandler, "get_detail_record", autospec=True + ) as mock_get_detail_record, + mock.patch.object( + test_module.RevocationRegistry, "from_definition", mock.MagicMock() + ) as mock_rev_reg, + ): mock_get_detail_record.return_value = mock.MagicMock( cred_request_metadata=cred_req_meta, save=mock.CoroutineMock(), diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/indy/tests/test_handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/indy/tests/test_handler.py index 91c80e2b7a..78bd346d02 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/indy/tests/test_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/indy/tests/test_handler.py @@ -1132,15 +1132,19 @@ async def test_store_credential(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object( - test_module, "RevocationRegistry", autospec=True - ) as mock_rev_reg, mock.patch.object( - test_module.IndyCredFormatHandler, "get_detail_record", autospec=True - ) as mock_get_detail_record: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object( + test_module, "RevocationRegistry", autospec=True + ) as mock_rev_reg, + mock.patch.object( + test_module.IndyCredFormatHandler, "get_detail_record", autospec=True + ) as mock_get_detail_record, + ): mock_rev_reg.from_definition = mock.MagicMock( return_value=mock.MagicMock( get_or_fetch_local_tails_path=mock.CoroutineMock() @@ -1236,11 +1240,14 @@ async def test_store_credential_holder_store_indy_error(self): side_effect=test_module.IndyHolderError("Problem", {"message": "Nope"}) ) - with mock.patch.object( - test_module.IndyCredFormatHandler, "get_detail_record", autospec=True - ) as mock_get_detail_record, mock.patch.object( - test_module.RevocationRegistry, "from_definition", mock.MagicMock() - ) as mock_rev_reg: + with ( + mock.patch.object( + test_module.IndyCredFormatHandler, "get_detail_record", autospec=True + ) as mock_get_detail_record, + mock.patch.object( + test_module.RevocationRegistry, "from_definition", mock.MagicMock() + ) as mock_rev_reg, + ): mock_get_detail_record.return_value = mock.MagicMock( cred_request_metadata=cred_req_meta, save=mock.CoroutineMock(), diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py index 2b2e948adb..33a92abbc9 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py @@ -255,12 +255,13 @@ async def test_receive_proposal(self): await self.handler.receive_proposal(cred_ex_record, cred_proposal_message) async def test_create_offer(self): - with mock.patch.object( - VcLdpManager, - "assert_can_issue_with_id_and_proof_type", - mock.CoroutineMock(), - ) as mock_can_issue, patch.object( - test_module, "get_properties_without_context", return_value=[] + with ( + mock.patch.object( + VcLdpManager, + "assert_can_issue_with_id_and_proof_type", + mock.CoroutineMock(), + ) as mock_can_issue, + patch.object(test_module, "get_properties_without_context", return_value=[]), ): (cred_format, attachment) = await self.handler.create_offer( self.cred_proposal @@ -295,11 +296,14 @@ async def test_create_offer_adds_bbs_context(self): ], ) - with mock.patch.object( - VcLdpManager, - "assert_can_issue_with_id_and_proof_type", - mock.CoroutineMock(), - ), patch.object(test_module, "get_properties_without_context", return_value=[]): + with ( + mock.patch.object( + VcLdpManager, + "assert_can_issue_with_id_and_proof_type", + mock.CoroutineMock(), + ), + patch.object(test_module, "get_properties_without_context", return_value=[]), + ): (cred_format, attachment) = await self.handler.create_offer(cred_proposal) # assert BBS url added to context @@ -320,11 +324,14 @@ async def test_create_offer_adds_ed25519_2020_context(self): ], ) - with mock.patch.object( - VcLdpManager, - "assert_can_issue_with_id_and_proof_type", - mock.CoroutineMock(), - ), patch.object(test_module, "get_properties_without_context", return_value=[]): + with ( + mock.patch.object( + VcLdpManager, + "assert_can_issue_with_id_and_proof_type", + mock.CoroutineMock(), + ), + patch.object(test_module, "get_properties_without_context", return_value=[]), + ): (cred_format, attachment) = await self.handler.create_offer(cred_proposal) # assert BBS url added to context @@ -342,15 +349,19 @@ async def test_create_offer_x_no_proposal(self): async def test_create_offer_x_wrong_attributes(self): missing_properties = ["foo"] - with mock.patch.object( - self.manager, - "assert_can_issue_with_id_and_proof_type", - mock.CoroutineMock(), - ), patch.object( - test_module, - "get_properties_without_context", - return_value=missing_properties, - ), self.assertRaises(LinkedDataProofException) as context: + with ( + mock.patch.object( + self.manager, + "assert_can_issue_with_id_and_proof_type", + mock.CoroutineMock(), + ), + patch.object( + test_module, + "get_properties_without_context", + return_value=missing_properties, + ), + self.assertRaises(LinkedDataProofException) as context, + ): await self.handler.create_offer(self.cred_proposal) assert ( @@ -885,17 +896,24 @@ async def test_store_credential_x_not_verified(self): cred_id = "cred_id" self.holder.store_credential = mock.CoroutineMock() - with mock.patch.object( - self.manager, - "_get_suite", - mock.CoroutineMock(), - ), mock.patch.object( - self.manager, - "verify_credential", - mock.CoroutineMock(return_value=DocumentVerificationResult(verified=False)), - ), mock.patch.object( - self.manager, - "_get_proof_purpose", - ), self.assertRaises(V20CredFormatError) as context: + with ( + mock.patch.object( + self.manager, + "_get_suite", + mock.CoroutineMock(), + ), + mock.patch.object( + self.manager, + "verify_credential", + mock.CoroutineMock( + return_value=DocumentVerificationResult(verified=False) + ), + ), + mock.patch.object( + self.manager, + "_get_proof_purpose", + ), + self.assertRaises(V20CredFormatError) as context, + ): await self.handler.store_credential(cred_ex_record, cred_id) assert "Received invalid credential: " in str(context.exception) diff --git a/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_offer_handler.py b/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_offer_handler.py index b87034e70c..ccd1a854e2 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_offer_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_offer_handler.py @@ -109,11 +109,14 @@ async def test_called_auto_request_x_indy(self): handler = test_module.V20CredOfferHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ) as mock_send_reply, mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object( + responder, "send_reply", mock.CoroutineMock() + ) as mock_send_reply, + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() @@ -145,11 +148,14 @@ async def test_called_auto_request_x_anoncreds(self): handler = test_module.V20CredOfferHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ) as mock_send_reply, mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object( + responder, "send_reply", mock.CoroutineMock() + ) as mock_send_reply, + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_proposal_handler.py b/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_proposal_handler.py index 8ece39bf7b..a901018d08 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_proposal_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_proposal_handler.py @@ -86,11 +86,14 @@ async def test_called_auto_offer_x_indy(self): handler = test_module.V20CredProposalHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ) as mock_send_reply, mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object( + responder, "send_reply", mock.CoroutineMock() + ) as mock_send_reply, + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() @@ -115,11 +118,14 @@ async def test_called_auto_offer_x_anoncreds(self): handler = test_module.V20CredProposalHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ) as mock_send_reply, mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object( + responder, "send_reply", mock.CoroutineMock() + ) as mock_send_reply, + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_request_handler.py b/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_request_handler.py index 3fc7571b62..f2d9763e0f 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_request_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/handlers/tests/test_cred_request_handler.py @@ -102,10 +102,11 @@ async def test_called_auto_issue_x_indy(self): ) request_context.injector.bind_instance(OobMessageProcessor, mock_oob_processor) - with mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - cred_ex_rec, "save_error_state", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(cred_ex_rec, "save_error_state", mock.CoroutineMock()), ): mock_cred_mgr.return_value.receive_request = mock.CoroutineMock( return_value=cred_ex_rec @@ -120,11 +121,14 @@ async def test_called_auto_issue_x_indy(self): handler = test_module.V20CredRequestHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ) as mock_send_reply, mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object( + responder, "send_reply", mock.CoroutineMock() + ) as mock_send_reply, + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() @@ -142,10 +146,11 @@ async def test_called_auto_issue_x_anoncreds(self): ) request_context.injector.bind_instance(OobMessageProcessor, mock_oob_processor) - with mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - cred_ex_rec, "save_error_state", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(cred_ex_rec, "save_error_state", mock.CoroutineMock()), ): mock_cred_mgr.return_value.receive_request = mock.CoroutineMock( return_value=cred_ex_rec @@ -160,11 +165,14 @@ async def test_called_auto_issue_x_anoncreds(self): handler = test_module.V20CredRequestHandler() responder = MockResponder() - with mock.patch.object( - responder, "send_reply", mock.CoroutineMock() - ) as mock_send_reply, mock.patch.object( - handler._logger, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object( + responder, "send_reply", mock.CoroutineMock() + ) as mock_send_reply, + mock.patch.object( + handler._logger, "exception", mock.MagicMock() + ) as mock_log_exc, + ): await handler.handle(request_context, responder) mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v2_0/models/tests/test_cred_ex_record.py b/acapy_agent/protocols/issue_credential/v2_0/models/tests/test_cred_ex_record.py index a3ef8a756d..b7fdaa2e7b 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/models/tests/test_cred_ex_record.py +++ b/acapy_agent/protocols/issue_credential/v2_0/models/tests/test_cred_ex_record.py @@ -125,11 +125,12 @@ async def test_save_error_state(self): record.state = V20CredExRecord.STATE_PROPOSAL_RECEIVED await record.save(session) - with mock.patch.object( - record, "save", mock.CoroutineMock() - ) as mock_save, mock.patch.object( - test_module.LOGGER, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(record, "save", mock.CoroutineMock()) as mock_save, + mock.patch.object( + test_module.LOGGER, "exception", mock.MagicMock() + ) as mock_log_exc, + ): mock_save.side_effect = test_module.StorageError() await record.save_error_state(session, reason="test") mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/issue_credential/v2_0/tests/test_manager.py b/acapy_agent/protocols/issue_credential/v2_0/tests/test_manager.py index 65062ad5ea..015033925e 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/tests/test_manager.py +++ b/acapy_agent/protocols/issue_credential/v2_0/tests/test_manager.py @@ -145,11 +145,10 @@ async def test_create_proposal(self): ) ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.create_proposal = mock.CoroutineMock( return_value=( V20CredFormat( @@ -186,11 +185,10 @@ async def test_create_proposal_no_preview(self): connection_id = "test_conn_id" comment = "comment" - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.create_proposal = mock.CoroutineMock( return_value=( V20CredFormat( @@ -236,11 +234,10 @@ async def test_receive_proposal(self): ) ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.receive_proposal = mock.CoroutineMock() cred_proposal = V20CredProposal( @@ -308,11 +305,10 @@ async def test_create_free_offer(self): cred_proposal=cred_proposal, ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.create_offer = mock.CoroutineMock( return_value=( V20CredFormat( @@ -384,11 +380,10 @@ async def test_create_bound_offer(self): cred_proposal=cred_proposal, ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.create_offer = mock.CoroutineMock( return_value=( V20CredFormat( @@ -492,15 +487,15 @@ async def test_receive_offer_proposed(self): thread_id=thread_id, ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredExRecord, - "retrieve_by_conn_and_thread", - mock.CoroutineMock(return_value=stored_cx_rec), - ) as mock_retrieve, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object( + V20CredExRecord, + "retrieve_by_conn_and_thread", + mock.CoroutineMock(return_value=stored_cx_rec), + ) as mock_retrieve, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.receive_offer = mock.CoroutineMock() cx_rec = await self.manager.receive_offer(cred_offer, connection_id) @@ -549,13 +544,13 @@ async def test_receive_free_offer(self): self.context.conn_record = mock.MagicMock() self.context.conn_record.connection_id = connection_id - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object( + V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.receive_offer = mock.CoroutineMock() mock_retrieve.side_effect = (StorageNotFoundError(),) cx_rec = await self.manager.receive_offer(cred_offer, connection_id) @@ -602,11 +597,10 @@ async def test_create_bound_request(self): self.cache = InMemoryCache() self.context.injector.bind_instance(BaseCache, self.cache) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.create_request = mock.CoroutineMock( return_value=( V20CredFormat( @@ -689,11 +683,10 @@ async def test_create_free_request(self): self.cache = InMemoryCache() self.context.injector.bind_instance(BaseCache, self.cache) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.create_request = mock.CoroutineMock( return_value=( V20CredFormat( @@ -754,13 +747,13 @@ async def test_receive_request(self): requests_attach=[AttachDecorator.data_base64(INDY_CRED_REQ, ident="0")], ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object( + V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_retrieve.side_effect = (StorageNotFoundError(),) mock_handler.return_value.receive_request = mock.CoroutineMock() @@ -799,13 +792,13 @@ async def test_receive_request_no_connection_cred_request(self): mock_conn = mock.MagicMock(connection_id="test_conn_id") mock_oob = mock.MagicMock() - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object( + V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_retrieve.return_value = stored_cx_rec mock_handler.return_value.receive_request = mock.CoroutineMock() @@ -834,11 +827,13 @@ async def test_receive_request_no_cred_ex_with_offer_found(self): requests_attach=[AttachDecorator.data_base64(INDY_CRED_REQ, ident="0")], ) - with mock.patch.object(V20CredExRecord, "save", autospec=True), mock.patch.object( - V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True), + mock.patch.object( + V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_retrieve.side_effect = (StorageNotFoundError(),) mock_handler.return_value.receive_request = mock.CoroutineMock() @@ -926,11 +921,10 @@ async def test_issue_credential_indy(self): ) self.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.issue_credential = mock.CoroutineMock( return_value=( V20CredFormat( @@ -1033,11 +1027,10 @@ async def test_issue_credential_anoncreds(self): ) self.context.injector.bind_instance(AnonCredsIssuer, issuer) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.issue_credential = mock.CoroutineMock( return_value=( V20CredFormat( @@ -1139,15 +1132,15 @@ async def test_receive_cred(self): credentials_attach=[AttachDecorator.data_base64(INDY_CRED, ident="0")], ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredExRecord, - "retrieve_by_conn_and_thread", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object( + V20CredExRecord, + "retrieve_by_conn_and_thread", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.receive_credential = mock.CoroutineMock() mock_retrieve.return_value = stored_cx_rec ret_cx_rec = await self.manager.receive_credential( @@ -1282,13 +1275,13 @@ async def test_store_credential(self): thread_id=thread_id, ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - test_module.V20CredManager, "delete_cred_ex_record", autospec=True - ) as mock_delete, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object( + test_module.V20CredManager, "delete_cred_ex_record", autospec=True + ) as mock_delete, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_handler.return_value.store_credential = mock.CoroutineMock() ret_cx_rec = await self.manager.store_credential( @@ -1329,15 +1322,18 @@ async def test_send_cred_ack(self): auto_remove=True, ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save_ex, mock.patch.object( - V20CredExRecord, "delete_record", autospec=True - ) as mock_delete_ex, mock.patch.object( - test_module.LOGGER, "exception", mock.MagicMock() - ) as mock_log_exception, mock.patch.object( - test_module.LOGGER, "warning", mock.MagicMock() - ) as mock_log_warning: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save_ex, + mock.patch.object( + V20CredExRecord, "delete_record", autospec=True + ) as mock_delete_ex, + mock.patch.object( + test_module.LOGGER, "exception", mock.MagicMock() + ) as mock_log_exception, + mock.patch.object( + test_module.LOGGER, "warning", mock.MagicMock() + ) as mock_log_warning, + ): mock_delete_ex.side_effect = test_module.StorageError() (_, ack) = await self.manager.send_cred_ack(stored_exchange) assert ack._thread @@ -1361,15 +1357,18 @@ async def test_receive_cred_ack(self): ack = V20CredAck() - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as mock_save, mock.patch.object( - V20CredExRecord, "delete_record", autospec=True - ) as mock_delete, mock.patch.object( - V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - test_module.V20CredManager, "delete_cred_ex_record", autospec=True - ) as mock_delete: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as mock_save, + mock.patch.object( + V20CredExRecord, "delete_record", autospec=True + ) as mock_delete, + mock.patch.object( + V20CredExRecord, "retrieve_by_conn_and_thread", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object( + test_module.V20CredManager, "delete_cred_ex_record", autospec=True + ) as mock_delete, + ): mock_retrieve.return_value = stored_cx_rec ret_cx_rec = await self.manager.receive_credential_ack( ack, @@ -1386,13 +1385,15 @@ async def test_delete_cred_ex_record(self): stored_cx_rec = mock.MagicMock(delete_record=mock.CoroutineMock()) stored_indy = mock.MagicMock(delete_record=mock.CoroutineMock()) - with mock.patch.object( - V20CredExRecord, "delete_record", autospec=True - ), mock.patch.object( - V20CredExRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - test_module, "V20CredFormat", mock.MagicMock() - ) as mock_cred_format: + with ( + mock.patch.object(V20CredExRecord, "delete_record", autospec=True), + mock.patch.object( + V20CredExRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object( + test_module, "V20CredFormat", mock.MagicMock() + ) as mock_cred_format, + ): mock_retrieve.return_value = stored_cx_rec mock_cred_format.Format = [ mock.MagicMock( @@ -1428,13 +1429,14 @@ async def test_receive_problem_report(self): } ) - with mock.patch.object( - V20CredExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20CredExRecord, - "retrieve_by_conn_and_thread", - mock.CoroutineMock(), - ) as retrieve_ex: + with ( + mock.patch.object(V20CredExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20CredExRecord, + "retrieve_by_conn_and_thread", + mock.CoroutineMock(), + ) as retrieve_ex, + ): retrieve_ex.return_value = stored_exchange ret_exchange = await self.manager.receive_problem_report( diff --git a/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py b/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py index 1359057136..9e3663d5ed 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py +++ b/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py @@ -135,11 +135,12 @@ async def test_credential_exchange_list_x(self): async def test_credential_exchange_retrieve(self): self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock() @@ -173,11 +174,12 @@ async def test_credential_exchange_retrieve(self): async def test_credential_exchange_retrieve_indy_ld_proof(self): self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock() @@ -231,11 +233,12 @@ async def test_credential_exchange_retrieve_not_found(self): async def test_credential_exchange_retrieve_x(self): self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock() @@ -254,13 +257,14 @@ async def test_credential_exchange_retrieve_x(self): async def test_credential_exchange_create(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.V20CredPreview, "deserialize", autospec=True - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.V20CredPreview, "deserialize", autospec=True), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_mgr.return_value.create_offer = mock.CoroutineMock() mock_cred_mgr.return_value.create_offer.return_value = ( @@ -283,13 +287,14 @@ async def test_credential_exchange_create(self): async def test_credential_exchange_create_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.V20CredPreview, "deserialize", autospec=True - ), mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.V20CredPreview, "deserialize", autospec=True), + mock.patch.object(test_module.web, "json_response"), + ): mock_cred_mgr.return_value.create_offer = mock.CoroutineMock() mock_cred_mgr.return_value.create_offer.return_value = ( @@ -323,13 +328,14 @@ async def test_credential_exchange_create_no_filter(self): async def test_credential_exchange_send(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.V20CredPreview, "deserialize", autospec=True - ), mock.patch.object(test_module.web, "json_response") as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.V20CredPreview, "deserialize", autospec=True), + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_mgr.return_value.create_offer = mock.CoroutineMock() mock_cred_mgr.return_value.create_offer.return_value = ( @@ -353,17 +359,19 @@ async def test_credential_exchange_send_request_no_conn_no_holder_did(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "OobRecord", autospec=True - ) as mock_oob_rec, mock.patch.object( - test_module, "default_did_from_verkey", autospec=True - ) as mock_default_did_from_verkey, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "OobRecord", autospec=True) as mock_oob_rec, + mock.patch.object( + test_module, "default_did_from_verkey", autospec=True + ) as mock_default_did_from_verkey, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cred_ex, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_oob_rec.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock.MagicMock(our_recipient_key="our-recipient_key") ) @@ -403,11 +411,12 @@ async def test_credential_exchange_send_no_conn_record(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -433,11 +442,12 @@ async def test_credential_exchange_send_not_ready(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): mock_conn_rec.retrieve_by_id.return_value.is_ready = False mock_cred_mgr.return_value.create_offer.return_value = ( @@ -451,12 +461,12 @@ async def test_credential_exchange_send_not_ready(self): async def test_credential_exchange_send_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.V20CredPreview, "deserialize", autospec=True + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.V20CredPreview, "deserialize", autospec=True), ): mock_cred_ex_record = mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), @@ -493,13 +503,13 @@ async def test_credential_exchange_send_proposal(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cx_rec = mock.MagicMock() mock_cred_mgr.return_value.create_proposal.return_value = mock_cx_rec @@ -525,12 +535,12 @@ async def test_credential_exchange_send_proposal_no_filter(self): async def test_credential_exchange_send_proposal_no_conn_record(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.V20CredPreview, "deserialize", autospec=True + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.V20CredPreview, "deserialize", autospec=True), ): # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = mock.CoroutineMock( @@ -554,11 +564,12 @@ async def test_credential_exchange_send_proposal_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): mock_cx_rec = mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), save_error_state=mock.CoroutineMock(), @@ -571,12 +582,12 @@ async def test_credential_exchange_send_proposal_x(self): async def test_credential_exchange_send_proposal_not_ready(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.V20CredPreview, "deserialize", autospec=True + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.V20CredPreview, "deserialize", autospec=True), ): # Emulate connection not ready mock_conn_rec.retrieve_by_id = mock.CoroutineMock() @@ -599,13 +610,13 @@ async def test_credential_exchange_create_free_offer(self): ) self.context.update_settings({"debug.auto_respond_credential_offer": True}) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_mgr.return_value.create_offer = mock.CoroutineMock() mock_cx_rec = mock.MagicMock() mock_cred_mgr.return_value.create_offer.return_value = ( @@ -642,11 +653,12 @@ async def test_credential_exchange_create_free_offer_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): mock_cx_rec = mock.MagicMock( serialize=mock.MagicMock( side_effect=test_module.BaseModelError(), @@ -675,13 +687,13 @@ async def test_credential_exchange_send_free_offer(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_mgr.return_value.create_offer = mock.CoroutineMock() mock_cx_rec = mock.MagicMock() mock_cred_mgr.return_value.create_offer.return_value = ( @@ -713,13 +725,13 @@ async def test_credential_exchange_send_free_offer_vcdi(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): # Mock the creation of a credential offer, especially for handling VC-DI mock_cred_mgr.return_value.create_offer = mock.CoroutineMock() mock_cx_rec = mock.MagicMock() @@ -759,11 +771,12 @@ async def test_credential_exchange_send_free_offer_no_conn_record(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -789,11 +802,12 @@ async def test_credential_exchange_send_free_offer_not_ready(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): # Emulate connection not ready mock_conn_rec.retrieve_by_id = mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -818,11 +832,13 @@ async def test_credential_exchange_send_free_offer_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_cx_rec = mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), save_error_state=mock.CoroutineMock(), @@ -843,15 +859,16 @@ async def test_credential_exchange_send_bound_offer(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_PROPOSAL_RECEIVED @@ -874,13 +891,16 @@ async def test_credential_exchange_send_bound_offer_linked_data_error(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response"), + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_PROPOSAL_RECEIVED @@ -916,13 +936,15 @@ async def test_credential_exchange_send_bound_offer_no_conn_record(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock( @@ -969,13 +991,15 @@ async def test_credential_exchange_send_bound_offer_not_ready(self): self.request.json = mock.CoroutineMock(return_value={}) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock() @@ -1000,15 +1024,16 @@ async def test_credential_exchange_send_request(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_OFFER_RECEIVED @@ -1044,13 +1069,15 @@ async def test_credential_exchange_send_request_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock() @@ -1077,13 +1104,15 @@ async def test_credential_exchange_send_request_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock() @@ -1111,13 +1140,13 @@ async def test_credential_exchange_send_free_request(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_mgr.return_value.create_request = mock.CoroutineMock() mock_cx_rec = mock.MagicMock() @@ -1145,11 +1174,12 @@ async def test_credential_exchange_send_free_request_no_conn_record(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -1171,11 +1201,12 @@ async def test_credential_exchange_send_free_request_not_ready(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + ): # Emulate connection not ready mock_conn_rec.retrieve_by_id = mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -1196,11 +1227,13 @@ async def test_credential_exchange_send_free_request_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_cred_mgr.return_value.create_request = mock.CoroutineMock( side_effect=[ test_module.LedgerError(), @@ -1217,17 +1250,17 @@ async def test_credential_exchange_issue(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_REQUEST_RECEIVED @@ -1266,17 +1299,17 @@ async def test_credential_exchange_issue_vcdi(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_REQUEST_RECEIVED @@ -1335,13 +1368,15 @@ async def test_credential_exchange_issue_no_conn_record(self): serialize=mock.MagicMock(), save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + ): mock_cx_rec.state = mock_cx_rec_cls.STATE_REQUEST_RECEIVED mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock(return_value=mock_cx_rec) @@ -1363,13 +1398,15 @@ async def test_credential_exchange_issue_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + ): mock_cx_rec.retrieve_by_id = mock.CoroutineMock() mock_cx_rec.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_REQUEST_RECEIVED @@ -1397,13 +1434,15 @@ async def test_credential_exchange_issue_rev_reg_full_indy(self): serialize=mock.MagicMock(), save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + ): mock_cx_rec.state = mock_cx_rec_cls.STATE_REQUEST_RECEIVED mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock(return_value=mock_cx_rec) @@ -1427,13 +1466,15 @@ async def test_credential_exchange_issue_rev_reg_full_anoncreds(self): serialize=mock.MagicMock(), save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + ): mock_cx_rec.state = mock_cx_rec_cls.STATE_REQUEST_RECEIVED mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock(return_value=mock_cx_rec) @@ -1459,13 +1500,15 @@ async def test_credential_exchange_issue_deser_x(self): mock_conn_rec = mock.MagicMock(ConnRecord, autospec=True) mock_conn_rec.retrieve_by_id = mock.CoroutineMock(return_value=ConnRecord()) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock(return_value=mock_cx_rec) mock_cred_mgr.return_value = mock.MagicMock( issue_credential=mock.CoroutineMock( @@ -1491,17 +1534,17 @@ async def test_credential_exchange_store(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - V20CredFormat.Format, "handler" - ) as mock_handler: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_CREDENTIAL_RECEIVED @@ -1543,19 +1586,22 @@ async def test_credential_exchange_store_bad_cred_id_json(self): ) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response, mock.patch.object( - LDProofCredFormatHandler, "get_detail_record", autospec=True - ) as mock_ld_proof_get_detail_record, mock.patch.object( - IndyCredFormatHandler, "get_detail_record", autospec=True - ) as mock_indy_get_detail_record: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + mock.patch.object( + LDProofCredFormatHandler, "get_detail_record", autospec=True + ) as mock_ld_proof_get_detail_record, + mock.patch.object( + IndyCredFormatHandler, "get_detail_record", autospec=True + ) as mock_indy_get_detail_record, + ): mock_cx_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_CREDENTIAL_RECEIVED @@ -1613,13 +1659,15 @@ async def test_credential_exchange_store_no_conn_record(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock( @@ -1647,13 +1695,13 @@ async def test_credential_exchange_store_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20CredManager", autospec=True - ), mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object(test_module, "V20CredManager", autospec=True), + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec, + ): mock_cx_rec.connection_id = "conn-123" mock_cx_rec.thread_id = "conn-123" mock_cx_rec.retrieve_by_id = mock.CoroutineMock() @@ -1672,15 +1720,17 @@ async def test_credential_exchange_store_x(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cx_rec_cls, mock.patch.object( - test_module.web, "json_response" - ), mock.patch.object(V20CredFormat.Format, "handler") as mock_handler: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cx_rec_cls, + mock.patch.object(test_module.web, "json_response"), + mock.patch.object(V20CredFormat.Format, "handler") as mock_handler, + ): mock_cx_rec = mock.MagicMock( state=mock_cx_rec_cls.STATE_CREDENTIAL_RECEIVED, serialize=mock.MagicMock(side_effect=test_module.BaseModelError()), @@ -1716,11 +1766,12 @@ async def test_credential_exchange_store_x(self): async def test_credential_exchange_remove(self): self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20CredManager", autospec=True - ) as mock_cred_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20CredManager", autospec=True + ) as mock_cred_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_mgr.return_value = mock.MagicMock( delete_cred_ex_record=mock.CoroutineMock() ) @@ -1765,15 +1816,16 @@ async def test_credential_exchange_problem_report(self): self.request.match_info = {"cred_ex_id": "dummy"} magic_report = mock.MagicMock() - with mock.patch.object( - test_module, "V20CredManager", autospec=True - ), mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cred_ex, mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ) as mock_problem_report, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "V20CredManager", autospec=True), + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cred_ex, + mock.patch.object( + test_module, "problem_report_for_record", mock.MagicMock() + ) as mock_problem_report, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(save_error_state=mock.CoroutineMock()) ) @@ -1793,11 +1845,12 @@ async def test_credential_exchange_problem_report_bad_cred_ex_id(self): ) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20CredManager", autospec=True - ), mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "V20CredManager", autospec=True), + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() ) @@ -1811,13 +1864,13 @@ async def test_credential_exchange_problem_report_x(self): ) self.request.match_info = {"cred_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20CredManager", autospec=True - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ), mock.patch.object( - test_module, "V20CredExRecord", autospec=True - ) as mock_cred_ex: + with ( + mock.patch.object(test_module, "V20CredManager", autospec=True), + mock.patch.object(test_module, "problem_report_for_record", mock.MagicMock()), + mock.patch.object( + test_module, "V20CredExRecord", autospec=True + ) as mock_cred_ex, + ): mock_cred_ex.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock( save_error_state=mock.CoroutineMock( diff --git a/acapy_agent/protocols/out_of_band/v1_0/tests/test_manager.py b/acapy_agent/protocols/out_of_band/v1_0/tests/test_manager.py index 9d1ae4b624..1e5b41ba7e 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/out_of_band/v1_0/tests/test_manager.py @@ -399,11 +399,14 @@ async def test_create_invitation_multitenant_local(self): } ) - with mock.patch.object( - AskarWallet, "create_signing_key", autospec=True - ) as mock_wallet_create_signing_key, mock.patch.object( - self.multitenant_mgr, "get_default_mediator" - ) as mock_get_default_mediator: + with ( + mock.patch.object( + AskarWallet, "create_signing_key", autospec=True + ) as mock_wallet_create_signing_key, + mock.patch.object( + self.multitenant_mgr, "get_default_mediator" + ) as mock_get_default_mediator, + ): mock_wallet_create_signing_key.return_value = KeyInfo( TestConfig.test_verkey, None, ED25519 ) @@ -455,11 +458,12 @@ async def test_create_invitation_mediation_overwrites_routing_and_endpoint(self) endpoint=self.test_mediator_endpoint, ) await mediation_record.save(session) - with mock.patch.object( - MediationManager, - "get_default_mediator_id", - ) as mock_get_default_mediator, mock.patch.object( - mock_conn_rec, "metadata_set", mock.CoroutineMock() + with ( + mock.patch.object( + MediationManager, + "get_default_mediator_id", + ) as mock_get_default_mediator, + mock.patch.object(mock_conn_rec, "metadata_set", mock.CoroutineMock()), ): invite = await self.manager.create_invitation( my_endpoint=TestConfig.test_endpoint, @@ -496,13 +500,16 @@ async def test_create_invitation_no_handshake_no_attachments_x(self): async def test_create_invitation_attachment_v1_0_cred_offer(self): self.profile.context.update_settings({"public_invites": True}) - with mock.patch.object( - AskarWallet, "get_public_did", autospec=True - ) as mock_wallet_get_public_did, mock.patch.object( - V10CredentialExchange, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_cxid: + with ( + mock.patch.object( + AskarWallet, "get_public_did", autospec=True + ) as mock_wallet_get_public_did, + mock.patch.object( + V10CredentialExchange, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_cxid, + ): mock_wallet_get_public_did.return_value = DIDInfo( TestConfig.test_did, TestConfig.test_verkey, @@ -530,13 +537,16 @@ async def test_create_invitation_attachment_v1_0_cred_offer(self): async def test_create_invitation_attachment_v1_0_cred_offer_no_handshake(self): self.profile.context.update_settings({"public_invites": True}) - with mock.patch.object( - AskarWallet, "get_public_did", autospec=True - ) as mock_wallet_get_public_did, mock.patch.object( - V10CredentialExchange, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_cxid: + with ( + mock.patch.object( + AskarWallet, "get_public_did", autospec=True + ) as mock_wallet_get_public_did, + mock.patch.object( + V10CredentialExchange, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_cxid, + ): mock_wallet_get_public_did.return_value = DIDInfo( TestConfig.test_did, TestConfig.test_verkey, @@ -564,17 +574,21 @@ async def test_create_invitation_attachment_v1_0_cred_offer_no_handshake(self): } async def test_create_invitation_attachment_v2_0_cred_offer(self): - with mock.patch.object( - AskarWallet, "get_public_did", autospec=True - ) as mock_wallet_get_public_did, mock.patch.object( - test_module.V10CredentialExchange, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_cxid_v1, mock.patch.object( - test_module.V20CredExRecord, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_cxid_v2: + with ( + mock.patch.object( + AskarWallet, "get_public_did", autospec=True + ) as mock_wallet_get_public_did, + mock.patch.object( + test_module.V10CredentialExchange, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_cxid_v1, + mock.patch.object( + test_module.V20CredExRecord, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_cxid_v2, + ): mock_wallet_get_public_did.return_value = DIDInfo( TestConfig.test_did, TestConfig.test_verkey, @@ -602,13 +616,16 @@ async def test_create_invitation_attachment_v2_0_cred_offer(self): async def test_create_invitation_attachment_present_proof_v1_0(self): self.profile.context.update_settings({"public_invites": True}) - with mock.patch.object( - AskarWallet, "get_public_did", autospec=True - ) as mock_wallet_get_public_did, mock.patch.object( - test_module.V10PresentationExchange, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_pxid: + with ( + mock.patch.object( + AskarWallet, "get_public_did", autospec=True + ) as mock_wallet_get_public_did, + mock.patch.object( + test_module.V10PresentationExchange, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_pxid, + ): mock_wallet_get_public_did.return_value = DIDInfo( TestConfig.test_did, TestConfig.test_verkey, @@ -637,17 +654,21 @@ async def test_create_invitation_attachment_present_proof_v1_0(self): async def test_create_invitation_attachment_present_proof_v2_0(self): self.profile.context.update_settings({"public_invites": True}) - with mock.patch.object( - AskarWallet, "get_public_did", autospec=True - ) as mock_wallet_get_public_did, mock.patch.object( - test_module.V10PresentationExchange, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_pxid_1, mock.patch.object( - test_module.V20PresExRecord, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_pxid_2: + with ( + mock.patch.object( + AskarWallet, "get_public_did", autospec=True + ) as mock_wallet_get_public_did, + mock.patch.object( + test_module.V10PresentationExchange, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_pxid_1, + mock.patch.object( + test_module.V20PresExRecord, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_pxid_2, + ): mock_wallet_get_public_did.return_value = DIDInfo( TestConfig.test_did, TestConfig.test_verkey, @@ -904,14 +925,17 @@ async def test_wait_for_conn_rec_active_retrieve_by_id(self): async def test_create_handshake_reuse_msg(self): self.profile.context.update_settings({"public_invites": True}) - with mock.patch.object( - OutOfBandManager, - "fetch_connection_targets", - autospec=True, - ) as oob_mgr_fetch_conn, mock.patch.object( - ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=self.test_conn_rec), + with ( + mock.patch.object( + OutOfBandManager, + "fetch_connection_targets", + autospec=True, + ) as oob_mgr_fetch_conn, + mock.patch.object( + ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=self.test_conn_rec), + ), ): oob_mgr_fetch_conn.return_value = ConnectionTarget( did=TestConfig.test_did, @@ -974,17 +998,19 @@ async def test_receive_reuse_message_existing_found(self): self.test_conn_rec.invitation_msg_id = "test_123" self.test_conn_rec.state = ConnRecord.State.COMPLETED.rfc160 - with mock.patch.object( - OutOfBandManager, - "fetch_connection_targets", - autospec=True, - ) as oob_mgr_fetch_conn, mock.patch.object( - OobRecord, - "retrieve_by_tag_filter", - autospec=True, - ) as mock_retrieve_oob, mock.patch.object( - self.profile, "notify", autospec=True - ) as mock_notify: + with ( + mock.patch.object( + OutOfBandManager, + "fetch_connection_targets", + autospec=True, + ) as oob_mgr_fetch_conn, + mock.patch.object( + OobRecord, + "retrieve_by_tag_filter", + autospec=True, + ) as mock_retrieve_oob, + mock.patch.object(self.profile, "notify", autospec=True) as mock_notify, + ): mock_retrieve_oob.return_value = mock.MagicMock( emit_event=mock.CoroutineMock(), delete_record=mock.CoroutineMock(), @@ -1031,17 +1057,19 @@ async def test_receive_reuse_message_existing_found_multi_use(self): self.test_conn_rec.invitation_msg_id = "test_123" self.test_conn_rec.state = ConnRecord.State.COMPLETED.rfc160 - with mock.patch.object( - OutOfBandManager, - "fetch_connection_targets", - autospec=True, - ) as oob_mgr_fetch_conn, mock.patch.object( - OobRecord, - "retrieve_by_tag_filter", - autospec=True, - ) as mock_retrieve_oob, mock.patch.object( - self.profile, "notify", autospec=True - ) as mock_notify: + with ( + mock.patch.object( + OutOfBandManager, + "fetch_connection_targets", + autospec=True, + ) as oob_mgr_fetch_conn, + mock.patch.object( + OobRecord, + "retrieve_by_tag_filter", + autospec=True, + ) as mock_retrieve_oob, + mock.patch.object(self.profile, "notify", autospec=True) as mock_notify, + ): mock_retrieve_oob.return_value = mock.MagicMock( emit_event=mock.CoroutineMock(), delete_record=mock.CoroutineMock(), @@ -1085,11 +1113,12 @@ async def test_receive_reuse_accepted(self): reuse_msg_accepted = HandshakeReuseAccept() reuse_msg_accepted.assign_thread_id(thid="the-thread-id", pthid="the-pthid") - with mock.patch.object( - self.profile, "notify", autospec=True - ) as mock_notify, mock.patch.object( - OobRecord, "retrieve_by_tag_filter", autospec=True - ) as mock_retrieve_oob: + with ( + mock.patch.object(self.profile, "notify", autospec=True) as mock_notify, + mock.patch.object( + OobRecord, "retrieve_by_tag_filter", autospec=True + ) as mock_retrieve_oob, + ): mock_retrieve_oob.return_value = mock.MagicMock( emit_event=mock.CoroutineMock(), delete_record=mock.CoroutineMock(), @@ -1122,11 +1151,12 @@ async def test_receive_reuse_accepted_x(self): reuse_msg_accepted = HandshakeReuseAccept() reuse_msg_accepted.assign_thread_id(thid="the-thread-id", pthid="the-pthid") - with mock.patch.object( - self.profile, "notify", autospec=True - ) as mock_notify, mock.patch.object( - OobRecord, "retrieve_by_tag_filter", autospec=True - ) as mock_retrieve_oob: + with ( + mock.patch.object(self.profile, "notify", autospec=True) as mock_notify, + mock.patch.object( + OobRecord, "retrieve_by_tag_filter", autospec=True + ) as mock_retrieve_oob, + ): mock_retrieve_oob.side_effect = (StorageNotFoundError,) with self.assertRaises(test_module.OutOfBandManagerError) as err: @@ -1219,11 +1249,14 @@ async def test_receive_invitation_with_valid_mediation(self): endpoint=self.test_mediator_endpoint, ) await mediation_record.save(session) - with mock.patch.object( - DIDXManager, "receive_invitation", mock.CoroutineMock() - ) as mock_didx_recv_invi, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve_conn_by_id: + with ( + mock.patch.object( + DIDXManager, "receive_invitation", mock.CoroutineMock() + ) as mock_didx_recv_invi, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve_conn_by_id, + ): invite = await self.manager.create_invitation( my_endpoint=TestConfig.test_endpoint, my_label="test123", @@ -1249,15 +1282,18 @@ async def test_receive_invitation_with_valid_mediation(self): async def test_receive_invitation_with_invalid_mediation(self): mock_conn = mock.MagicMock(connection_id="dummy-connection") - with mock.patch.object( - DIDXManager, - "receive_invitation", - mock.CoroutineMock(), - ) as mock_didx_recv_invi, mock.patch.object( - ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(), - ) as mock_retrieve_conn_by_id: + with ( + mock.patch.object( + DIDXManager, + "receive_invitation", + mock.CoroutineMock(), + ) as mock_didx_recv_invi, + mock.patch.object( + ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(), + ) as mock_retrieve_conn_by_id, + ): invite = await self.manager.create_invitation( my_endpoint=TestConfig.test_endpoint, my_label="test123", @@ -1287,11 +1323,12 @@ async def test_receive_invitation_didx_services_with_service_block(self): mock_conn = mock.MagicMock(connection_id="dummy-connection") - with mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as didx_mgr_cls, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve_conn_by_id: + with ( + mock.patch.object(test_module, "DIDXManager", autospec=True) as didx_mgr_cls, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve_conn_by_id, + ): didx_mgr_cls.return_value = mock.MagicMock( receive_invitation=mock.CoroutineMock(return_value=mock_conn) ) @@ -1316,11 +1353,14 @@ async def test_receive_invitation_connection_protocol(self): mock_conn = mock.MagicMock(connection_id="dummy-connection") - with mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as conn_mgr_cls, mock.patch.object( - ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_conn_retrieve_by_id: + with ( + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as conn_mgr_cls, + mock.patch.object( + ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_conn_retrieve_by_id, + ): conn_mgr_cls.return_value = mock.MagicMock( receive_invitation=mock.CoroutineMock(return_value=mock_conn) ) @@ -1405,17 +1445,20 @@ async def test_existing_conn_record_public_did(self): their_role=ConnRecord.Role.REQUESTER, ) - with mock.patch.object( - ConnRecord, - "find_existing_connection", - mock.CoroutineMock(), - ) as oob_mgr_find_existing_conn, mock.patch.object( - OobRecord, "save", mock.CoroutineMock() - ) as oob_record_save, mock.patch.object( - OobRecord, "retrieve_by_id", mock.CoroutineMock() - ) as oob_record_retrieve_by_id, mock.patch.object( - OutOfBandManager, "fetch_connection_targets", autospec=True - ) as oob_mgr_fetch_conn: + with ( + mock.patch.object( + ConnRecord, + "find_existing_connection", + mock.CoroutineMock(), + ) as oob_mgr_find_existing_conn, + mock.patch.object(OobRecord, "save", mock.CoroutineMock()) as oob_record_save, + mock.patch.object( + OobRecord, "retrieve_by_id", mock.CoroutineMock() + ) as oob_record_retrieve_by_id, + mock.patch.object( + OutOfBandManager, "fetch_connection_targets", autospec=True + ) as oob_mgr_fetch_conn, + ): oob_mgr_find_existing_conn.return_value = test_exist_conn oob_mgr_fetch_conn.return_value = [] oob_invitation = InvitationMessage( @@ -1450,18 +1493,22 @@ async def test_receive_invitation_handshake_reuse(self): their_role=ConnRecord.Role.REQUESTER, ) - with mock.patch.object( - test_module.OutOfBandManager, - "_handle_handshake_reuse", - mock.CoroutineMock(), - ) as handle_handshake_reuse, mock.patch.object( - test_module.OutOfBandManager, - "_perform_handshake", - mock.CoroutineMock(), - ) as perform_handshake, mock.patch.object( - ConnRecord, - "find_existing_connection", - mock.CoroutineMock(return_value=test_exist_conn), + with ( + mock.patch.object( + test_module.OutOfBandManager, + "_handle_handshake_reuse", + mock.CoroutineMock(), + ) as handle_handshake_reuse, + mock.patch.object( + test_module.OutOfBandManager, + "_perform_handshake", + mock.CoroutineMock(), + ) as perform_handshake, + mock.patch.object( + ConnRecord, + "find_existing_connection", + mock.CoroutineMock(return_value=test_exist_conn), + ), ): oob_invitation = InvitationMessage( handshake_protocols=[ @@ -1498,22 +1545,27 @@ async def test_receive_invitation_handshake_reuse_failed(self): their_role=ConnRecord.Role.REQUESTER, ) - with mock.patch.object( - test_module.OutOfBandManager, - "_handle_handshake_reuse", - mock.CoroutineMock(), - ) as handle_handshake_reuse, mock.patch.object( - test_module.OutOfBandManager, - "_perform_handshake", - mock.CoroutineMock(), - ) as perform_handshake, mock.patch.object( - ConnRecord, - "find_existing_connection", - mock.CoroutineMock(return_value=test_exist_conn), - ), mock.patch.object( - ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=test_exist_conn), + with ( + mock.patch.object( + test_module.OutOfBandManager, + "_handle_handshake_reuse", + mock.CoroutineMock(), + ) as handle_handshake_reuse, + mock.patch.object( + test_module.OutOfBandManager, + "_perform_handshake", + mock.CoroutineMock(), + ) as perform_handshake, + mock.patch.object( + ConnRecord, + "find_existing_connection", + mock.CoroutineMock(return_value=test_exist_conn), + ), + mock.patch.object( + ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=test_exist_conn), + ), ): oob_invitation = InvitationMessage( handshake_protocols=[ @@ -1562,12 +1614,13 @@ async def test_receive_invitation_services_with_service_did(self): mock_conn = mock.MagicMock(connection_id="dummy") - with mock.patch.object( - test_module, "DIDXManager", autospec=True - ) as didx_mgr_cls, mock.patch.object( - ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_conn), + with ( + mock.patch.object(test_module, "DIDXManager", autospec=True) as didx_mgr_cls, + mock.patch.object( + ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_conn), + ), ): didx_mgr_cls.return_value = mock.MagicMock( receive_invitation=mock.CoroutineMock(return_value=mock_conn) @@ -1598,15 +1651,18 @@ async def test_request_attach_oob_message_processor_connectionless(self): endpoint=self.test_endpoint, recipient_keys=[self.test_verkey] ) - with mock.patch.object( - AskarWallet, - "create_signing_key", - mock.CoroutineMock(), - ) as mock_create_signing_key, mock.patch.object( - OutOfBandManager, - "_service_decorator_from_service", - mock.CoroutineMock(), - ) as mock_service_decorator_from_service: + with ( + mock.patch.object( + AskarWallet, + "create_signing_key", + mock.CoroutineMock(), + ) as mock_create_signing_key, + mock.patch.object( + OutOfBandManager, + "_service_decorator_from_service", + mock.CoroutineMock(), + ) as mock_service_decorator_from_service, + ): mock_create_signing_key.return_value = KeyInfo( verkey="H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV", metadata={}, @@ -1696,13 +1752,16 @@ async def test_request_attach_wait_for_conn_rec_active(self): their_role=ConnRecord.Role.REQUESTER, ) - with mock.patch.object( - OutOfBandManager, "_wait_for_conn_rec_active" - ) as mock_wait_for_conn_rec_active, mock.patch.object( - ConnRecord, - "find_existing_connection", - mock.CoroutineMock(), - ) as oob_mgr_find_existing_conn: + with ( + mock.patch.object( + OutOfBandManager, "_wait_for_conn_rec_active" + ) as mock_wait_for_conn_rec_active, + mock.patch.object( + ConnRecord, + "find_existing_connection", + mock.CoroutineMock(), + ) as oob_mgr_find_existing_conn, + ): oob_mgr_find_existing_conn.return_value = test_exist_conn mock_wait_for_conn_rec_active.return_value = None oob_invitation = InvitationMessage( @@ -1837,11 +1896,14 @@ async def test_delete_stale_connection_by_invitation(self): updated_at=datetime_to_str(older_datetime), ) ] - with mock.patch.object( - ConnRecord, "query", mock.CoroutineMock() - ) as mock_connrecord_query, mock.patch.object( - ConnRecord, "delete_record", mock.CoroutineMock() - ) as mock_connrecord_delete: + with ( + mock.patch.object( + ConnRecord, "query", mock.CoroutineMock() + ) as mock_connrecord_query, + mock.patch.object( + ConnRecord, "delete_record", mock.CoroutineMock() + ) as mock_connrecord_delete, + ): mock_connrecord_query.return_value = records await self.manager.delete_stale_connection_by_invitation("test123") mock_connrecord_delete.assert_called_once() @@ -1868,15 +1930,20 @@ async def test_delete_conn_and_oob_record_invitation(self): invitation_msg_id="test123", ) ] - with mock.patch.object( - ConnRecord, "query", mock.CoroutineMock() - ) as mock_connrecord_query, mock.patch.object( - ConnRecord, "delete_record", mock.CoroutineMock() - ) as mock_connrecord_delete, mock.patch.object( - OobRecord, "query", mock.CoroutineMock() - ) as mock_oobrecord_query, mock.patch.object( - OobRecord, "delete_record", mock.CoroutineMock() - ) as mock_oobrecord_delete: + with ( + mock.patch.object( + ConnRecord, "query", mock.CoroutineMock() + ) as mock_connrecord_query, + mock.patch.object( + ConnRecord, "delete_record", mock.CoroutineMock() + ) as mock_connrecord_delete, + mock.patch.object( + OobRecord, "query", mock.CoroutineMock() + ) as mock_oobrecord_query, + mock.patch.object( + OobRecord, "delete_record", mock.CoroutineMock() + ) as mock_oobrecord_delete, + ): mock_connrecord_query.return_value = conn_records mock_oobrecord_query.return_value = oob_records await self.manager.delete_conn_and_oob_record_invitation("test123") diff --git a/acapy_agent/protocols/out_of_band/v1_0/tests/test_routes.py b/acapy_agent/protocols/out_of_band/v1_0/tests/test_routes.py index a42378c811..6e25915185 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/out_of_band/v1_0/tests/test_routes.py @@ -40,11 +40,14 @@ async def test_invitation_create(self): } self.request.json = mock.CoroutineMock(return_value=body) - with mock.patch.object( - test_module, "OutOfBandManager", autospec=True - ) as mock_oob_mgr, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "OutOfBandManager", autospec=True + ) as mock_oob_mgr, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_oob_mgr.return_value.create_invitation = mock.CoroutineMock( return_value=mock.MagicMock( serialize=mock.MagicMock(return_value={"abc": "123"}) @@ -75,11 +78,14 @@ async def test_invitation_create(self): async def test_invitation_remove(self): self.request.match_info = {"invi_msg_id": "dummy"} - with mock.patch.object( - test_module, "OutOfBandManager", autospec=True - ) as mock_oob_mgr, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "OutOfBandManager", autospec=True + ) as mock_oob_mgr, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_oob_mgr.return_value.delete_conn_and_oob_record_invitation = ( mock.CoroutineMock(return_value=None) ) @@ -100,11 +106,14 @@ async def test_invitation_create_with_accept(self): } self.request.json = mock.CoroutineMock(return_value=body) - with mock.patch.object( - test_module, "OutOfBandManager", autospec=True - ) as mock_oob_mgr, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "OutOfBandManager", autospec=True + ) as mock_oob_mgr, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_oob_mgr.return_value.create_invitation = mock.CoroutineMock( return_value=mock.MagicMock( serialize=mock.MagicMock(return_value={"abc": "123"}) @@ -142,11 +151,14 @@ async def test_invitation_create_x(self): } ) - with mock.patch.object( - test_module, "OutOfBandManager", autospec=True - ) as mock_oob_mgr, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "OutOfBandManager", autospec=True + ) as mock_oob_mgr, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_oob_mgr.return_value.create_invitation = mock.CoroutineMock( side_effect=test_module.OutOfBandManagerError() ) @@ -159,13 +171,15 @@ async def test_invitation_receive(self): self.request.json = mock.CoroutineMock() expected_connection_record = ConnRecord(connection_id="some-id") - with mock.patch.object( - test_module, "OutOfBandManager", autospec=True - ) as mock_oob_mgr, mock.patch.object( - test_module.InvitationMessage, "deserialize", mock.Mock() - ), mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "OutOfBandManager", autospec=True + ) as mock_oob_mgr, + mock.patch.object(test_module.InvitationMessage, "deserialize", mock.Mock()), + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_oob_mgr.return_value.receive_invitation = mock.CoroutineMock( return_value=expected_connection_record ) @@ -183,11 +197,13 @@ async def test_invitation_receive_forbidden_x(self): async def test_invitation_receive_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "OutOfBandManager", autospec=True - ) as mock_oob_mgr, mock.patch.object( - test_module.InvitationMessage, "deserialize", mock.Mock() - ), mock.patch.object(test_module.web, "json_response", mock.Mock()): + with ( + mock.patch.object( + test_module, "OutOfBandManager", autospec=True + ) as mock_oob_mgr, + mock.patch.object(test_module.InvitationMessage, "deserialize", mock.Mock()), + mock.patch.object(test_module.web, "json_response", mock.Mock()), + ): mock_oob_mgr.return_value.receive_invitation = mock.CoroutineMock( side_effect=test_module.StorageError("cannot write") ) diff --git a/acapy_agent/protocols/present_proof/dif/tests/test_pres_exch_handler.py b/acapy_agent/protocols/present_proof/dif/tests/test_pres_exch_handler.py index 654c62f432..3af1efe80e 100644 --- a/acapy_agent/protocols/present_proof/dif/tests/test_pres_exch_handler.py +++ b/acapy_agent/protocols/present_proof/dif/tests/test_pres_exch_handler.py @@ -2177,27 +2177,33 @@ async def test_create_vp_no_issuer(self): cred_tags={"some": "tag"}, ), ] - with mock.patch.object( - DIFPresExchHandler, - "_did_info_for_did", - mock.CoroutineMock(), - ) as mock_did_info, mock.patch.object( - DIFPresExchHandler, - "make_requirement", - mock.CoroutineMock(), - ) as mock_make_req, mock.patch.object( - DIFPresExchHandler, - "apply_requirements", - mock.CoroutineMock(), - ) as mock_apply_req, mock.patch.object( - DIFPresExchHandler, - "merge", - mock.CoroutineMock(), - ) as mock_merge, mock.patch.object( - test_module, - "create_presentation", - mock.CoroutineMock(), - ) as mock_create_vp: + with ( + mock.patch.object( + DIFPresExchHandler, + "_did_info_for_did", + mock.CoroutineMock(), + ) as mock_did_info, + mock.patch.object( + DIFPresExchHandler, + "make_requirement", + mock.CoroutineMock(), + ) as mock_make_req, + mock.patch.object( + DIFPresExchHandler, + "apply_requirements", + mock.CoroutineMock(), + ) as mock_apply_req, + mock.patch.object( + DIFPresExchHandler, + "merge", + mock.CoroutineMock(), + ) as mock_merge, + mock.patch.object( + test_module, + "create_presentation", + mock.CoroutineMock(), + ) as mock_create_vp, + ): mock_make_req.return_value = mock.MagicMock() mock_apply_req.return_value = mock.MagicMock() mock_merge.return_value = (VC_RECORDS, {}) @@ -2229,31 +2235,38 @@ async def test_create_vp_with_bbs_suite(self): self.profile, proof_type=BbsBlsSignature2020.signature_type ) cred_list, pd_list = await self.setup_tuple(self.profile) - with mock.patch.object( - DIFPresExchHandler, - "_did_info_for_did", - mock.CoroutineMock(), - ) as mock_did_info, mock.patch.object( - DIFPresExchHandler, - "make_requirement", - mock.CoroutineMock(), - ) as mock_make_req, mock.patch.object( - DIFPresExchHandler, - "apply_requirements", - mock.CoroutineMock(), - ) as mock_apply_req, mock.patch.object( - DIFPresExchHandler, - "merge", - mock.CoroutineMock(), - ) as mock_merge, mock.patch.object( - test_module, - "create_presentation", - mock.CoroutineMock(), - ) as mock_create_vp, mock.patch.object( - test_module, - "sign_presentation", - mock.CoroutineMock(), - ) as mock_sign_vp: + with ( + mock.patch.object( + DIFPresExchHandler, + "_did_info_for_did", + mock.CoroutineMock(), + ) as mock_did_info, + mock.patch.object( + DIFPresExchHandler, + "make_requirement", + mock.CoroutineMock(), + ) as mock_make_req, + mock.patch.object( + DIFPresExchHandler, + "apply_requirements", + mock.CoroutineMock(), + ) as mock_apply_req, + mock.patch.object( + DIFPresExchHandler, + "merge", + mock.CoroutineMock(), + ) as mock_merge, + mock.patch.object( + test_module, + "create_presentation", + mock.CoroutineMock(), + ) as mock_create_vp, + mock.patch.object( + test_module, + "sign_presentation", + mock.CoroutineMock(), + ) as mock_sign_vp, + ): mock_make_req.return_value = mock.MagicMock() mock_apply_req.return_value = mock.MagicMock() mock_merge.return_value = (cred_list, {}) @@ -2286,31 +2299,38 @@ async def test_create_vp_no_issuer_with_bbs_suite(self): self.profile, proof_type=BbsBlsSignature2020.signature_type ) cred_list, pd_list = await self.setup_tuple(self.profile) - with mock.patch.object( - DIFPresExchHandler, - "_did_info_for_did", - mock.CoroutineMock(), - ) as mock_did_info, mock.patch.object( - DIFPresExchHandler, - "make_requirement", - mock.CoroutineMock(), - ) as mock_make_req, mock.patch.object( - DIFPresExchHandler, - "apply_requirements", - mock.CoroutineMock(), - ) as mock_apply_req, mock.patch.object( - DIFPresExchHandler, - "merge", - mock.CoroutineMock(), - ) as mock_merge, mock.patch.object( - test_module, - "create_presentation", - mock.CoroutineMock(), - ) as mock_create_vp, mock.patch.object( - DIFPresExchHandler, - "get_sign_key_credential_subject_id", - mock.CoroutineMock(), - ) as mock_sign_key_cred_subject: + with ( + mock.patch.object( + DIFPresExchHandler, + "_did_info_for_did", + mock.CoroutineMock(), + ) as mock_did_info, + mock.patch.object( + DIFPresExchHandler, + "make_requirement", + mock.CoroutineMock(), + ) as mock_make_req, + mock.patch.object( + DIFPresExchHandler, + "apply_requirements", + mock.CoroutineMock(), + ) as mock_apply_req, + mock.patch.object( + DIFPresExchHandler, + "merge", + mock.CoroutineMock(), + ) as mock_merge, + mock.patch.object( + test_module, + "create_presentation", + mock.CoroutineMock(), + ) as mock_create_vp, + mock.patch.object( + DIFPresExchHandler, + "get_sign_key_credential_subject_id", + mock.CoroutineMock(), + ) as mock_sign_key_cred_subject, + ): mock_make_req.return_value = mock.MagicMock() mock_apply_req.return_value = mock.MagicMock() mock_merge.return_value = (cred_list, {}) diff --git a/acapy_agent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py b/acapy_agent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py index e43c2e80b0..25ccd85984 100644 --- a/acapy_agent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py +++ b/acapy_agent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py @@ -97,11 +97,14 @@ async def test_called(self): auto_present=True, ) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance ) @@ -149,11 +152,14 @@ async def test_called_not_found(self): auto_present=True, ) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( side_effect=StorageNotFoundError ) @@ -222,11 +228,14 @@ async def test_called_auto_present(self): ) self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -302,11 +311,14 @@ async def test_called_auto_present_x(self): ) self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = mock_px_rec mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock_px_rec @@ -368,11 +380,14 @@ async def test_called_auto_present_no_preview(self): ) self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -435,11 +450,14 @@ async def test_called_auto_present_pred_no_match(self): ) self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -498,11 +516,14 @@ async def test_called_auto_present_pred_single_match(self): ) self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -570,11 +591,14 @@ async def test_called_auto_present_pred_multi_match(self): ) self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -694,11 +718,14 @@ async def test_called_auto_present_multi_cred_match_reft(self): self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -798,11 +825,14 @@ async def test_called_auto_present_bait_and_switch(self): mock_holder.get_credentials_for_presentation_request_by_referent = by_reft self.request_context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "PresentationManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V10PresentationExchange", autospec=True - ) as mock_pres_ex_cls: + with ( + mock.patch.object( + test_module, "PresentationManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V10PresentationExchange", autospec=True + ) as mock_pres_ex_cls, + ): mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance diff --git a/acapy_agent/protocols/present_proof/v1_0/models/tests/test_record.py b/acapy_agent/protocols/present_proof/v1_0/models/tests/test_record.py index 6868be17f3..4556877338 100644 --- a/acapy_agent/protocols/present_proof/v1_0/models/tests/test_record.py +++ b/acapy_agent/protocols/present_proof/v1_0/models/tests/test_record.py @@ -129,11 +129,12 @@ async def test_save_error_state(self): record.state = V10PresentationExchange.STATE_PROPOSAL_RECEIVED await record.save(session) - with mock.patch.object( - record, "save", mock.CoroutineMock() - ) as mock_save, mock.patch.object( - test_module.LOGGER, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(record, "save", mock.CoroutineMock()) as mock_save, + mock.patch.object( + test_module.LOGGER, "exception", mock.MagicMock() + ) as mock_log_exc, + ): mock_save.side_effect = test_module.StorageError() await record.save_error_state(session, reason="testing") mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/present_proof/v1_0/tests/test_manager.py b/acapy_agent/protocols/present_proof/v1_0/tests/test_manager.py index 7674f7e1f7..574acb5139 100644 --- a/acapy_agent/protocols/present_proof/v1_0/tests/test_manager.py +++ b/acapy_agent/protocols/present_proof/v1_0/tests/test_manager.py @@ -340,9 +340,10 @@ async def test_record_eq(self): async def test_create_exchange_for_proposal(self): proposal = PresentationProposal() - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object(PresentationProposal, "serialize", autospec=True): + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object(PresentationProposal, "serialize", autospec=True), + ): exchange = await self.manager.create_exchange_for_proposal( CONN_ID, proposal, @@ -441,13 +442,15 @@ async def test_create_presentation(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -484,13 +487,15 @@ async def test_create_presentation_proof_req_non_revoc_interval_none(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -545,13 +550,15 @@ async def test_create_presentation_self_asserted(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -616,13 +623,15 @@ async def test_create_presentation_no_revocation(self): self.holder.create_presentation = mock.CoroutineMock(return_value="{}") self.profile.context.injector.bind_instance(IndyHolder, self.holder) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module.LOGGER, "info", mock.MagicMock() - ) as mock_log_info: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module.LOGGER, "info", mock.MagicMock() + ) as mock_log_info, + ): mock_attach_decorator.data_base64 = mock.MagicMock( return_value=mock_attach_decorator ) @@ -690,13 +699,15 @@ async def test_create_presentation_bad_revoc_state(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ), mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True), + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -776,13 +787,15 @@ async def test_create_presentation_multi_matching_proposal_creds_names(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - test_module, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + test_module, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -921,13 +934,14 @@ async def test_receive_presentation(self): }, ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ), mock.patch.object( - V10PresentationExchange, - "retrieve_by_tag_filter", - mock.CoroutineMock(return_value=exchange_dummy), - ) as retrieve_ex: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True), + mock.patch.object( + V10PresentationExchange, + "retrieve_by_tag_filter", + mock.CoroutineMock(return_value=exchange_dummy), + ) as retrieve_ex, + ): retrieve_ex.side_effect = [exchange_dummy] exchange_out = await self.manager.receive_presentation( PRES, connection_record, None @@ -1024,11 +1038,12 @@ async def test_receive_presentation_oob(self): }, ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ), mock.patch.object( - V10PresentationExchange, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True), + mock.patch.object( + V10PresentationExchange, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [exchange_dummy] exchange_out = await self.manager.receive_presentation(PRES, None, None) assert exchange_out.state == ( @@ -1125,11 +1140,12 @@ async def test_receive_presentation_bait_and_switch(self): }, ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ), mock.patch.object( - V10PresentationExchange, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True), + mock.patch.object( + V10PresentationExchange, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = exchange_dummy with self.assertRaises(PresentationManagerError): await self.manager.receive_presentation(PRES, connection_record, None) @@ -1137,11 +1153,12 @@ async def test_receive_presentation_bait_and_switch(self): async def test_receive_presentation_connectionless(self): exchange_dummy = V10PresentationExchange() - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10PresentationExchange, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10PresentationExchange, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = exchange_dummy exchange_out = await self.manager.receive_presentation(PRES, None, None) save_ex.assert_called_once() @@ -1221,11 +1238,12 @@ async def test_receive_presentation_ack_a(self): exchange_dummy = V10PresentationExchange() message = mock.MagicMock() - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10PresentationExchange, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10PresentationExchange, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = exchange_dummy exchange_out = await self.manager.receive_presentation_ack( message, connection_record @@ -1242,11 +1260,12 @@ async def test_receive_presentation_ack_b(self): exchange_dummy = V10PresentationExchange() message = mock.MagicMock(_verification_result="true") - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10PresentationExchange, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10PresentationExchange, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = exchange_dummy exchange_out = await self.manager.receive_presentation_ack( message, connection_record @@ -1275,17 +1294,19 @@ async def test_receive_problem_report(self): } ) - with mock.patch.object( - V10PresentationExchange, "save", autospec=True - ) as save_ex, mock.patch.object( - V10PresentationExchange, - "retrieve_by_tag_filter", - mock.CoroutineMock(), - ) as retrieve_ex, mock.patch.object( - self.profile, - "session", - mock.MagicMock(return_value=self.profile.session()), - ) as session: + with ( + mock.patch.object(V10PresentationExchange, "save", autospec=True) as save_ex, + mock.patch.object( + V10PresentationExchange, + "retrieve_by_tag_filter", + mock.CoroutineMock(), + ) as retrieve_ex, + mock.patch.object( + self.profile, + "session", + mock.MagicMock(return_value=self.profile.session()), + ) as session, + ): retrieve_ex.return_value = stored_exchange ret_exchange = await self.manager.receive_problem_report( diff --git a/acapy_agent/protocols/present_proof/v1_0/tests/test_routes.py b/acapy_agent/protocols/present_proof/v1_0/tests/test_routes.py index 5c55474765..28c7930443 100644 --- a/acapy_agent/protocols/present_proof/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/present_proof/v1_0/tests/test_routes.py @@ -300,16 +300,20 @@ async def test_presentation_exchange_retrieve_x(self): async def test_presentation_exchange_send_proposal(self): self.request.json = mock.CoroutineMock() - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ), mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.models.pres_preview.IndyPresPreview", - autospec=True, - ) as mock_preview: + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ), + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.models.pres_preview.IndyPresPreview", + autospec=True, + ) as mock_preview, + ): # Since we are mocking import importlib.reload(test_module) @@ -347,18 +351,22 @@ async def test_presentation_exchange_send_proposal_no_conn_record(self): async def test_presentation_exchange_send_proposal_not_ready(self): self.request.json = mock.CoroutineMock() - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.indy.models.pres_preview.IndyPresPreview", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "messages.presentation_proposal.PresentationProposal" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.indy.models.pres_preview.IndyPresPreview", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "messages.presentation_proposal.PresentationProposal" + ), + autospec=True, ), - autospec=True, ): # Since we are mocking import importlib.reload(test_module) @@ -372,15 +380,19 @@ async def test_presentation_exchange_send_proposal_not_ready(self): async def test_presentation_exchange_send_proposal_x(self): self.request.json = mock.CoroutineMock() - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ), mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.models.pres_preview.IndyPresPreview", - autospec=True, + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ), + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.models.pres_preview.IndyPresPreview", + autospec=True, + ), ): # Since we are mocking import importlib.reload(test_module) @@ -402,26 +414,31 @@ async def test_presentation_exchange_create_request(self): return_value={"comment": "dummy", "proof_request": {}} ) - with mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.models.pres_preview.IndyPresPreview", - autospec=True, - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ) as mock_attach_decorator, mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.models.pres_preview.IndyPresPreview", + autospec=True, + ), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ) as mock_attach_decorator, + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange, mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, ): # Since we are mocking import importlib.reload(test_module) @@ -451,26 +468,31 @@ async def test_presentation_exchange_create_request_x(self): return_value={"comment": "dummy", "proof_request": {}} ) - with mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.models.pres_preview.IndyPresPreview", - autospec=True, - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.models.pres_preview.IndyPresPreview", + autospec=True, + ), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ), + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, ), - autospec=True, - ), mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, ): # Since we are mocking import importlib.reload(test_module) @@ -496,30 +518,36 @@ async def test_presentation_exchange_send_free_request(self): } ) - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch( - "acapy_agent.indy.models.pres_preview.IndyPresPreview", - autospec=True, - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ) as mock_attach_decorator, mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch( + "acapy_agent.indy.models.pres_preview.IndyPresPreview", + autospec=True, + ), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ) as mock_attach_decorator, + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -592,28 +620,32 @@ async def test_presentation_exchange_send_free_request_x(self): } ) - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ) as mock_attach_decorator, mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, + ), + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ) as mock_attach_decorator, + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, ), - autospec=True, ): # Since we are mocking import importlib.reload(test_module) @@ -655,27 +687,33 @@ async def test_presentation_exchange_send_bound_request(self): ), ) - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ) as mock_presentation_request, mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange", - autospec=True, - ) as mock_presentation_exchange: + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, + ), + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object( + test_module, "PresentationRequest", autospec=True + ) as mock_presentation_request, + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange", + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -712,29 +750,33 @@ async def test_presentation_exchange_send_bound_request_not_found(self): self.request.json = mock.CoroutineMock(return_value={"trace": False}) self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ), mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, + ), + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -756,29 +798,33 @@ async def test_presentation_exchange_send_bound_request_not_ready(self): self.request.json = mock.CoroutineMock(return_value={"trace": False}) self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ), mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, + ), + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -839,29 +885,33 @@ async def test_presentation_exchange_send_bound_request_x(self): self.request.json = mock.CoroutineMock(return_value={"trace": False}) self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -921,21 +971,24 @@ async def test_presentation_exchange_send_presentation(self): ), ) - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" - ), - autospec=True, - ) as mock_presentation_exchange: + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -987,29 +1040,33 @@ async def test_presentation_exchange_send_presentation_not_found(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ), mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, + ), + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -1031,29 +1088,33 @@ async def test_presentation_exchange_send_presentation_not_ready(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ), mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, + ), + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -1105,29 +1166,33 @@ async def test_presentation_exchange_send_presentation_x(self): ) self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch.object( - test_module, "IndyPresPreview", autospec=True - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch.object(test_module, "IndyPresPreview", autospec=True), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -1158,30 +1223,36 @@ async def test_presentation_exchange_send_presentation_x(self): async def test_presentation_exchange_verify_presentation(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - "acapy_agent.indy.util.generate_pr_nonce", - autospec=True, - ), mock.patch( - "acapy_agent.indy.models.pres_preview.IndyPresPreview", - autospec=True, - ), mock.patch.object( - test_module, "PresentationRequest", autospec=True - ), mock.patch( - "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + "acapy_agent.indy.util.generate_pr_nonce", + autospec=True, ), - autospec=True, - ) as mock_presentation_exchange: + mock.patch( + "acapy_agent.indy.models.pres_preview.IndyPresPreview", + autospec=True, + ), + mock.patch.object(test_module, "PresentationRequest", autospec=True), + mock.patch( + "acapy_agent.messaging.decorators.attach_decorator.AttachDecorator", + autospec=True, + ), + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -1262,19 +1333,23 @@ async def test_presentation_exchange_verify_presentation_x(self): ), ) - with mock.patch( - "acapy_agent.connections.models.conn_record.ConnRecord", - autospec=True, - ) as mock_connection_record, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ) as mock_presentation_manager, mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" - ), - autospec=True, - ) as mock_presentation_exchange: + with ( + mock.patch( + "acapy_agent.connections.models.conn_record.ConnRecord", + autospec=True, + ) as mock_connection_record, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, + ) as mock_presentation_manager, + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_presentation_exchange, + ): # Since we are mocking import importlib.reload(test_module) @@ -1314,20 +1389,23 @@ async def test_presentation_exchange_problem_report(self): self.request.match_info = {"pres_ex_id": "dummy"} magic_report = mock.MagicMock() - with mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_pres_ex, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, ), - autospec=True, - ) as mock_pres_ex, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ) as mock_problem_report, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + mock.patch.object( + test_module, "problem_report_for_record", mock.MagicMock() + ) as mock_problem_report, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): # Since we are mocking import importlib.reload(test_module) @@ -1347,16 +1425,19 @@ async def test_presentation_exchange_problem_report_bad_pres_ex_id(self): ) self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ), mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, ), - autospec=True, - ) as mock_pres_ex: + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_pres_ex, + ): # Since we are mocking import importlib.reload(test_module) @@ -1371,18 +1452,21 @@ async def test_presentation_exchange_problem_report_x(self): self.request.json = mock.CoroutineMock() self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch( - ( - "acapy_agent.protocols.present_proof.v1_0." - "models.presentation_exchange.V10PresentationExchange" + with ( + mock.patch( + ( + "acapy_agent.protocols.present_proof.v1_0." + "models.presentation_exchange.V10PresentationExchange" + ), + autospec=True, + ) as mock_pres_ex, + mock.patch( + "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", + autospec=True, ), - autospec=True, - ) as mock_pres_ex, mock.patch( - "acapy_agent.protocols.present_proof.v1_0.manager.PresentationManager", - autospec=True, - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ), mock.patch.object(test_module.web, "json_response"): + mock.patch.object(test_module, "problem_report_for_record", mock.MagicMock()), + mock.patch.object(test_module.web, "json_response"), + ): # Since we are mocking import importlib.reload(test_module) mock_pres_ex.retrieve_by_id = mock.CoroutineMock( diff --git a/acapy_agent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py b/acapy_agent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py index 820fe2771e..2d0f73d59d 100644 --- a/acapy_agent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py +++ b/acapy_agent/protocols/present_proof/v2_0/formats/dif/tests/test_handler.py @@ -727,17 +727,20 @@ async def test_create_pres_prover_proof_spec_with_record_ids(self): ) self.profile.context.injector.bind_instance(VCHolder, mock_holder) - with mock.patch.object( - DIFPresExchHandler, - "create_vp", - mock.CoroutineMock(), - ) as mock_create_vp, mock.patch.object( - VCHolder, - "search_credentials", - mock.CoroutineMock( - return_value=mock.MagicMock( - fetch=mock.CoroutineMock(return_value=cred_list) - ) + with ( + mock.patch.object( + DIFPresExchHandler, + "create_vp", + mock.CoroutineMock(), + ) as mock_create_vp, + mock.patch.object( + VCHolder, + "search_credentials", + mock.CoroutineMock( + return_value=mock.MagicMock( + fetch=mock.CoroutineMock(return_value=cred_list) + ) + ), ), ): mock_create_vp.return_value = DIF_PRES @@ -2211,11 +2214,12 @@ async def test_verify_received_pres_fail_schema_filter(self): auto_present=True, error_msg="error", ) - with mock.patch.object( - test_module.LOGGER, "error", mock.MagicMock() - ) as mock_log_err, mock.patch.object( - jsonld, "expand", mock.MagicMock() - ) as mock_jsonld_expand: + with ( + mock.patch.object( + test_module.LOGGER, "error", mock.MagicMock() + ) as mock_log_err, + mock.patch.object(jsonld, "expand", mock.MagicMock()) as mock_jsonld_expand, + ): mock_jsonld_expand.return_value = EXPANDED_CRED_FHIR_TYPE_2 await self.handler.receive_pres(message=dif_pres, pres_ex_record=record) mock_log_err.assert_called_once() diff --git a/acapy_agent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py b/acapy_agent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py index 0168fa6a36..bbce190491 100644 --- a/acapy_agent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py +++ b/acapy_agent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py @@ -220,11 +220,14 @@ async def test_called(self): auto_present=True, ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance ) @@ -261,11 +264,14 @@ async def test_called_not_found(self): auto_present=True, ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( side_effect=StorageNotFoundError ) @@ -304,11 +310,14 @@ async def test_called_auto_present_x_indy(self): save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock_px_rec @@ -347,11 +356,14 @@ async def test_called_auto_present_x_anoncreds(self): save_error_state=mock.CoroutineMock(), ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock_px_rec @@ -389,11 +401,14 @@ async def test_called_auto_present_indy(self): auto_present=True, ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock_px_rec @@ -463,11 +478,14 @@ async def test_called_auto_present_anoncreds(self): auto_present=True, ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock_px_rec @@ -526,11 +544,14 @@ async def test_called_auto_present_dif(self): pres_proposal=pres_proposal, auto_present=True, ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -585,11 +606,14 @@ async def test_called_auto_present_no_preview_indy(self): ) self.request_context.injector.bind_instance(IndyHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -644,11 +668,14 @@ async def test_called_auto_present_no_preview_anoncreds(self): ) self.request_context.injector.bind_instance(AnonCredsHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -704,11 +731,14 @@ async def test_called_auto_present_pred_no_match_indy(self): ) self.request_context.injector.bind_instance(IndyHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock_px_rec @@ -760,11 +790,14 @@ async def test_called_auto_present_pred_no_match_anoncreds(self): ) self.request_context.injector.bind_instance(AnonCredsHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=mock_px_rec @@ -810,11 +843,14 @@ async def test_called_auto_present_pred_single_match_indy(self): ) self.request_context.injector.bind_instance(IndyHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -864,11 +900,14 @@ async def test_called_auto_present_pred_single_match_anoncreds(self): ) self.request_context.injector.bind_instance(AnonCredsHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -923,11 +962,14 @@ async def test_called_auto_present_pred_multi_match_indy(self): ) self.request_context.injector.bind_instance(IndyHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -982,11 +1024,14 @@ async def test_called_auto_present_pred_multi_match_anoncreds(self): ) self.request_context.injector.bind_instance(AnonCredsHolder, self.mock_holder) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -1084,11 +1129,14 @@ async def test_called_auto_present_multi_cred_match_reft_indy(self): pres_proposal=pres_proposal.serialize(), auto_present=True, ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance @@ -1186,11 +1234,14 @@ async def test_called_auto_present_multi_cred_match_reft_anoncreds(self): pres_proposal=pres_proposal.serialize(), auto_present=True, ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + ): mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = mock.CoroutineMock( return_value=px_rec_instance diff --git a/acapy_agent/protocols/present_proof/v2_0/models/tests/test_record.py b/acapy_agent/protocols/present_proof/v2_0/models/tests/test_record.py index ee0255e9a6..eafd51d68c 100644 --- a/acapy_agent/protocols/present_proof/v2_0/models/tests/test_record.py +++ b/acapy_agent/protocols/present_proof/v2_0/models/tests/test_record.py @@ -124,11 +124,12 @@ async def test_save_error_state(self): record.state = V20PresExRecord.STATE_PROPOSAL_RECEIVED await record.save(session) - with mock.patch.object( - record, "save", mock.CoroutineMock() - ) as mock_save, mock.patch.object( - test_module.LOGGER, "exception", mock.MagicMock() - ) as mock_log_exc: + with ( + mock.patch.object(record, "save", mock.CoroutineMock()) as mock_save, + mock.patch.object( + test_module.LOGGER, "exception", mock.MagicMock() + ) as mock_log_exc, + ): mock_save.side_effect = test_module.StorageError() await record.save_error_state(session, reason="testing") mock_log_exc.assert_called_once() diff --git a/acapy_agent/protocols/present_proof/v2_0/tests/test_manager.py b/acapy_agent/protocols/present_proof/v2_0/tests/test_manager.py index 94a6ee2966..ccc823dabf 100644 --- a/acapy_agent/protocols/present_proof/v2_0/tests/test_manager.py +++ b/acapy_agent/protocols/present_proof/v2_0/tests/test_manager.py @@ -512,9 +512,10 @@ async def test_create_exchange_for_proposal(self): ] ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object(V20PresProposal, "serialize", autospec=True): + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object(V20PresProposal, "serialize", autospec=True), + ): px_rec = await self.manager.create_exchange_for_proposal( CONN_ID, proposal, @@ -704,11 +705,14 @@ async def test_receive_pres_catch_diferror(self): pres_request=pres_req.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object( - DIFPresFormatHandler, "receive_pres", autospec=True - ) as mock_receive_pres, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object( + DIFPresFormatHandler, "receive_pres", autospec=True + ) as mock_receive_pres, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): mock_receive_pres.return_value = False retrieve_ex.side_effect = [px_rec] with self.assertRaises(V20PresManagerError) as context: @@ -776,13 +780,15 @@ async def test_create_pres_indy(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -830,15 +836,18 @@ async def test_create_pres_indy_and_dif(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator_indy, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr, mock.patch.object( - DIFPresFormatHandler, "create_pres", autospec=True - ) as mock_create_pres: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator_indy, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + mock.patch.object( + DIFPresFormatHandler, "create_pres", autospec=True + ) as mock_create_pres, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator_indy.data_base64 = mock.MagicMock( @@ -891,17 +900,20 @@ async def test_create_pres_proof_req_non_revoc_interval_none(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -943,13 +955,15 @@ async def test_create_pres_self_asserted(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -1021,13 +1035,15 @@ async def test_create_pres_no_revocation(self): self.holder.create_presentation = mock.CoroutineMock(return_value="{}") self.profile.context.injector.bind_instance(IndyHolder, self.holder) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module.LOGGER, "info", mock.MagicMock() - ) as mock_log_info: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module.LOGGER, "info", mock.MagicMock() + ) as mock_log_info, + ): mock_attach_decorator.data_base64 = mock.MagicMock( return_value=mock_attach_decorator ) @@ -1116,12 +1132,15 @@ async def test_create_pres_bad_revoc_state(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr, mock.patch.object( - test_indy_util_module.LOGGER, "error", mock.MagicMock() + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + mock.patch.object(test_indy_util_module.LOGGER, "error", mock.MagicMock()), ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) @@ -1203,13 +1222,15 @@ async def test_create_pres_multi_matching_proposal_creds_names(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -1287,9 +1308,12 @@ async def test_no_matching_creds_indy_handler(self): get_creds = mock.CoroutineMock(return_value=()) self.holder.get_credentials_for_presentation_request_by_referent = get_creds - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + ): mock_attach_decorator.data_base64 = mock.MagicMock( return_value=mock_attach_decorator ) @@ -1352,11 +1376,12 @@ async def test_receive_pres(self): assert by_format.get("pres_proposal").get("indy") == INDY_PROOF_REQ_NAME assert by_format.get("pres_request").get("indy") == INDY_PROOF_REQ_NAME - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1421,11 +1446,12 @@ async def test_receive_pres_receive_pred_value_mismatch_punt_to_indy(self): assert by_format.get("pres_proposal").get("indy") == INDY_PROOF_REQ_NAME assert by_format.get("pres_request").get("indy") == indy_proof_req - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1497,11 +1523,12 @@ async def test_receive_pres_indy_no_predicate_restrictions(self): assert by_format.get("pres_request").get("indy") == indy_proof_req - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1569,11 +1596,12 @@ async def test_receive_pres_indy_no_attr_restrictions(self): assert by_format.get("pres_request").get("indy") == indy_proof_req - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1630,9 +1658,12 @@ async def test_receive_pres_bait_and_switch_attr_name(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1678,9 +1709,12 @@ async def test_receive_pres_bait_and_switch_attr_name(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1733,9 +1767,12 @@ async def test_receive_pres_bait_and_switch_attr_names(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1785,9 +1822,12 @@ async def test_receive_pres_bait_and_switch_attr_names(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1838,9 +1878,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1890,9 +1933,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1942,9 +1988,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1994,9 +2043,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -2036,11 +2088,14 @@ async def test_verify_pres(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + ): px_rec_out = await self.manager.verify_pres(px_rec_in) save_ex.assert_called_once() @@ -2096,32 +2151,40 @@ async def test_verify_pres_indy_and_dif(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + ): px_rec_out = await self.manager.verify_pres(px_rec_in) save_ex.assert_called_once() assert px_rec_out.state == (V20PresExRecord.STATE_DONE) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch( - "acapy_agent.vc.vc_ld.verify.verify_presentation", - mock.CoroutineMock( - return_value=PresentationVerificationResult(verified=False) + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), ), - ), mock.patch.object( - IndyVerifier, - "verify_presentation", - mock.CoroutineMock( - return_value=PresentationVerificationResult(verified=True) + mock.patch( + "acapy_agent.vc.vc_ld.verify.verify_presentation", + mock.CoroutineMock( + return_value=PresentationVerificationResult(verified=False) + ), + ), + mock.patch.object( + IndyVerifier, + "verify_presentation", + mock.CoroutineMock( + return_value=PresentationVerificationResult(verified=True) + ), ), - ), mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex: + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + ): px_rec_out = await self.manager.verify_pres(px_rec_in) save_ex.assert_called_once() assert px_rec_out.state == (V20PresExRecord.STATE_DONE) @@ -2167,11 +2230,12 @@ async def test_receive_pres_ack_a(self): px_rec_dummy = V20PresExRecord() message = mock.MagicMock() - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy px_rec_out = await self.manager.receive_pres_ack(message, conn_record) save_ex.assert_called_once() @@ -2184,11 +2248,12 @@ async def test_receive_pres_ack_b(self): px_rec_dummy = V20PresExRecord() message = mock.MagicMock(_verification_result="true") - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy px_rec_out = await self.manager.receive_pres_ack(message, conn_record) save_ex.assert_called_once() @@ -2213,17 +2278,19 @@ async def test_receive_problem_report(self): } ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, - "retrieve_by_tag_filter", - mock.CoroutineMock(), - ) as retrieve_ex, mock.patch.object( - self.profile, - "session", - mock.MagicMock(return_value=self.profile.session()), - ) as session: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, + "retrieve_by_tag_filter", + mock.CoroutineMock(), + ) as retrieve_ex, + mock.patch.object( + self.profile, + "session", + mock.MagicMock(return_value=self.profile.session()), + ) as session, + ): retrieve_ex.return_value = stored_exchange await self.manager.receive_problem_report(problem, connection_id) diff --git a/acapy_agent/protocols/present_proof/v2_0/tests/test_manager_anoncreds.py b/acapy_agent/protocols/present_proof/v2_0/tests/test_manager_anoncreds.py index 78d93e01a7..9f88377968 100644 --- a/acapy_agent/protocols/present_proof/v2_0/tests/test_manager_anoncreds.py +++ b/acapy_agent/protocols/present_proof/v2_0/tests/test_manager_anoncreds.py @@ -518,9 +518,10 @@ async def test_create_exchange_for_proposal(self): ] ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object(V20PresProposal, "serialize", autospec=True): + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object(V20PresProposal, "serialize", autospec=True), + ): px_rec = await self.manager.create_exchange_for_proposal( CONN_ID, proposal, @@ -712,11 +713,14 @@ async def test_receive_pres_catch_diferror(self): pres_request=pres_req.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object( - DIFPresFormatHandler, "receive_pres", autospec=True - ) as mock_receive_pres, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object( + DIFPresFormatHandler, "receive_pres", autospec=True + ) as mock_receive_pres, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): mock_receive_pres.return_value = False retrieve_ex.side_effect = [px_rec] with self.assertRaises(V20PresManagerError) as context: @@ -787,13 +791,15 @@ async def test_create_pres_indy(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -842,15 +848,18 @@ async def test_create_pres_indy_and_dif(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator_indy, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr, mock.patch.object( - DIFPresFormatHandler, "create_pres", autospec=True - ) as mock_create_pres: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator_indy, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + mock.patch.object( + DIFPresFormatHandler, "create_pres", autospec=True + ) as mock_create_pres, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator_indy.data_base64 = mock.MagicMock( @@ -904,17 +913,20 @@ async def test_create_pres_proof_req_non_revoc_interval_none(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -957,13 +969,15 @@ async def test_create_pres_self_asserted(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -1036,13 +1050,15 @@ async def test_create_pres_no_revocation(self): self.holder.create_presentation = mock.AsyncMock(return_value="{}") self.profile.context.injector.bind_instance(AnonCredsHolder, self.holder) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module.LOGGER, "info", mock.MagicMock() - ) as mock_log_info: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module.LOGGER, "info", mock.MagicMock() + ) as mock_log_info, + ): mock_attach_decorator.data_base64 = mock.MagicMock( return_value=mock_attach_decorator ) @@ -1132,12 +1148,15 @@ async def test_create_pres_bad_revoc_state(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr, mock.patch.object( - test_indy_util_module.LOGGER, "error", mock.MagicMock() + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + mock.patch.object(test_indy_util_module.LOGGER, "error", mock.MagicMock()), ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) @@ -1220,13 +1239,15 @@ async def test_create_pres_multi_matching_proposal_creds_names(self): return_value="/tmp/sample/tails/path" ) ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator, mock.patch.object( - test_indy_util_module, "RevocationRegistry", autospec=True - ) as mock_rr: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + mock.patch.object( + test_indy_util_module, "RevocationRegistry", autospec=True + ) as mock_rr, + ): mock_rr.from_definition = mock.MagicMock(return_value=more_magic_rr) mock_attach_decorator.data_base64 = mock.MagicMock( @@ -1304,9 +1325,12 @@ async def test_no_matching_creds_indy_handler(self): get_creds = mock.CoroutineMock(return_value=()) self.holder.get_credentials_for_presentation_request_by_referent = get_creds - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - test_indy_handler, "AttachDecorator", autospec=True - ) as mock_attach_decorator: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + test_indy_handler, "AttachDecorator", autospec=True + ) as mock_attach_decorator, + ): mock_attach_decorator.data_base64 = mock.MagicMock( return_value=mock_attach_decorator ) @@ -1375,11 +1399,12 @@ async def test_receive_pres(self): assert by_format.get("pres_proposal").get("anoncreds") == ANONCREDS_PROOF_REQ_NAME assert by_format.get("pres_request").get("anoncreds") == ANONCREDS_PROOF_REQ_NAME - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1448,11 +1473,12 @@ async def test_receive_pres_receive_pred_value_mismatch_punt_to_indy(self): assert by_format.get("pres_proposal").get("anoncreds") == ANONCREDS_PROOF_REQ_NAME assert by_format.get("pres_request").get("anoncreds") == indy_proof_req - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1528,11 +1554,12 @@ async def test_receive_pres_indy_no_predicate_restrictions(self): assert by_format.get("pres_request").get("anoncreds") == indy_proof_req - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1602,11 +1629,12 @@ async def test_receive_pres_indy_no_attr_restrictions(self): assert by_format.get("pres_request").get("anoncreds") == indy_proof_req - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.side_effect = [px_rec_dummy] px_rec_out = await self.manager.receive_pres(pres, connection_record, None) assert retrieve_ex.call_args.args[1] == {"thread_id": "thread-id"} @@ -1667,9 +1695,12 @@ async def test_receive_pres_bait_and_switch_attr_name(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1723,9 +1754,12 @@ async def test_receive_pres_bait_and_switch_attr_name(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1782,9 +1816,12 @@ async def test_receive_pres_bait_and_switch_attr_names(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1840,9 +1877,12 @@ async def test_receive_pres_bait_and_switch_attr_names(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1897,9 +1937,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -1957,9 +2000,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -2017,9 +2063,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -2077,9 +2126,12 @@ async def test_receive_pres_bait_and_switch_pred(self): pres_request=pres_request.serialize(), pres=pres_x.serialize(), ) - with mock.patch.object(V20PresExRecord, "save", autospec=True), mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True), + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy with self.assertRaises(V20PresFormatHandlerError) as context: await self.manager.receive_pres(pres_x, connection_record, None) @@ -2124,11 +2176,14 @@ async def test_verify_pres(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + ): px_rec_out = await self.manager.verify_pres(px_rec_in) save_ex.assert_called_once() @@ -2187,32 +2242,40 @@ async def test_verify_pres_indy_and_dif(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), + ), + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + ): px_rec_out = await self.manager.verify_pres(px_rec_in) save_ex.assert_called_once() assert px_rec_out.state == (V20PresExRecord.STATE_DONE) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), - ), mock.patch( - "acapy_agent.vc.vc_ld.verify.verify_presentation", - mock.CoroutineMock( - return_value=PresentationVerificationResult(verified=False) + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=("test_ledger_id", self.ledger)), ), - ), mock.patch.object( - AnonCredsVerifier, - "verify_presentation", - mock.CoroutineMock( - return_value=PresentationVerificationResult(verified=True) + mock.patch( + "acapy_agent.vc.vc_ld.verify.verify_presentation", + mock.CoroutineMock( + return_value=PresentationVerificationResult(verified=False) + ), ), - ), mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex: + mock.patch.object( + AnonCredsVerifier, + "verify_presentation", + mock.CoroutineMock( + return_value=PresentationVerificationResult(verified=True) + ), + ), + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + ): px_rec_out = await self.manager.verify_pres(px_rec_in) save_ex.assert_called_once() assert px_rec_out.state == (V20PresExRecord.STATE_DONE) @@ -2258,11 +2321,12 @@ async def test_receive_pres_ack_a(self): px_rec_dummy = V20PresExRecord() message = mock.MagicMock() - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy px_rec_out = await self.manager.receive_pres_ack(message, conn_record) save_ex.assert_called_once() @@ -2275,11 +2339,12 @@ async def test_receive_pres_ack_b(self): px_rec_dummy = V20PresExRecord() message = mock.MagicMock(_verification_result="true") - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, "retrieve_by_tag_filter", autospec=True - ) as retrieve_ex: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, "retrieve_by_tag_filter", autospec=True + ) as retrieve_ex, + ): retrieve_ex.return_value = px_rec_dummy px_rec_out = await self.manager.receive_pres_ack(message, conn_record) save_ex.assert_called_once() @@ -2304,17 +2369,19 @@ async def test_receive_problem_report(self): } ) - with mock.patch.object( - V20PresExRecord, "save", autospec=True - ) as save_ex, mock.patch.object( - V20PresExRecord, - "retrieve_by_tag_filter", - mock.CoroutineMock(), - ) as retrieve_ex, mock.patch.object( - self.profile, - "session", - mock.MagicMock(return_value=self.profile.session()), - ) as session: + with ( + mock.patch.object(V20PresExRecord, "save", autospec=True) as save_ex, + mock.patch.object( + V20PresExRecord, + "retrieve_by_tag_filter", + mock.CoroutineMock(), + ) as retrieve_ex, + mock.patch.object( + self.profile, + "session", + mock.MagicMock(return_value=self.profile.session()), + ) as session, + ): retrieve_ex.return_value = stored_exchange await self.manager.receive_problem_report(problem, connection_id) diff --git a/acapy_agent/protocols/present_proof/v2_0/tests/test_routes.py b/acapy_agent/protocols/present_proof/v2_0/tests/test_routes.py index b1fb15ef7f..7d120b0052 100644 --- a/acapy_agent/protocols/present_proof/v2_0/tests/test_routes.py +++ b/acapy_agent/protocols/present_proof/v2_0/tests/test_routes.py @@ -256,11 +256,14 @@ async def test_present_proof_list(self): mock_pres_ex_rec_inst = mock.MagicMock( serialize=mock.MagicMock(return_value={"thread_id": "sample-thread-id"}) ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.query = mock.CoroutineMock( return_value=[mock_pres_ex_rec_inst] ) @@ -339,11 +342,14 @@ async def test_present_proof_credentials_list_single_referent(self): ) self.profile.context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.return_value = mock.MagicMock( retrieve_by_id=mock.CoroutineMock() ) @@ -365,11 +371,14 @@ async def test_present_proof_credentials_list_multiple_referents(self): ) self.profile.context.injector.bind_instance(IndyHolder, mock_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.return_value = mock.MagicMock( retrieve_by_id=mock.CoroutineMock() ) @@ -429,11 +438,14 @@ async def test_present_proof_credentials_list_dif(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -506,11 +518,14 @@ async def test_present_proof_credentials_list_dif_one_of_filter(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -579,11 +594,14 @@ async def test_present_proof_credentials_dif_no_tag_query(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -652,11 +670,14 @@ async def test_present_proof_credentials_single_ldp_vp_claim_format(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -725,11 +746,14 @@ async def test_present_proof_credentials_double_ldp_vp_claim_format(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -791,10 +815,11 @@ async def test_present_proof_credentials_single_ldp_vp_error(self): mock_vc_holder.search_credentials = mock.MagicMock() self.profile.context.injector.bind_instance(VCHolder, mock_vc_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -851,10 +876,11 @@ async def test_present_proof_credentials_double_ldp_vp_error(self): mock_vc_holder.search_credentials = mock.MagicMock() self.profile.context.injector.bind_instance(VCHolder, mock_vc_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -908,10 +934,11 @@ async def test_present_proof_credentials_list_limit_disclosure_no_bbs(self): mock_vc_holder.search_credentials = mock.MagicMock() self.profile.context.injector.bind_instance(VCHolder, mock_vc_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -968,10 +995,11 @@ async def test_present_proof_credentials_no_ldp_vp(self): mock_vc_holder.search_credentials = mock.MagicMock() self.profile.context.injector.bind_instance(VCHolder, mock_vc_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -1034,11 +1062,14 @@ async def test_present_proof_credentials_list_schema_uri(self): ) self.profile.context.injector.bind_instance(VCHolder, mock_vc_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) mock_response.assert_called_once_with( @@ -1097,10 +1128,11 @@ async def test_present_proof_credentials_list_dif_error(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): with self.assertRaises(test_module.web.HTTPBadRequest): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record @@ -1109,11 +1141,14 @@ async def test_present_proof_credentials_list_dif_error(self): async def test_present_proof_retrieve(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock( serialize=mock.MagicMock( @@ -1165,15 +1200,16 @@ async def test_present_proof_send_proposal(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ), mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object(test_module, "V20PresExRecord", autospec=True), + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_conn_rec.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(is_ready=True) ) @@ -1199,10 +1235,11 @@ async def test_present_proof_send_proposal_no_conn_record(self): async def test_present_proof_send_proposal_not_ready(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresProposal", autospec=True + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object(test_module, "V20PresProposal", autospec=True), ): mock_conn_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(is_ready=False) @@ -1214,11 +1251,12 @@ async def test_present_proof_send_proposal_not_ready(self): async def test_present_proof_send_proposal_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + ): mock_pres_mgr.return_value.create_exchange_for_proposal = mock.CoroutineMock( return_value=mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.StorageError()), @@ -1240,13 +1278,15 @@ async def test_present_proof_create_request(self): } ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec_inst = mock.MagicMock( serialize=mock.MagicMock(return_value={"thread_id": "sample-thread-id"}) ) @@ -1268,11 +1308,13 @@ async def test_present_proof_create_request_x(self): } ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object(test_module.web, "json_response", mock.MagicMock()): + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), + ): mock_pres_mgr_inst = mock.MagicMock( create_exchange_for_request=mock.CoroutineMock( return_value=mock.MagicMock( @@ -1295,17 +1337,19 @@ async def test_present_proof_send_free_request(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ), mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object(test_module, "V20PresExRecord", autospec=True), + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_conn_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_px_rec_inst = mock.MagicMock( serialize=mock.MagicMock({"thread_id": "sample-thread-id"}) @@ -1359,13 +1403,16 @@ async def test_present_proof_send_free_request_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object(test_module, "V20PresExRecord", autospec=True): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object(test_module, "V20PresExRecord", autospec=True), + ): mock_conn_rec_inst = mock.MagicMock() mock_conn_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock_conn_rec_inst @@ -1401,15 +1448,20 @@ async def test_present_proof_send_bound_request(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1454,11 +1506,14 @@ async def test_present_proof_send_bound_request_not_found(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1492,11 +1547,14 @@ async def test_present_proof_send_bound_request_not_ready(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1580,13 +1638,17 @@ async def test_present_proof_send_bound_request_x(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1634,15 +1696,18 @@ async def test_present_proof_send_presentation(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1685,15 +1750,18 @@ async def test_present_proof_send_presentation_dif(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1758,15 +1826,18 @@ async def test_present_proof_send_presentation_dif_error(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=px_rec_instance ) @@ -1831,11 +1902,14 @@ async def test_present_proof_send_presentation_not_found(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1873,11 +1947,14 @@ async def test_present_proof_send_presentation_not_ready(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1945,13 +2022,18 @@ async def test_present_proof_send_presentation_x(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response"), + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1985,15 +2067,20 @@ async def test_present_proof_send_presentation_x(self): async def test_present_proof_verify_presentation(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PRESENTATION_RECEIVED, @@ -2050,14 +2137,17 @@ async def test_present_proof_verify_presentation_bad_state(self): async def test_present_proof_verify_presentation_x(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", @@ -2095,15 +2185,16 @@ async def test_present_proof_problem_report(self): self.request.match_info = {"pres_ex_id": "dummy"} magic_report = mock.MagicMock() - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ) as mock_problem_report, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "V20PresManager", autospec=True), + mock.patch.object( + test_module, "problem_report_for_record", mock.MagicMock() + ) as mock_problem_report, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(save_error_state=mock.CoroutineMock()) ) @@ -2136,13 +2227,13 @@ async def test_present_proof_problem_report_x(self): ) self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ), mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec: + with ( + mock.patch.object(test_module, "V20PresManager", autospec=True), + mock.patch.object(test_module, "problem_report_for_record", mock.MagicMock()), + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec, + ): mock_px_rec.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageError() ) @@ -2153,11 +2244,14 @@ async def test_present_proof_problem_report_x(self): async def test_present_proof_remove(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock( state=test_module.V20PresExRecord.STATE_DONE, diff --git a/acapy_agent/protocols/present_proof/v2_0/tests/test_routes_anoncreds.py b/acapy_agent/protocols/present_proof/v2_0/tests/test_routes_anoncreds.py index faa4f0f278..4a29ff2b08 100644 --- a/acapy_agent/protocols/present_proof/v2_0/tests/test_routes_anoncreds.py +++ b/acapy_agent/protocols/present_proof/v2_0/tests/test_routes_anoncreds.py @@ -258,11 +258,14 @@ async def test_present_proof_list(self): mock_pres_ex_rec_inst = mock.MagicMock( serialize=mock.MagicMock(return_value={"thread_id": "sample-thread-id"}) ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.query = mock.CoroutineMock( return_value=[mock_pres_ex_rec_inst] ) @@ -349,11 +352,14 @@ async def test_present_proof_credentials_list_single_referent(self): ), ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.return_value = mock.MagicMock( retrieve_by_id=mock.CoroutineMock() ) @@ -379,11 +385,14 @@ async def test_present_proof_credentials_list_multiple_referents(self): ), ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.return_value = mock.MagicMock( retrieve_by_id=mock.CoroutineMock() ) @@ -445,11 +454,14 @@ async def test_present_proof_credentials_list_dif(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -523,11 +535,14 @@ async def test_present_proof_credentials_list_dif_one_of_filter(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -598,11 +613,14 @@ async def test_present_proof_credentials_dif_no_tag_query(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -673,11 +691,14 @@ async def test_present_proof_credentials_single_ldp_vp_claim_format(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -748,11 +769,14 @@ async def test_present_proof_credentials_double_ldp_vp_claim_format(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) @@ -818,10 +842,11 @@ async def test_present_proof_credentials_single_ldp_vp_error(self): ) self.profile.context.injector.bind_instance(VCHolder, mock_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -882,10 +907,11 @@ async def test_present_proof_credentials_double_ldp_vp_error(self): ) self.profile.context.injector.bind_instance(VCHolder, mock_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -943,10 +969,11 @@ async def test_present_proof_credentials_list_limit_disclosure_no_bbs(self): ) self.profile.context.injector.bind_instance(VCHolder, mock_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -1007,10 +1034,11 @@ async def test_present_proof_credentials_no_ldp_vp(self): ) self.profile.context.injector.bind_instance(VCHolder, mock_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record with self.assertRaises(test_module.web.HTTPBadRequest): @@ -1075,11 +1103,14 @@ async def test_present_proof_credentials_list_schema_uri(self): ) self.profile.context.injector.bind_instance(VCHolder, mock_holder) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record await test_module.present_proof_credentials_list(self.request) mock_response.assert_called_once_with( @@ -1139,10 +1170,11 @@ async def test_present_proof_credentials_list_dif_error(self): error_msg=None, ) - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): with self.assertRaises(test_module.web.HTTPBadRequest): mock_pres_ex_rec_cls.retrieve_by_id.return_value = record @@ -1151,11 +1183,14 @@ async def test_present_proof_credentials_list_dif_error(self): async def test_present_proof_retrieve(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_pres_ex_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_pres_ex_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_pres_ex_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock( serialize=mock.MagicMock( @@ -1207,15 +1242,16 @@ async def test_present_proof_send_proposal(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ), mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True) as mock_conn_rec, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + mock.patch.object(test_module, "V20PresExRecord", autospec=True), + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_conn_rec.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(is_ready=True) ) @@ -1241,10 +1277,11 @@ async def test_present_proof_send_proposal_no_conn_record(self): async def test_present_proof_send_proposal_not_ready(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresProposal", autospec=True + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object(test_module, "V20PresProposal", autospec=True), ): mock_conn_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(is_ready=False) @@ -1256,11 +1293,12 @@ async def test_present_proof_send_proposal_not_ready(self): async def test_present_proof_send_proposal_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ), mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr: + with ( + mock.patch.object(test_module, "ConnRecord", autospec=True), + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr, + ): mock_pres_mgr.return_value.create_exchange_for_proposal = mock.CoroutineMock( return_value=mock.MagicMock( serialize=mock.MagicMock(side_effect=test_module.StorageError()), @@ -1282,13 +1320,15 @@ async def test_present_proof_create_request(self): } ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec_inst = mock.MagicMock( serialize=mock.MagicMock(return_value={"thread_id": "sample-thread-id"}) ) @@ -1310,11 +1350,13 @@ async def test_present_proof_create_request_x(self): } ) - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object(test_module.web, "json_response", mock.MagicMock()): + with ( + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), + ): mock_pres_mgr_inst = mock.MagicMock( create_exchange_for_request=mock.CoroutineMock( return_value=mock.MagicMock( @@ -1337,17 +1379,19 @@ async def test_present_proof_send_free_request(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ), mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object(test_module, "V20PresExRecord", autospec=True), + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_conn_rec_cls.retrieve_by_id = mock.CoroutineMock() mock_px_rec_inst = mock.MagicMock( serialize=mock.MagicMock({"thread_id": "sample-thread-id"}) @@ -1401,13 +1445,16 @@ async def test_present_proof_send_free_request_x(self): } ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresRequest", autospec=True - ), mock.patch.object(test_module, "V20PresExRecord", autospec=True): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object(test_module, "V20PresRequest", autospec=True), + mock.patch.object(test_module, "V20PresExRecord", autospec=True), + ): mock_conn_rec_inst = mock.MagicMock() mock_conn_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=mock_conn_rec_inst @@ -1443,15 +1490,20 @@ async def test_present_proof_send_bound_request(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1496,11 +1548,14 @@ async def test_present_proof_send_bound_request_not_found(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1534,11 +1589,14 @@ async def test_present_proof_send_bound_request_not_ready(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1622,13 +1680,17 @@ async def test_present_proof_send_bound_request_x(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PROPOSAL_RECEIVED, @@ -1676,15 +1738,18 @@ async def test_present_proof_send_presentation(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1727,15 +1792,18 @@ async def test_present_proof_send_presentation_dif(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1800,15 +1868,18 @@ async def test_present_proof_send_presentation_dif_error(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec_cls.retrieve_by_id = mock.CoroutineMock( return_value=px_rec_instance ) @@ -1873,11 +1944,14 @@ async def test_present_proof_send_presentation_not_found(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1914,11 +1988,14 @@ async def test_present_proof_send_presentation_not_ready(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -1986,13 +2063,18 @@ async def test_present_proof_send_presentation_x(self): ), ) - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response"), + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_REQUEST_RECEIVED, @@ -2026,15 +2108,20 @@ async def test_present_proof_send_presentation_x(self): async def test_present_proof_verify_presentation(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", state=test_module.V20PresExRecord.STATE_PRESENTATION_RECEIVED, @@ -2091,14 +2178,17 @@ async def test_present_proof_verify_presentation_bad_state(self): async def test_present_proof_verify_presentation_x(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "ConnRecord", autospec=True - ) as mock_conn_rec_cls, mock.patch.object( - test_module, "V20PresManager", autospec=True - ) as mock_pres_mgr_cls, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec_cls, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module, "ConnRecord", autospec=True + ) as mock_conn_rec_cls, + mock.patch.object( + test_module, "V20PresManager", autospec=True + ) as mock_pres_mgr_cls, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec_cls, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_px_rec_inst = mock.MagicMock( connection_id="dummy", @@ -2136,15 +2226,16 @@ async def test_present_proof_problem_report(self): self.request.match_info = {"pres_ex_id": "dummy"} magic_report = mock.MagicMock() - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ) as mock_problem_report, mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object(test_module, "V20PresManager", autospec=True), + mock.patch.object( + test_module, "problem_report_for_record", mock.MagicMock() + ) as mock_problem_report, + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_px_rec.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock(save_error_state=mock.CoroutineMock()) ) @@ -2177,13 +2268,13 @@ async def test_present_proof_problem_report_x(self): ) self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20PresManager", autospec=True - ), mock.patch.object( - test_module, "problem_report_for_record", mock.MagicMock() - ), mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec: + with ( + mock.patch.object(test_module, "V20PresManager", autospec=True), + mock.patch.object(test_module, "problem_report_for_record", mock.MagicMock()), + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec, + ): mock_px_rec.retrieve_by_id = mock.CoroutineMock( side_effect=test_module.StorageError() ) @@ -2194,11 +2285,14 @@ async def test_present_proof_problem_report_x(self): async def test_present_proof_remove(self): self.request.match_info = {"pres_ex_id": "dummy"} - with mock.patch.object( - test_module, "V20PresExRecord", autospec=True - ) as mock_px_rec, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as mock_response: + with ( + mock.patch.object( + test_module, "V20PresExRecord", autospec=True + ) as mock_px_rec, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as mock_response, + ): mock_px_rec.retrieve_by_id = mock.CoroutineMock( return_value=mock.MagicMock( state=test_module.V20PresExRecord.STATE_DONE, diff --git a/acapy_agent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py b/acapy_agent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py index 4e3b19f933..73c642c489 100644 --- a/acapy_agent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py +++ b/acapy_agent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py @@ -28,13 +28,15 @@ async def test_handle(self): handler = test_module.ForwardHandler() responder = MockResponder() - with mock.patch.object( - test_module, "RoutingManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module, "ConnectionManager", autospec=True - ) as mock_connection_mgr, mock.patch.object( - self.context.profile, "notify", autospec=True - ) as mock_notify: + with ( + mock.patch.object(test_module, "RoutingManager", autospec=True) as mock_mgr, + mock.patch.object( + test_module, "ConnectionManager", autospec=True + ) as mock_connection_mgr, + mock.patch.object( + self.context.profile, "notify", autospec=True + ) as mock_notify, + ): mock_mgr.return_value.get_recipient = mock.CoroutineMock( return_value=RouteRecord(connection_id="dummy") ) diff --git a/acapy_agent/protocols/trustping/v1_0/tests/test_routes.py b/acapy_agent/protocols/trustping/v1_0/tests/test_routes.py index cf05eae733..6012046e75 100644 --- a/acapy_agent/protocols/trustping/v1_0/tests/test_routes.py +++ b/acapy_agent/protocols/trustping/v1_0/tests/test_routes.py @@ -31,13 +31,15 @@ async def test_connections_send_ping(self): self.request.json = mock.CoroutineMock(return_value={"comment": "some comment"}) self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - test_module, "Ping", mock.MagicMock() - ) as mock_ping, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() - ) as json_response: + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(test_module, "Ping", mock.MagicMock()) as mock_ping, + mock.patch.object( + test_module.web, "json_response", mock.MagicMock() + ) as json_response, + ): mock_ping.return_value = mock.MagicMock(_thread_id="dummy") mock_retrieve.return_value = mock.MagicMock(is_ready=True) result = await test_module.connections_send_ping(self.request) @@ -48,10 +50,11 @@ async def test_connections_send_ping_no_conn(self): self.request.json = mock.CoroutineMock(return_value={"comment": "some comment"}) self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_retrieve.side_effect = test_module.StorageNotFoundError() with self.assertRaises(test_module.web.HTTPNotFound): @@ -61,10 +64,11 @@ async def test_connections_send_ping_not_ready(self): self.request.json = mock.CoroutineMock(return_value={"comment": "some comment"}) self.request.match_info = {"conn_id": "dummy"} - with mock.patch.object( - test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() - ) as mock_retrieve, mock.patch.object( - test_module.web, "json_response", mock.MagicMock() + with ( + mock.patch.object( + test_module.ConnRecord, "retrieve_by_id", mock.CoroutineMock() + ) as mock_retrieve, + mock.patch.object(test_module.web, "json_response", mock.MagicMock()), ): mock_retrieve.return_value = mock.MagicMock(is_ready=False) with self.assertRaises(test_module.web.HTTPBadRequest): diff --git a/acapy_agent/resolver/default/tests/test_legacy_peer.py b/acapy_agent/resolver/default/tests/test_legacy_peer.py index fb7cb8f264..46f18caf8a 100644 --- a/acapy_agent/resolver/default/tests/test_legacy_peer.py +++ b/acapy_agent/resolver/default/tests/test_legacy_peer.py @@ -79,11 +79,10 @@ async def test_supports_x_unknown_did( @pytest.mark.asyncio async def test_resolve(self, resolver: LegacyPeerDIDResolver, profile: Profile): """Test resolve.""" - with mock.patch.object( - test_module, "BaseConnectionManager" - ) as mock_mgr, mock.patch.object( - test_module, "LegacyDocCorrections" - ) as mock_corrections: + with ( + mock.patch.object(test_module, "BaseConnectionManager") as mock_mgr, + mock.patch.object(test_module, "LegacyDocCorrections") as mock_corrections, + ): doc = object() mock_corrections.apply = mock.MagicMock(return_value=doc) mock_mgr.return_value = mock.MagicMock( @@ -102,11 +101,11 @@ async def test_resolve_x_not_found( This should be impossible in practice but still. """ - with mock.patch.object( - test_module, "BaseConnectionManager" - ) as mock_mgr, mock.patch.object( - test_module, "LegacyDocCorrections" - ) as mock_corrections, pytest.raises(test_module.DIDNotFound): + with ( + mock.patch.object(test_module, "BaseConnectionManager") as mock_mgr, + mock.patch.object(test_module, "LegacyDocCorrections") as mock_corrections, + pytest.raises(test_module.DIDNotFound), + ): doc = object mock_corrections.apply = mock.MagicMock(return_value=doc) mock_mgr.return_value = mock.MagicMock( diff --git a/acapy_agent/revocation/models/tests/test_issuer_rev_reg_record.py b/acapy_agent/revocation/models/tests/test_issuer_rev_reg_record.py index 8038414429..12488dd350 100644 --- a/acapy_agent/revocation/models/tests/test_issuer_rev_reg_record.py +++ b/acapy_agent/revocation/models/tests/test_issuer_rev_reg_record.py @@ -178,28 +178,32 @@ async def test_fix_ledger_entry(self, mock_handle): settings={"tails_server_base_url": "http://1.2.3.4:8088"}, ) _test_profile.context.injector.bind_instance(BaseLedger, self.ledger) - with mock.patch.object( - test_module.IssuerCredRevRecord, - "query_by_ids", - mock.CoroutineMock( - return_value=[ - test_module.IssuerCredRevRecord( - record_id=test_module.UUID4_EXAMPLE, - state=test_module.IssuerCredRevRecord.STATE_REVOKED, - cred_ex_id=test_module.UUID4_EXAMPLE, - rev_reg_id=REV_REG_ID, - cred_rev_id="1", - ) - ] + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "query_by_ids", + mock.CoroutineMock( + return_value=[ + test_module.IssuerCredRevRecord( + record_id=test_module.UUID4_EXAMPLE, + state=test_module.IssuerCredRevRecord.STATE_REVOKED, + cred_ex_id=test_module.UUID4_EXAMPLE, + rev_reg_id=REV_REG_ID, + cred_rev_id="1", + ) + ] + ), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_revoc_reg_id", + mock.CoroutineMock(return_value=rec), + ), + mock.patch.object( + test_module, + "generate_ledger_rrrecovery_txn", + mock.CoroutineMock(return_value=rev_reg_delta), ), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_revoc_reg_id", - mock.CoroutineMock(return_value=rec), - ), mock.patch.object( - test_module, - "generate_ledger_rrrecovery_txn", - mock.CoroutineMock(return_value=rev_reg_delta), ): assert ( _test_rev_reg_delta, diff --git a/acapy_agent/revocation/models/tests/test_revocation_registry.py b/acapy_agent/revocation/models/tests/test_revocation_registry.py index 6416d38767..d438a42aa3 100644 --- a/acapy_agent/revocation/models/tests/test_revocation_registry.py +++ b/acapy_agent/revocation/models/tests/test_revocation_registry.py @@ -128,13 +128,11 @@ async def test_retrieve_tails(self): rmtree(TAILS_DIR, ignore_errors=True) more_magic = mock.MagicMock() - with mock.patch.object( - test_module, "Session", autospec=True - ) as mock_session, mock.patch.object( - base58, "b58encode", mock.MagicMock() - ) as mock_b58enc, mock.patch.object( - Path, "is_file", autospec=True - ) as mock_is_file: + with ( + mock.patch.object(test_module, "Session", autospec=True) as mock_session, + mock.patch.object(base58, "b58encode", mock.MagicMock()) as mock_b58enc, + mock.patch.object(Path, "is_file", autospec=True) as mock_is_file, + ): mock_session.return_value.__enter__ = mock.MagicMock(return_value=more_magic) more_magic.get = mock.MagicMock( return_value=mock.MagicMock( diff --git a/acapy_agent/revocation/tests/test_indy.py b/acapy_agent/revocation/tests/test_indy.py index 26a44e35a2..224369b372 100644 --- a/acapy_agent/revocation/tests/test_indy.py +++ b/acapy_agent/revocation/tests/test_indy.py @@ -226,13 +226,16 @@ async def test_get_ledger_registry(self): BaseMultitenantManager, mock.MagicMock(MultitenantManager, autospec=True), ) - with mock.patch.object( - IndyLedgerRequestsExecutor, - "get_ledger_for_identifier", - mock.CoroutineMock(return_value=(None, self.ledger)), - ), mock.patch.object( - RevocationRegistry, "from_definition", mock.MagicMock() - ) as mock_from_def: + with ( + mock.patch.object( + IndyLedgerRequestsExecutor, + "get_ledger_for_identifier", + mock.CoroutineMock(return_value=(None, self.ledger)), + ), + mock.patch.object( + RevocationRegistry, "from_definition", mock.MagicMock() + ) as mock_from_def, + ): result = await self.revoc.get_ledger_registry("dummy2") assert result == mock_from_def.return_value assert "dummy2" in IndyRevocation.REV_REG_CACHE diff --git a/acapy_agent/revocation/tests/test_manager.py b/acapy_agent/revocation/tests/test_manager.py index 7e4d85baf5..3105141cb8 100644 --- a/acapy_agent/revocation/tests/test_manager.py +++ b/acapy_agent/revocation/tests/test_manager.py @@ -59,16 +59,18 @@ async def test_revoke_credential_publish(self): ) self.profile.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_cred_ex_id", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_cred_ex_id", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), ): mock_retrieve.return_value = mock.MagicMock( rev_reg_id="dummy-rr-id", cred_rev_id=CRED_REV_ID @@ -120,16 +122,18 @@ async def test_revoke_credential_notify(self): ) self.profile.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_cred_ex_id", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_cred_ex_id", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), ): mock_retrieve.return_value = mock.MagicMock( rev_reg_id="dummy-rr-id", cred_rev_id=CRED_REV_ID @@ -200,20 +204,23 @@ async def test_revoke_credential_publish_endorser(self): ) self.profile.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_cred_ex_id", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), - ), mock.patch.object( - test_module.ConnRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=conn_record), + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_cred_ex_id", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), + mock.patch.object( + test_module.ConnRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=conn_record), + ), ): mock_retrieve.return_value = mock.MagicMock( rev_reg_id="dummy-rr-id", cred_rev_id=CRED_REV_ID @@ -270,21 +277,24 @@ async def test_revoke_credential_publish_endorser_x(self): ) self.profile.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_cred_ex_id", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), - ), mock.patch.object( - ConnRecord, - "retrieve_by_id", - mock.CoroutineMock( - side_effect=test_module.StorageNotFoundError("no such rec") + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_cred_ex_id", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), + mock.patch.object( + ConnRecord, + "retrieve_by_id", + mock.CoroutineMock( + side_effect=test_module.StorageNotFoundError("no such rec") + ), ), ): mock_retrieve.return_value = mock.MagicMock( @@ -350,12 +360,13 @@ async def test_revoke_credential_pend(self): issuer = mock.MagicMock(IndyIssuer, autospec=True) self.profile.context.injector.bind_instance(IndyIssuer, issuer) - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + with ( + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), ): revoc.return_value.get_issuer_rev_reg_record = mock.CoroutineMock( return_value=mock_issuer_rev_reg_record @@ -420,15 +431,18 @@ async def test_publish_pending_revocations_endorser(self): ) conn_id = conn_record.connection_id assert conn_id is not None - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock( - side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock( + side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + ), ), ): issuer = mock.MagicMock(IndyIssuer, autospec=True) @@ -482,15 +496,18 @@ async def test_publish_pending_revocations_endorser_x(self): clear_pending=mock.CoroutineMock(), ), ] - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock( - side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock( + side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + ), ), ): issuer = mock.MagicMock(IndyIssuer, autospec=True) @@ -531,14 +548,17 @@ async def test_publish_pending_revocations_basic(self): send_entry=mock.CoroutineMock(), clear_pending=mock.CoroutineMock(), ) - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=[mock_issuer_rev_reg_record]), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=[mock_issuer_rev_reg_record]), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), ): issuer = mock.MagicMock(IndyIssuer, autospec=True) issuer.merge_revocation_registry_deltas = mock.CoroutineMock( @@ -588,15 +608,18 @@ async def test_publish_pending_revocations_1_rev_reg_all(self): clear_pending=mock.CoroutineMock(), ), ] - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock( - side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock( + side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + ), ), ): issuer = mock.MagicMock(IndyIssuer, autospec=True) @@ -648,15 +671,18 @@ async def test_publish_pending_revocations_1_rev_reg_some(self): clear_pending=mock.CoroutineMock(), ), ] - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock( - side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock( + side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + ), ), ): issuer = mock.MagicMock(IndyIssuer, autospec=True) diff --git a/acapy_agent/revocation/tests/test_routes.py b/acapy_agent/revocation/tests/test_routes.py index f79a5590f9..97f33c5cc8 100644 --- a/acapy_agent/revocation/tests/test_routes.py +++ b/acapy_agent/revocation/tests/test_routes.py @@ -117,11 +117,12 @@ async def test_revoke(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock() await test_module.revoke(self.request) @@ -137,14 +138,17 @@ async def test_revoke_endorser_no_conn_id_by_cred_ex_id(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module, - "get_endorser_connection_id", - mock.CoroutineMock(return_value="dummy-conn-id"), - ), mock.patch.object(test_module.web, "json_response"), mock.patch.object( - TransactionManager, "create_record", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object( + test_module, + "get_endorser_connection_id", + mock.CoroutineMock(return_value="dummy-conn-id"), + ), + mock.patch.object(test_module.web, "json_response"), + mock.patch.object(TransactionManager, "create_record", mock.CoroutineMock()), ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock( return_value={"result": "..."} @@ -163,15 +167,18 @@ async def test_revoke_endorser_by_cred_ex_id(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ), mock.patch.object( - test_module, - "get_endorser_connection_id", - mock.CoroutineMock(return_value="test_conn_id"), - ), mock.patch.object(TransactionManager, "create_record", mock.CoroutineMock()): + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response"), + mock.patch.object( + test_module, + "get_endorser_connection_id", + mock.CoroutineMock(return_value="test_conn_id"), + ), + mock.patch.object(TransactionManager, "create_record", mock.CoroutineMock()), + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock( return_value={"result": "..."} ) @@ -187,14 +194,17 @@ async def test_revoke_endorser_no_conn_id(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module, - "get_endorser_connection_id", - mock.CoroutineMock(return_value=None), - ), mock.patch.object(test_module.web, "json_response"), mock.patch.object( - TransactionManager, "create_record", mock.CoroutineMock() + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object( + test_module, + "get_endorser_connection_id", + mock.CoroutineMock(return_value=None), + ), + mock.patch.object(test_module.web, "json_response"), + mock.patch.object(TransactionManager, "create_record", mock.CoroutineMock()), ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock( return_value={"result": "..."} @@ -213,15 +223,18 @@ async def test_revoke_endorser(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ), mock.patch.object( - test_module, - "get_endorser_connection_id", - mock.CoroutineMock(return_value="test_conn_id"), - ), mock.patch.object(TransactionManager, "create_record", mock.CoroutineMock()): + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response"), + mock.patch.object( + test_module, + "get_endorser_connection_id", + mock.CoroutineMock(return_value="test_conn_id"), + ), + mock.patch.object(TransactionManager, "create_record", mock.CoroutineMock()), + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock( return_value={"result": "..."} ) @@ -237,12 +250,15 @@ async def test_revoke_endorser_x(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module, - "get_endorser_connection_id", - mock.CoroutineMock(return_value=None), + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object( + test_module, + "get_endorser_connection_id", + mock.CoroutineMock(return_value=None), + ), ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock() with self.assertRaises(test_module.web.HTTPBadRequest): @@ -256,11 +272,12 @@ async def test_revoke_by_cred_ex_id(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock() await test_module.revoke(self.request) @@ -276,9 +293,12 @@ async def test_revoke_not_found(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() ) @@ -289,11 +309,12 @@ async def test_revoke_not_found(self): async def test_publish_revocations(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): pub_pending = mock.CoroutineMock() mock_mgr.return_value.publish_pending_revocations = mock.CoroutineMock( return_value=({}, pub_pending.return_value) @@ -318,20 +339,25 @@ async def test_publish_revocations_x(self): async def test_publish_revocations_endorser(self): self.author_request.json = mock.CoroutineMock(return_value={}) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module, - "get_endorser_connection_id", - mock.CoroutineMock(return_value="dummy-conn-id"), - ), mock.patch.object( - TransactionManager, - "create_record", - mock.CoroutineMock(return_value=TransactionRecord()), - ), mock.patch.object( - TransactionManager, - "create_request", - mock.CoroutineMock(), + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object( + test_module, + "get_endorser_connection_id", + mock.CoroutineMock(return_value="dummy-conn-id"), + ), + mock.patch.object( + TransactionManager, + "create_record", + mock.CoroutineMock(return_value=TransactionRecord()), + ), + mock.patch.object( + TransactionManager, + "create_request", + mock.CoroutineMock(), + ), ): pub_pending = mock.CoroutineMock() mock_mgr.return_value.publish_pending_revocations = mock.CoroutineMock( @@ -385,13 +411,17 @@ async def test_publish_revocations_endorser_exceptions(self): async def test_publish_revocations_endorser_x(self): self.author_request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module, - "get_endorser_connection_id", - mock.CoroutineMock(return_value=None), - ), mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object( + test_module, + "get_endorser_connection_id", + mock.CoroutineMock(return_value=None), + ), + mock.patch.object(test_module.web, "json_response"), + ): pub_pending = mock.CoroutineMock() mock_mgr.return_value.publish_pending_revocations = mock.CoroutineMock( return_value=( @@ -410,11 +440,12 @@ async def test_publish_revocations_endorser_x(self): async def test_clear_pending_revocations(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): clear_pending = mock.CoroutineMock() mock_mgr.return_value.clear_pending_revocations = clear_pending @@ -427,9 +458,12 @@ async def test_clear_pending_revocations(self): async def test_clear_pending_revocations_x(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response"), + ): clear_pending = mock.CoroutineMock(side_effect=test_module.StorageError()) mock_mgr.return_value.clear_pending_revocations = clear_pending @@ -445,11 +479,15 @@ async def test_create_rev_reg(self): } ) - with mock.patch.object(AskarStorage, "find_all_records"), mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object(AskarStorage, "find_all_records"), + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( init_issuer_registry=mock.CoroutineMock( return_value=mock.MagicMock( @@ -472,11 +510,14 @@ async def test_create_rev_reg_no_such_cred_def(self): } ) - with mock.patch.object( - BaseStorage, "find_all_records", autospec=True - ) as mock_find, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + BaseStorage, "find_all_records", autospec=True + ) as mock_find, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_find.return_value = False with self.assertRaises(HTTPNotFound): @@ -492,13 +533,17 @@ async def test_create_rev_reg_no_revo_support(self): } ) - with mock.patch.object( - AskarStorage, "find_all_records", autospec=True - ) as mock_find, mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + AskarStorage, "find_all_records", autospec=True + ) as mock_find, + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_find.return_value = True mock_indy_revoc.return_value = mock.MagicMock( init_issuer_registry=mock.CoroutineMock( @@ -520,11 +565,14 @@ async def test_rev_regs_created(self): "state": test_module.IssuerRevRegRecord.STATE_ACTIVE, } - with mock.patch.object( - test_module.IssuerRevRegRecord, "query", mock.CoroutineMock() - ) as mock_query, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, "query", mock.CoroutineMock() + ) as mock_query, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_query.return_value = [mock.MagicMock(revoc_reg_id="dummy")] result = await test_module.rev_regs_created(self.request) @@ -537,11 +585,14 @@ async def test_get_rev_reg(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -560,11 +611,14 @@ async def test_get_rev_reg_not_found(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( side_effect=test_module.StorageNotFoundError(error_code="dummy") @@ -581,17 +635,21 @@ async def test_get_rev_reg_issued(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_revoc_reg_id", - mock.CoroutineMock(), - ), mock.patch.object( - test_module.IssuerCredRevRecord, - "query_by_ids", - mock.CoroutineMock(), - ) as mock_query, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_revoc_reg_id", + mock.CoroutineMock(), + ), + mock.patch.object( + test_module.IssuerCredRevRecord, + "query_by_ids", + mock.CoroutineMock(), + ) as mock_query, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_query.return_value = [{"...": "..."}, {"...": "..."}] result = await test_module.get_rev_reg_issued_count(self.request) @@ -625,13 +683,16 @@ async def test_get_cred_rev_record(self): "cred_rev_id": CRED_REV_ID, } - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_ids", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_ids", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value="dummy") ) @@ -645,13 +706,16 @@ async def test_get_cred_rev_record_by_cred_ex_id(self): self.request.query = {"cred_ex_id": CRED_EX_ID} - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_cred_ex_id", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_cred_ex_id", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value="dummy") ) @@ -687,11 +751,14 @@ async def test_get_active_rev_reg(self): CRED_DEF_ID = f"{self.test_did}:3:CL:1234:default" self.request.match_info = {"cred_def_id": CRED_DEF_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_active_issuer_rev_reg_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -708,11 +775,14 @@ async def test_get_active_rev_reg_not_found(self): CRED_DEF_ID = f"{self.test_did}:3:CL:1234:default" self.request.match_info = {"cred_def_id": CRED_DEF_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_active_issuer_rev_reg_record=mock.CoroutineMock( side_effect=test_module.StorageNotFoundError(error_code="dummy") @@ -729,11 +799,14 @@ async def test_get_tails_file(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_file_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_file_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( return_value=mock.MagicMock(tails_local_path="dummy") @@ -750,11 +823,14 @@ async def test_get_tails_file_not_found(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_file_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_file_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( side_effect=test_module.StorageNotFoundError(error_code="dummy") @@ -771,11 +847,14 @@ async def test_upload_tails_file_basic(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_upload = mock.CoroutineMock() mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( @@ -841,11 +920,14 @@ async def test_send_rev_reg_def(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -866,11 +948,14 @@ async def test_send_rev_reg_def_not_found(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( side_effect=test_module.StorageNotFoundError(error_code="dummy") @@ -909,11 +994,14 @@ async def test_send_rev_reg_entry(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -933,11 +1021,14 @@ async def test_send_rev_reg_entry_not_found(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( side_effect=test_module.StorageNotFoundError(error_code="dummy") @@ -979,11 +1070,14 @@ async def test_update_rev_reg(self): return_value={"tails_public_uri": f"http://sample.ca:8181/tails/{REV_REG_ID}"} ) - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -1007,11 +1101,14 @@ async def test_update_rev_reg_not_found(self): return_value={"tails_public_uri": f"http://sample.ca:8181/tails/{REV_REG_ID}"} ) - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( side_effect=test_module.StorageNotFoundError(error_code="dummy") @@ -1061,11 +1158,14 @@ async def test_set_rev_reg_state(self): "state": test_module.IssuerRevRegRecord.STATE_ACTIVE, } - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( return_value=mock.MagicMock( @@ -1094,11 +1194,14 @@ async def test_set_rev_reg_state_not_found(self): "state": test_module.IssuerRevRegRecord.STATE_ACTIVE, } - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as mock_indy_revoc, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "IndyRevocation", autospec=True + ) as mock_indy_revoc, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_json_response, + ): mock_indy_revoc.return_value = mock.MagicMock( get_issuer_rev_reg_record=mock.CoroutineMock( side_effect=test_module.StorageNotFoundError(error_code="dummy") diff --git a/acapy_agent/revocation_anoncreds/tests/test_manager.py b/acapy_agent/revocation_anoncreds/tests/test_manager.py index 9c62d37d9d..eeacc02929 100644 --- a/acapy_agent/revocation_anoncreds/tests/test_manager.py +++ b/acapy_agent/revocation_anoncreds/tests/test_manager.py @@ -61,16 +61,18 @@ async def test_revoke_credential_publish(self): ) self.profile.context.injector.bind_instance(AnonCredsIssuer, issuer) - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_cred_ex_id", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_cred_ex_id", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), ): mock_retrieve.return_value = mock.MagicMock( rev_reg_id="dummy-rr-id", cred_rev_id=CRED_REV_ID @@ -139,20 +141,23 @@ async def test_revoke_credential_pend(self): issuer = mock.MagicMock(AnonCredsIssuer, autospec=True) self.profile.context.injector.bind_instance(AnonCredsIssuer, issuer) - with mock.patch.object( - test_module, "IndyRevocation", autospec=True - ) as revoc, mock.patch.object( - self.profile, - "session", - mock.MagicMock(return_value=self.profile.session()), - ) as session, mock.patch.object( - self.profile, - "transaction", - mock.MagicMock(return_value=session.return_value), - ) as session, mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + with ( + mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc, + mock.patch.object( + self.profile, + "session", + mock.MagicMock(return_value=self.profile.session()), + ) as session, + mock.patch.object( + self.profile, + "transaction", + mock.MagicMock(return_value=session.return_value), + ) as session, + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), ): revoc.return_value.get_issuer_rev_reg_record = mock.CoroutineMock( return_value=mock_issuer_rev_reg_record @@ -189,14 +194,17 @@ async def test_publish_pending_revocations_basic(self): send_entry=mock.CoroutineMock(), clear_pending=mock.CoroutineMock(), ) - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=[mock_issuer_rev_reg_record]), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=[mock_issuer_rev_reg_record]), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_record), + ), ): issuer = mock.MagicMock(AnonCredsIssuer, autospec=True) issuer.merge_revocation_registry_deltas = mock.AsyncMock(side_effect=deltas) @@ -245,15 +253,18 @@ async def test_publish_pending_revocations_1_rev_reg_all(self): clear_pending=mock.CoroutineMock(), ), ] - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock( - side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock( + side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + ), ), ): issuer = mock.MagicMock(AnonCredsIssuer, autospec=True) @@ -304,15 +315,18 @@ async def test_publish_pending_revocations_1_rev_reg_some(self): clear_pending=mock.CoroutineMock(), ), ] - with mock.patch.object( - test_module.IssuerRevRegRecord, - "query_by_pending", - mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), - ), mock.patch.object( - test_module.IssuerRevRegRecord, - "retrieve_by_id", - mock.CoroutineMock( - side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + with ( + mock.patch.object( + test_module.IssuerRevRegRecord, + "query_by_pending", + mock.CoroutineMock(return_value=mock_issuer_rev_reg_records), + ), + mock.patch.object( + test_module.IssuerRevRegRecord, + "retrieve_by_id", + mock.CoroutineMock( + side_effect=lambda _, id, **args: mock_issuer_rev_reg_records[id] + ), ), ): issuer = mock.MagicMock(AnonCredsIssuer, autospec=True) diff --git a/acapy_agent/revocation_anoncreds/tests/test_routes.py b/acapy_agent/revocation_anoncreds/tests/test_routes.py index 4fef93761e..6f0ea1577b 100644 --- a/acapy_agent/revocation_anoncreds/tests/test_routes.py +++ b/acapy_agent/revocation_anoncreds/tests/test_routes.py @@ -85,11 +85,12 @@ async def test_revoke(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock() await test_module.revoke(self.request) @@ -104,11 +105,12 @@ async def test_revoke_by_cred_ex_id(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock() await test_module.revoke(self.request) @@ -124,9 +126,12 @@ async def test_revoke_not_found(self): } ) - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object(test_module.web, "json_response"): + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response"), + ): mock_mgr.return_value.revoke_credential = mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() ) @@ -137,11 +142,12 @@ async def test_revoke_not_found(self): async def test_publish_revocations(self): self.request.json = mock.CoroutineMock() - with mock.patch.object( - test_module, "RevocationManager", autospec=True - ) as mock_mgr, mock.patch.object( - test_module.web, "json_response" - ) as mock_response: + with ( + mock.patch.object( + test_module, "RevocationManager", autospec=True + ) as mock_mgr, + mock.patch.object(test_module.web, "json_response") as mock_response, + ): pub_pending = mock.CoroutineMock() mock_mgr.return_value.publish_pending_revocations = pub_pending @@ -168,13 +174,16 @@ async def test_rev_regs_created(self): "state": test_module.IssuerRevRegRecord.STATE_ACTIVE, } - with mock.patch.object( - test_module.AnonCredsRevocation, - "get_created_revocation_registry_definitions", - mock.AsyncMock(), - ) as mock_query, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.AnonCredsRevocation, + "get_created_revocation_registry_definitions", + mock.AsyncMock(), + ) as mock_query, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_query.return_value = ["dummy"] result = await test_module.get_rev_regs(self.request) @@ -188,13 +197,15 @@ async def test_get_rev_reg(self): RECORD_ID = "4ba81d6e-f341-4e37-83d4-6b1d3e25a7bd" self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "AnonCredsRevocation", autospec=True - ) as mock_anon_creds_revoc, mock.patch.object( - test_module, "uuid4", mock.Mock() - ) as mock_uuid, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "AnonCredsRevocation", autospec=True + ) as mock_anon_creds_revoc, + mock.patch.object(test_module, "uuid4", mock.Mock()) as mock_uuid, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_uuid.return_value = RECORD_ID mock_anon_creds_revoc.return_value = mock.MagicMock( get_created_revocation_registry_definition=mock.AsyncMock( @@ -250,11 +261,14 @@ async def test_get_rev_reg_not_found(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module, "AnonCredsRevocation", autospec=True - ) as mock_anon_creds_revoc, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "AnonCredsRevocation", autospec=True + ) as mock_anon_creds_revoc, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_anon_creds_revoc.return_value = mock.MagicMock( get_created_revocation_registry_definition=mock.AsyncMock( return_value=None @@ -271,17 +285,21 @@ async def test_get_rev_reg_issued(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module.AnonCredsRevocation, - "get_created_revocation_registry_definition", - autospec=True, - ) as mock_rev_reg_def, mock.patch.object( - test_module.IssuerCredRevRecord, - "query_by_ids", - mock.CoroutineMock(), - ) as mock_query, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.AnonCredsRevocation, + "get_created_revocation_registry_definition", + autospec=True, + ) as mock_rev_reg_def, + mock.patch.object( + test_module.IssuerCredRevRecord, + "query_by_ids", + mock.CoroutineMock(), + ) as mock_query, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_rev_reg_def.return_value = {} mock_query.return_value = [{}, {}] result = await test_module.get_rev_reg_issued_count(self.request) @@ -316,13 +334,16 @@ async def test_get_cred_rev_record(self): "cred_rev_id": CRED_REV_ID, } - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_ids", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_ids", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value="dummy") ) @@ -336,13 +357,16 @@ async def test_get_cred_rev_record_by_cred_ex_id(self): self.request.query = {"cred_ex_id": CRED_EX_ID} - with mock.patch.object( - test_module.IssuerCredRevRecord, - "retrieve_by_cred_ex_id", - mock.CoroutineMock(), - ) as mock_retrieve, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.IssuerCredRevRecord, + "retrieve_by_cred_ex_id", + mock.CoroutineMock(), + ) as mock_retrieve, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_retrieve.return_value = mock.MagicMock( serialize=mock.MagicMock(return_value="dummy") ) @@ -379,13 +403,16 @@ async def test_get_tails_file(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module.AnonCredsRevocation, - "get_created_revocation_registry_definition", - mock.AsyncMock(), - ) as mock_get_rev_reg, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_file_response: + with ( + mock.patch.object( + test_module.AnonCredsRevocation, + "get_created_revocation_registry_definition", + mock.AsyncMock(), + ) as mock_get_rev_reg, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_file_response, + ): mock_get_rev_reg.return_value = RevRegDef( issuer_id="issuer_id", type="CL_ACCUM", @@ -409,13 +436,16 @@ async def test_get_tails_file_not_found(self): ) self.request.match_info = {"rev_reg_id": REV_REG_ID} - with mock.patch.object( - test_module.AnonCredsRevocation, - "get_created_revocation_registry_definition", - mock.AsyncMock(), - ) as mock_get_rev_reg, mock.patch.object( - test_module.web, "FileResponse", mock.Mock() - ) as mock_file_response: + with ( + mock.patch.object( + test_module.AnonCredsRevocation, + "get_created_revocation_registry_definition", + mock.AsyncMock(), + ) as mock_get_rev_reg, + mock.patch.object( + test_module.web, "FileResponse", mock.Mock() + ) as mock_file_response, + ): mock_get_rev_reg.return_value = None with self.assertRaises(HTTPNotFound): @@ -433,13 +463,15 @@ async def test_set_rev_reg_state(self): "state": test_module.RevRegDefState.STATE_FINISHED, } - with mock.patch.object( - test_module, "AnonCredsRevocation", autospec=True - ) as mock_anon_creds_revoc, mock.patch.object( - test_module, "uuid4", mock.Mock() - ) as mock_uuid, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module, "AnonCredsRevocation", autospec=True + ) as mock_anon_creds_revoc, + mock.patch.object(test_module, "uuid4", mock.Mock()) as mock_uuid, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_uuid.return_value = RECORD_ID mock_anon_creds_revoc.return_value = mock.MagicMock( set_rev_reg_state=mock.AsyncMock(return_value={}), @@ -500,13 +532,16 @@ async def test_set_rev_reg_state_not_found(self): "state": test_module.RevRegDefState.STATE_FINISHED, } - with mock.patch.object( - test_module.AnonCredsRevocation, - "get_created_revocation_registry_definition", - mock.AsyncMock(), - ) as mock_rev_reg_def, mock.patch.object( - test_module.web, "json_response", mock.Mock() - ) as mock_json_response: + with ( + mock.patch.object( + test_module.AnonCredsRevocation, + "get_created_revocation_registry_definition", + mock.AsyncMock(), + ) as mock_rev_reg_def, + mock.patch.object( + test_module.web, "json_response", mock.Mock() + ) as mock_json_response, + ): mock_rev_reg_def.return_value = None with self.assertRaises(HTTPNotFound): diff --git a/acapy_agent/settings/tests/test_routes.py b/acapy_agent/settings/tests/test_routes.py index 7327093c78..707aa6760a 100644 --- a/acapy_agent/settings/tests/test_routes.py +++ b/acapy_agent/settings/tests/test_routes.py @@ -190,11 +190,12 @@ async def test_update_profile_settings(mock_response, profile): ), __getitem__=lambda _, k: request_dict[k], ) - with mock.patch.object( - multi_tenant_manager, "update_wallet" - ) as update_wallet, mock.patch.object( - multi_tenant_manager, "get_wallet_and_profile" - ) as get_wallet_and_profile: + with ( + mock.patch.object(multi_tenant_manager, "update_wallet") as update_wallet, + mock.patch.object( + multi_tenant_manager, "get_wallet_and_profile" + ) as get_wallet_and_profile, + ): get_wallet_and_profile.return_value = ( mock.MagicMock( settings={ diff --git a/acapy_agent/storage/tests/test_askar_storage.py b/acapy_agent/storage/tests/test_askar_storage.py index b36925ea7f..c959c6e3fa 100644 --- a/acapy_agent/storage/tests/test_askar_storage.py +++ b/acapy_agent/storage/tests/test_askar_storage.py @@ -46,17 +46,23 @@ class TestAskarStorage: @pytest.mark.skip @pytest.mark.asyncio async def test_record(self): - with mock.patch.object( - indy.wallet, "create_wallet", mock.CoroutineMock() - ) as mock_create, mock.patch.object( - indy.wallet, "open_wallet", mock.CoroutineMock() - ) as mock_open, mock.patch.object( - indy.anoncreds, "prover_create_master_secret", mock.CoroutineMock() - ) as mock_master, mock.patch.object( - indy.wallet, "close_wallet", mock.CoroutineMock() - ) as mock_close, mock.patch.object( - indy.wallet, "delete_wallet", mock.CoroutineMock() - ) as mock_delete: + with ( + mock.patch.object( + indy.wallet, "create_wallet", mock.CoroutineMock() + ) as mock_create, + mock.patch.object( + indy.wallet, "open_wallet", mock.CoroutineMock() + ) as mock_open, + mock.patch.object( + indy.anoncreds, "prover_create_master_secret", mock.CoroutineMock() + ) as mock_master, + mock.patch.object( + indy.wallet, "close_wallet", mock.CoroutineMock() + ) as mock_close, + mock.patch.object( + indy.wallet, "delete_wallet", mock.CoroutineMock() + ) as mock_delete, + ): fake_wallet = AskarWallet( { "auto_create": True, @@ -154,19 +160,23 @@ async def test_record(self): with pytest.raises(test_module.StorageError): await storage.get_record("connection", "dummy-id") - with mock.patch.object( - test_module.non_secrets, - "update_wallet_record_value", - mock.CoroutineMock(), - ) as mock_update_value, mock.patch.object( - test_module.non_secrets, - "update_wallet_record_tags", - mock.CoroutineMock(), - ) as mock_update_tags, mock.patch.object( - test_module.non_secrets, - "delete_wallet_record", - mock.CoroutineMock(), - ) as mock_delete: + with ( + mock.patch.object( + test_module.non_secrets, + "update_wallet_record_value", + mock.CoroutineMock(), + ) as mock_update_value, + mock.patch.object( + test_module.non_secrets, + "update_wallet_record_tags", + mock.CoroutineMock(), + ) as mock_update_tags, + mock.patch.object( + test_module.non_secrets, + "delete_wallet_record", + mock.CoroutineMock(), + ) as mock_delete, + ): mock_update_value.side_effect = test_module.IndyError( test_module.ErrorCode.CommonInvalidStructure ) @@ -209,17 +219,23 @@ async def test_record(self): @pytest.mark.skip @pytest.mark.asyncio async def test_storage_search_x(self): - with mock.patch.object( - indy.wallet, "create_wallet", mock.CoroutineMock() - ) as mock_create, mock.patch.object( - indy.wallet, "open_wallet", mock.CoroutineMock() - ) as mock_open, mock.patch.object( - indy.anoncreds, "prover_create_master_secret", mock.CoroutineMock() - ) as mock_master, mock.patch.object( - indy.wallet, "close_wallet", mock.CoroutineMock() - ) as mock_close, mock.patch.object( - indy.wallet, "delete_wallet", mock.CoroutineMock() - ) as mock_delete: + with ( + mock.patch.object( + indy.wallet, "create_wallet", mock.CoroutineMock() + ) as mock_create, + mock.patch.object( + indy.wallet, "open_wallet", mock.CoroutineMock() + ) as mock_open, + mock.patch.object( + indy.anoncreds, "prover_create_master_secret", mock.CoroutineMock() + ) as mock_master, + mock.patch.object( + indy.wallet, "close_wallet", mock.CoroutineMock() + ) as mock_close, + mock.patch.object( + indy.wallet, "delete_wallet", mock.CoroutineMock() + ) as mock_delete, + ): fake_wallet = AskarWallet( { "auto_create": True, @@ -246,26 +262,33 @@ async def test_storage_search_x(self): with pytest.raises(StorageSearchError): await search.fetch(10) - with mock.patch.object( - indy.non_secrets, "open_wallet_search", mock.CoroutineMock() - ) as mock_indy_open_search, mock.patch.object( - indy.non_secrets, "close_wallet_search", mock.CoroutineMock() - ) as mock_indy_close_search: + with ( + mock.patch.object( + indy.non_secrets, "open_wallet_search", mock.CoroutineMock() + ) as mock_indy_open_search, + mock.patch.object( + indy.non_secrets, "close_wallet_search", mock.CoroutineMock() + ) as mock_indy_close_search, + ): mock_indy_open_search.side_effect = test_module.IndyError("no open") search = storage.search_records("connection") with pytest.raises(StorageSearchError): await search.open() await search.close() - with mock.patch.object( - indy.non_secrets, "open_wallet_search", mock.CoroutineMock() - ) as mock_indy_open_search, mock.patch.object( - indy.non_secrets, - "fetch_wallet_search_next_records", - mock.CoroutineMock(), - ) as mock_indy_fetch, mock.patch.object( - indy.non_secrets, "close_wallet_search", mock.CoroutineMock() - ) as mock_indy_close_search: + with ( + mock.patch.object( + indy.non_secrets, "open_wallet_search", mock.CoroutineMock() + ) as mock_indy_open_search, + mock.patch.object( + indy.non_secrets, + "fetch_wallet_search_next_records", + mock.CoroutineMock(), + ) as mock_indy_fetch, + mock.patch.object( + indy.non_secrets, "close_wallet_search", mock.CoroutineMock() + ) as mock_indy_close_search, + ): mock_indy_fetch.side_effect = test_module.IndyError("no fetch") search = storage.search_records("connection") await search.open() @@ -273,11 +296,14 @@ async def test_storage_search_x(self): await search.fetch(10) await search.close() - with mock.patch.object( - indy.non_secrets, "open_wallet_search", mock.CoroutineMock() - ) as mock_indy_open_search, mock.patch.object( - indy.non_secrets, "close_wallet_search", mock.CoroutineMock() - ) as mock_indy_close_search: + with ( + mock.patch.object( + indy.non_secrets, "open_wallet_search", mock.CoroutineMock() + ) as mock_indy_open_search, + mock.patch.object( + indy.non_secrets, "close_wallet_search", mock.CoroutineMock() + ) as mock_indy_close_search, + ): mock_indy_close_search.side_effect = test_module.IndyError("no close") search = storage.search_records("connection") await search.open() diff --git a/acapy_agent/tests/test_main.py b/acapy_agent/tests/test_main.py index ea2d7b0573..c403d0469d 100644 --- a/acapy_agent/tests/test_main.py +++ b/acapy_agent/tests/test_main.py @@ -5,11 +5,11 @@ class TestMain(TestCase): def test_main(self): - with mock.patch.object(test_module, "__name__", "__main__"), mock.patch.object( - test_module, "init_debug", mock.MagicMock() - ) as mock_debug, mock.patch.object( - test_module, "run", mock.MagicMock() - ) as mock_run: + with ( + mock.patch.object(test_module, "__name__", "__main__"), + mock.patch.object(test_module, "init_debug", mock.MagicMock()) as mock_debug, + mock.patch.object(test_module, "run", mock.MagicMock()) as mock_run, + ): args = ["aca-py"] test_module.main(args) mock_debug.assert_called_once_with(args) diff --git a/acapy_agent/transport/inbound/tests/test_session.py b/acapy_agent/transport/inbound/tests/test_session.py index 985fbc7f3a..421adcc3c8 100644 --- a/acapy_agent/transport/inbound/tests/test_session.py +++ b/acapy_agent/transport/inbound/tests/test_session.py @@ -134,11 +134,10 @@ async def test_receive(self): ) test_msg = mock.MagicMock() - with mock.patch.object( - sess, "parse_inbound", mock.CoroutineMock() - ) as encode, mock.patch.object( - sess, "receive_inbound", mock.MagicMock() - ) as receive: + with ( + mock.patch.object(sess, "parse_inbound", mock.CoroutineMock()) as encode, + mock.patch.object(sess, "receive_inbound", mock.MagicMock()) as receive, + ): result = await sess.receive(test_msg) encode.assert_awaited_once_with(test_msg) receive.assert_called_once_with(encode.return_value) @@ -165,11 +164,10 @@ async def test_receive_no_wallet_found(self): ) test_msg = mock.MagicMock() - with mock.patch.object( - sess, "parse_inbound", mock.CoroutineMock() - ) as encode, mock.patch.object( - sess, "receive_inbound", mock.MagicMock() - ) as receive: + with ( + mock.patch.object(sess, "parse_inbound", mock.CoroutineMock()) as encode, + mock.patch.object(sess, "receive_inbound", mock.MagicMock()) as receive, + ): result = await sess.receive(test_msg) encode.assert_awaited_once_with(test_msg) receive.assert_called_once_with(encode.return_value) diff --git a/acapy_agent/transport/outbound/tests/test_manager.py b/acapy_agent/transport/outbound/tests/test_manager.py index abdd0252a2..18ad129a8f 100644 --- a/acapy_agent/transport/outbound/tests/test_manager.py +++ b/acapy_agent/transport/outbound/tests/test_manager.py @@ -224,11 +224,13 @@ async def test_process_loop_new(self): message=mock.MagicMock(enc_payload=b"encr"), ) ] - with mock.patch.object( - mgr, "deliver_queued_message", mock.MagicMock() - ), mock.patch.object( - mgr.outbound_event, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object(test_module, "trace_event", mock.MagicMock()): + with ( + mock.patch.object(mgr, "deliver_queued_message", mock.MagicMock()), + mock.patch.object( + mgr.outbound_event, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object(test_module, "trace_event", mock.MagicMock()), + ): mock_wait.side_effect = KeyError() # cover state=NEW logic and bail with self.assertRaises(KeyError): @@ -245,11 +247,13 @@ async def test_process_loop_new_deliver(self): message=mock.MagicMock(enc_payload=b"encr"), ) ] - with mock.patch.object( - mgr, "deliver_queued_message", mock.MagicMock() - ), mock.patch.object( - mgr.outbound_event, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object(test_module, "trace_event", mock.MagicMock()): + with ( + mock.patch.object(mgr, "deliver_queued_message", mock.MagicMock()), + mock.patch.object( + mgr.outbound_event, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object(test_module, "trace_event", mock.MagicMock()), + ): mock_wait.side_effect = KeyError() # cover state=DELIVER logic and bail with self.assertRaises(KeyError): @@ -278,14 +282,13 @@ async def test_finished_deliver_x_log_debug(self): mock_handle_not_delivered = mock.MagicMock() mgr = OutboundTransportManager(self.profile, mock_handle_not_delivered) mgr.outbound_buffer.append(mock_queued) - with mock.patch.object( - test_module.LOGGER, "exception", mock.MagicMock() - ), mock.patch.object( - test_module.LOGGER, "error", mock.MagicMock() - ), mock.patch.object( - test_module.LOGGER, "isEnabledFor", mock.MagicMock() - ) as mock_logger_enabled, mock.patch.object( - mgr, "process_queued", mock.MagicMock() + with ( + mock.patch.object(test_module.LOGGER, "exception", mock.MagicMock()), + mock.patch.object(test_module.LOGGER, "error", mock.MagicMock()), + mock.patch.object( + test_module.LOGGER, "isEnabledFor", mock.MagicMock() + ) as mock_logger_enabled, + mock.patch.object(mgr, "process_queued", mock.MagicMock()), ): mock_logger_enabled.return_value = True # cover debug logging mgr.finished_deliver(mock_queued, mock_completed_x) diff --git a/acapy_agent/transport/queue/tests/test_basic_queue.py b/acapy_agent/transport/queue/tests/test_basic_queue.py index 6d54899f69..992ba3a7be 100644 --- a/acapy_agent/transport/queue/tests/test_basic_queue.py +++ b/acapy_agent/transport/queue/tests/test_basic_queue.py @@ -37,13 +37,16 @@ async def test_dequeue_x(self): test_value = "test value" await queue.enqueue(test_value) - with mock.patch.object( - test_module.asyncio, "get_event_loop", mock.MagicMock() - ) as mock_get_event_loop, mock.patch.object( - test_module.asyncio, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object( - queue, "stop_event" - ) as mock_stop_event, mock.patch.object(queue, "queue"): + with ( + mock.patch.object( + test_module.asyncio, "get_event_loop", mock.MagicMock() + ) as mock_get_event_loop, + mock.patch.object( + test_module.asyncio, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object(queue, "stop_event") as mock_stop_event, + mock.patch.object(queue, "queue"), + ): mock_stop_event.is_set.return_value = False mock_wait.return_value = ( mock.MagicMock(), @@ -68,13 +71,16 @@ async def test_dequeue_none(self): test_value = "test value" await queue.enqueue(test_value) - with mock.patch.object( - test_module.asyncio, "get_event_loop", mock.MagicMock() - ) as mock_get_event_loop, mock.patch.object( - test_module.asyncio, "wait", mock.CoroutineMock() - ) as mock_wait, mock.patch.object( - queue, "stop_event" - ) as mock_stop_event, mock.patch.object(queue, "queue"): + with ( + mock.patch.object( + test_module.asyncio, "get_event_loop", mock.MagicMock() + ) as mock_get_event_loop, + mock.patch.object( + test_module.asyncio, "wait", mock.CoroutineMock() + ) as mock_wait, + mock.patch.object(queue, "stop_event") as mock_stop_event, + mock.patch.object(queue, "queue"), + ): mock_stop_event.is_set.return_value = False mock_wait.return_value = ( mock.MagicMock(), diff --git a/acapy_agent/utils/tests/test_classloader.py b/acapy_agent/utils/tests/test_classloader.py index 5a9c8be5e5..daead84132 100644 --- a/acapy_agent/utils/tests/test_classloader.py +++ b/acapy_agent/utils/tests/test_classloader.py @@ -42,9 +42,12 @@ def test_import_missing(self): assert ClassLoader.load_module("acapy_agent", "not.a-module") is None def test_import_error(self): - with mock.patch.object( - test_module, "import_module", autospec=True - ) as import_module, mock.patch.object(test_module.sys, "modules", {}): + with ( + mock.patch.object( + test_module, "import_module", autospec=True + ) as import_module, + mock.patch.object(test_module.sys, "modules", {}), + ): import_module.side_effect = ModuleNotFoundError with self.assertRaises(ModuleLoadError): ClassLoader.load_module("acapy_agent.config") diff --git a/acapy_agent/utils/tests/test_task_queue.py b/acapy_agent/utils/tests/test_task_queue.py index 26815e87cc..b079bf53bb 100644 --- a/acapy_agent/utils/tests/test_task_queue.py +++ b/acapy_agent/utils/tests/test_task_queue.py @@ -106,11 +106,10 @@ def done(complete: CompletedTask): async def noop(): return - with mock.patch.object( - queue, "drain", mock.MagicMock() - ) as mock_drain, mock.patch.object( - queue, "wait_for", mock.CoroutineMock() - ) as mock_wait_for: + with ( + mock.patch.object(queue, "drain", mock.MagicMock()) as mock_drain, + mock.patch.object(queue, "wait_for", mock.CoroutineMock()) as mock_wait_for, + ): mock_drain.side_effect = [queue.loop.create_task(noop()), None] await queue.complete(cleanup=True) diff --git a/acapy_agent/vc/vc_ld/tests/test_manager.py b/acapy_agent/vc/vc_ld/tests/test_manager.py index 7b5dd4c81b..bc6a5b3d4b 100644 --- a/acapy_agent/vc/vc_ld/tests/test_manager.py +++ b/acapy_agent/vc/vc_ld/tests/test_manager.py @@ -158,15 +158,18 @@ async def test_get_did_info_for_did_sov(self): assert did_info == did async def test_get_suite_for_document(self): - with mock.patch.object( - self.manager, - "assert_can_issue_with_id_and_proof_type", - mock.CoroutineMock(), - ) as mock_can_issue, mock.patch.object( - self.manager, - "_did_info_for_did", - mock.CoroutineMock(), - ) as mock_did_info: + with ( + mock.patch.object( + self.manager, + "assert_can_issue_with_id_and_proof_type", + mock.CoroutineMock(), + ) as mock_can_issue, + mock.patch.object( + self.manager, + "_did_info_for_did", + mock.CoroutineMock(), + ) as mock_did_info, + ): suite = await self.manager._get_suite_for_document(self.vc, self.options) assert suite.signature_type == self.options.proof_type diff --git a/acapy_agent/wallet/tests/test_anoncreds_upgrade.py b/acapy_agent/wallet/tests/test_anoncreds_upgrade.py index 37f6ab94d1..9e6c0f04ad 100644 --- a/acapy_agent/wallet/tests/test_anoncreds_upgrade.py +++ b/acapy_agent/wallet/tests/test_anoncreds_upgrade.py @@ -329,17 +329,19 @@ async def test_failed_upgrade(self): ) ) - with mock.patch.object( - anoncreds_upgrade, "upgrade_and_delete_schema_records" - ), mock.patch.object( - anoncreds_upgrade, "upgrade_and_delete_cred_def_records" - ), mock.patch.object( - AskarProfileSession, "rollback" - ) as mock_rollback, mock.patch.object( - AskarProfileSession, - "commit", - # Don't wait for sleep in retry to speed up test - ) as mock_commit, mock.patch.object(asyncio, "sleep"): + with ( + mock.patch.object(anoncreds_upgrade, "upgrade_and_delete_schema_records"), + mock.patch.object( + anoncreds_upgrade, "upgrade_and_delete_cred_def_records" + ), + mock.patch.object(AskarProfileSession, "rollback") as mock_rollback, + mock.patch.object( + AskarProfileSession, + "commit", + # Don't wait for sleep in retry to speed up test + ) as mock_commit, + mock.patch.object(asyncio, "sleep"), + ): """ Only tests schemas and cred_defs failing to upgrade because the other objects are hard to mock. These tests should be enough to cover them as the logic is the same. diff --git a/acapy_agent/wallet/tests/test_crypto.py b/acapy_agent/wallet/tests/test_crypto.py index 0596f30821..429a551179 100644 --- a/acapy_agent/wallet/tests/test_crypto.py +++ b/acapy_agent/wallet/tests/test_crypto.py @@ -39,11 +39,14 @@ def test_seeds_keys(self): assert test_module.sign_pk_from_sk(secret_key) in secret_key def test_decode_pack_message_x(self): - with mock.patch.object( - test_module, "decode_pack_message_outer", mock.MagicMock() - ) as mock_decode_outer, mock.patch.object( - test_module, "extract_payload_key", mock.MagicMock() - ) as mock_extract: + with ( + mock.patch.object( + test_module, "decode_pack_message_outer", mock.MagicMock() + ) as mock_decode_outer, + mock.patch.object( + test_module, "extract_payload_key", mock.MagicMock() + ) as mock_extract, + ): mock_decode_outer.return_value = (b"wrapper", {"my": b"recip"}, True) with pytest.raises(ValueError) as excinfo: From 27edc6ed48133c93eb28af2dd3832fd1de17ba59 Mon Sep 17 00:00:00 2001 From: Mourits de Beer <31511766+ff137@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:20:12 +0200 Subject: [PATCH 07/10] :art: Replace deprecated ABC decorators (#3357) Signed-off-by: ff137 Co-authored-by: jamshale <31809382+jamshale@users.noreply.github.com> --- acapy_agent/messaging/base_message.py | 17 +++++++++++------ .../issue_credential/v2_0/formats/handler.py | 5 +++-- .../present_proof/v2_0/formats/handler.py | 5 +++-- acapy_agent/vc/ld_proofs/crypto/key_pair.py | 8 +++++--- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/acapy_agent/messaging/base_message.py b/acapy_agent/messaging/base_message.py index 91df02cb1f..766aa47898 100644 --- a/acapy_agent/messaging/base_message.py +++ b/acapy_agent/messaging/base_message.py @@ -1,6 +1,6 @@ """Base message.""" -from abc import ABC, abstractclassmethod, abstractmethod, abstractproperty +from abc import ABC, abstractmethod from enum import Enum, auto from typing import TYPE_CHECKING, Optional, Type @@ -23,15 +23,18 @@ class BaseMessage(ABC): the context of the plugin. """ - @abstractproperty + @property + @abstractmethod def _type(self) -> str: """Return message type.""" - @abstractproperty + @property + @abstractmethod def _id(self) -> str: """Return message id.""" - @abstractproperty + @property + @abstractmethod def _thread_id(self) -> Optional[str]: """Return message thread id.""" @@ -39,10 +42,12 @@ def _thread_id(self) -> Optional[str]: def serialize(self, msg_format: DIDCommVersion = DIDCommVersion.v1) -> dict: """Return serialized message in format specified.""" - @abstractclassmethod + @classmethod + @abstractmethod def deserialize(cls, value: dict, msg_format: DIDCommVersion = DIDCommVersion.v1): """Return message object deserialized from value in format specified.""" - @abstractproperty + @property + @abstractmethod def Handler(self) -> Type["BaseHandler"]: """Return reference to handler class.""" diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/handler.py index cc5cc15f7e..a001b11d86 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/handler.py @@ -1,7 +1,7 @@ """V2.0 issue-credential base credential format handler.""" import logging -from abc import ABC, abstractclassmethod, abstractmethod +from abc import ABC, abstractmethod from typing import Mapping, Optional, Tuple from .....core.error import BaseError @@ -60,7 +60,8 @@ def get_format_identifier(self, message_type: str) -> str: def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment: """Get credential format and attachment objects for use in cred ex messages.""" - @abstractclassmethod + @classmethod + @abstractmethod def validate_fields(cls, message_type: str, attachment_data: dict) -> None: """Validate attachment data for specific message type and format.""" diff --git a/acapy_agent/protocols/present_proof/v2_0/formats/handler.py b/acapy_agent/protocols/present_proof/v2_0/formats/handler.py index 7e4e421cb6..2a36cc3757 100644 --- a/acapy_agent/protocols/present_proof/v2_0/formats/handler.py +++ b/acapy_agent/protocols/present_proof/v2_0/formats/handler.py @@ -1,7 +1,7 @@ """present-proof-v2 format handler - supports ANONCREDS, DIF and INDY.""" import logging -from abc import ABC, abstractclassmethod, abstractmethod +from abc import ABC, abstractmethod from typing import Optional, Tuple from .....core.error import BaseError @@ -56,7 +56,8 @@ def get_format_identifier(self, message_type: str) -> str: def get_format_data(self, message_type: str, data: dict) -> PresFormatAttachment: """Get presentation format and attach objects for use in pres_ex messages.""" - @abstractclassmethod + @classmethod + @abstractmethod def validate_fields(cls, message_type: str, attachment_data: dict) -> None: """Validate attachment data for specific message type and format.""" diff --git a/acapy_agent/vc/ld_proofs/crypto/key_pair.py b/acapy_agent/vc/ld_proofs/crypto/key_pair.py index 0409bc3769..c11e249eea 100644 --- a/acapy_agent/vc/ld_proofs/crypto/key_pair.py +++ b/acapy_agent/vc/ld_proofs/crypto/key_pair.py @@ -1,6 +1,6 @@ """Base key pair class.""" -from abc import ABC, abstractmethod, abstractproperty +from abc import ABC, abstractmethod from typing import List, Optional, Union @@ -15,7 +15,8 @@ async def sign(self, message: Union[List[bytes], bytes]) -> bytes: async def verify(self, message: Union[List[bytes], bytes], signature: bytes) -> bool: """Verify message(s) against signature using key pair.""" - @abstractproperty + @property + @abstractmethod def has_public_key(self) -> bool: """Whether key pair has a public key. @@ -23,7 +24,8 @@ def has_public_key(self) -> bool: in the verification process. """ - @abstractproperty + @property + @abstractmethod def public_key(self) -> Optional[bytes]: """Getter for the public key bytes. From dd17d0115c2f87bd7d7cc2c13d10db7540c8f418 Mon Sep 17 00:00:00 2001 From: jamshale <31809382+jamshale@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:29:05 -0800 Subject: [PATCH 08/10] Add test wallet config option (#3355) * Add test wallet config option Signed-off-by: jamshale * Change wallet test arg to store true / Fix tests Signed-off-by: jamshale * Add unit test with test wallet config Signed-off-by: jamshale --------- Signed-off-by: jamshale --- acapy_agent/askar/profile.py | 8 ++++-- acapy_agent/askar/profile_anon.py | 8 ++++-- acapy_agent/askar/tests/test_profile.py | 29 ++++++++++++---------- acapy_agent/commands/tests/test_start.py | 1 + acapy_agent/commands/tests/test_upgrade.py | 1 + acapy_agent/config/argparse.py | 26 ++++++++++++++----- acapy_agent/config/tests/test_argparse.py | 6 ++--- acapy_agent/config/wallet.py | 1 + 8 files changed, 53 insertions(+), 27 deletions(-) diff --git a/acapy_agent/askar/profile.py b/acapy_agent/askar/profile.py index e80bc569f1..313c026bf3 100644 --- a/acapy_agent/askar/profile.py +++ b/acapy_agent/askar/profile.py @@ -324,7 +324,9 @@ async def provision( ) -> Profile: """Provision a new instance of a profile.""" store_config = AskarStoreConfig(config) - opened = await store_config.open_store(provision=True) + opened = await store_config.open_store( + provision=True, in_memory=config.get("test") + ) return AskarProfile(opened, context) async def open( @@ -332,7 +334,9 @@ async def open( ) -> Profile: """Open an instance of an existing profile.""" store_config = AskarStoreConfig(config) - opened = await store_config.open_store(provision=False) + opened = await store_config.open_store( + provision=False, in_memory=config.get("test") + ) return AskarProfile(opened, context) @classmethod diff --git a/acapy_agent/askar/profile_anon.py b/acapy_agent/askar/profile_anon.py index eea73d876f..9a3cb3e622 100644 --- a/acapy_agent/askar/profile_anon.py +++ b/acapy_agent/askar/profile_anon.py @@ -277,7 +277,9 @@ async def provision( ) -> Profile: """Provision a new instance of a profile.""" store_config = AskarStoreConfig(config) - opened = await store_config.open_store(provision=True) + opened = await store_config.open_store( + provision=True, in_memory=config.get("test") + ) return AskarAnoncredsProfile(opened, context) async def open( @@ -285,7 +287,9 @@ async def open( ) -> Profile: """Open an instance of an existing profile.""" store_config = AskarStoreConfig(config) - opened = await store_config.open_store(provision=False) + opened = await store_config.open_store( + provision=False, in_memory=config.get("test") + ) return AskarAnoncredsProfile(opened, context) @classmethod diff --git a/acapy_agent/askar/tests/test_profile.py b/acapy_agent/askar/tests/test_profile.py index 38a0326ded..15bbbba1ef 100644 --- a/acapy_agent/askar/tests/test_profile.py +++ b/acapy_agent/askar/tests/test_profile.py @@ -3,10 +3,11 @@ import pytest -from ...askar.profile import AskarProfile +from ...askar.profile import AskarProfile, AskarProfileManager from ...config.injection_context import InjectionContext from ...ledger.base import BaseLedger from .. import profile as test_module +from ..profile_anon import AskarAnonProfileManager @pytest.fixture @@ -107,15 +108,17 @@ async def test_profile_manager_transaction(): @pytest.mark.asyncio async def test_profile_manager_store(): - profile = "profileId" - - with mock.patch("acapy_agent.askar.profile.AskarProfile") as AskarProfile: - askar_profile = AskarProfile(None, False, profile_id=profile) - askar_profile.profile_id = profile - askar_profile_session = mock.MagicMock() - askar_profile.store.session.return_value = askar_profile_session - - sessionProfile = test_module.AskarProfileSession(askar_profile, False) - - assert sessionProfile._opener == askar_profile_session - askar_profile.store.session.assert_called_once_with(profile) + config = { + "test": True, + } + context = InjectionContext( + settings=config, + ) + await AskarProfileManager().provision( + context=context, + config=config, + ) + await AskarAnonProfileManager().provision( + context=context, + config=config, + ) diff --git a/acapy_agent/commands/tests/test_start.py b/acapy_agent/commands/tests/test_start.py index cac10b8df6..4c9fe32bcb 100644 --- a/acapy_agent/commands/tests/test_start.py +++ b/acapy_agent/commands/tests/test_start.py @@ -55,6 +55,7 @@ def test_exec_start(self): "0.0.0.0", "80", "--no-ledger", + "--wallet-test", ] ) start_app.assert_called_once() diff --git a/acapy_agent/commands/tests/test_upgrade.py b/acapy_agent/commands/tests/test_upgrade.py index 41728221c8..8d24bbc723 100644 --- a/acapy_agent/commands/tests/test_upgrade.py +++ b/acapy_agent/commands/tests/test_upgrade.py @@ -439,6 +439,7 @@ async def test_execute(self): "--from-version", "v0.7.0", "--force-upgrade", + "--wallet-test", ] ) diff --git a/acapy_agent/config/argparse.py b/acapy_agent/config/argparse.py index ec0d3d95e1..87a67aeaf7 100644 --- a/acapy_agent/config/argparse.py +++ b/acapy_agent/config/argparse.py @@ -1610,13 +1610,13 @@ def add_arguments(self, parser: ArgumentParser): "--wallet-type", type=str, metavar="", - default="basic", + default="askar", env_var="ACAPY_WALLET_TYPE", help=( "Specifies the type of wallet provider to use. " - "Supported internal storage types are 'basic' (memory), 'askar' " + "Supported internal storage types are 'askar' " "and 'askar-anoncreds'." - "The default (if not specified) is 'basic'." + "The default (if not specified) is 'askar'." ), ) parser.add_argument( @@ -1627,11 +1627,23 @@ def add_arguments(self, parser: ArgumentParser): env_var="ACAPY_WALLET_STORAGE_TYPE", help=( "Specifies the type of wallet backend to use. " - "Supported internal storage types are 'basic' (memory), " - "'default' (sqlite), and 'postgres_storage'. The default, " + "Supported internal storage types are 'default' (sqlite), " + "and 'postgres_storage'. The default, " "if not specified, is 'default'." ), ) + parser.add_argument( + "--wallet-test", + action="store_true", + default=False, + env_var="ACAPY_WALLET_TEST", + help=( + "Using this option will create a wallet with an in-memory askar wallet " + "storage with a random name. This is useful for testing purposes. " + "The data will not be persisted after the agent is stopped. The default " + "is False. " + ), + ) parser.add_argument( "--wallet-storage-config", type=str, @@ -1714,6 +1726,8 @@ def get_settings(self, args: Namespace) -> dict: settings["wallet.storage_type"] = args.wallet_storage_type if args.wallet_type: settings["wallet.type"] = args.wallet_type + if args.wallet_test: + settings["wallet.test"] = True if args.wallet_key_derivation_method: settings["wallet.key_derivation_method"] = args.wallet_key_derivation_method if args.wallet_rekey_derivation_method: @@ -1731,7 +1745,7 @@ def get_settings(self, args: Namespace) -> dict: # check required settings for persistent wallets if settings["wallet.type"] in ["askar", "askar-anoncreds"]: # requires name, key - if not args.wallet_name or not args.wallet_key: + if not args.wallet_test and (not args.wallet_name or not args.wallet_key): raise ArgsParseError( "Parameters --wallet-name and --wallet-key must be provided " "for persistent wallets" diff --git a/acapy_agent/config/tests/test_argparse.py b/acapy_agent/config/tests/test_argparse.py index b80e478032..c3965de392 100644 --- a/acapy_agent/config/tests/test_argparse.py +++ b/acapy_agent/config/tests/test_argparse.py @@ -525,10 +525,7 @@ async def test_wallet_key_derivation_method_value_parsing(self): group.add_arguments(parser) result = parser.parse_args( - [ - "--wallet-key-derivation-method", - key_derivation_method, - ] + ["--wallet-key-derivation-method", key_derivation_method, "--wallet-test"] ) settings = group.get_settings(result) @@ -545,6 +542,7 @@ async def test_wallet_key_value_parsing(self): [ "--wallet-key", key_value, + "--wallet-test", ] ) diff --git a/acapy_agent/config/wallet.py b/acapy_agent/config/wallet.py index f857b07847..ce5beb8fc3 100644 --- a/acapy_agent/config/wallet.py +++ b/acapy_agent/config/wallet.py @@ -26,6 +26,7 @@ "storage_config", "storage_creds", "storage_type", + "test", } From 80cc329076d3828c562fd6a31b72b27898359555 Mon Sep 17 00:00:00 2001 From: jamshale <31809382+jamshale@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:50:15 -0800 Subject: [PATCH 09/10] Week 49 Library upgrades (#3368) Signed-off-by: jamshale --- .pre-commit-config.yaml | 2 +- mkdocs-requirements.txt | 2 +- poetry.lock | 210 ++++++++++++++++++++-------------------- pyproject.toml | 8 +- 4 files changed, 110 insertions(+), 112 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9374f5f431..2cc9bec01f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: additional_dependencies: ['@commitlint/config-conventional'] - repo: https://github.com/astral-sh/ruff-pre-commit # Ensure this is synced with pyproject.toml - rev: v0.8.0 + rev: v0.8.1 hooks: # Run the linter - id: ruff diff --git a/mkdocs-requirements.txt b/mkdocs-requirements.txt index a6d710f6af..a3290d9569 100644 --- a/mkdocs-requirements.txt +++ b/mkdocs-requirements.txt @@ -1,3 +1,3 @@ -mkdocs-material==9.5.46 +mkdocs-material==9.5.47 mike==2.1.3 diff --git a/poetry.lock b/poetry.lock index 2ec25c70e1..09458d256f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "aiofiles" @@ -24,87 +24,87 @@ files = [ [[package]] name = "aiohttp" -version = "3.11.7" +version = "3.11.9" description = "Async http client/server framework (asyncio)" optional = false python-versions = ">=3.9" files = [ - {file = "aiohttp-3.11.7-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:8bedb1f6cb919af3b6353921c71281b1491f948ca64408871465d889b4ee1b66"}, - {file = "aiohttp-3.11.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f5022504adab881e2d801a88b748ea63f2a9d130e0b2c430824682a96f6534be"}, - {file = "aiohttp-3.11.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e22d1721c978a6494adc824e0916f9d187fa57baeda34b55140315fa2f740184"}, - {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e993676c71288618eb07e20622572b1250d8713e7e00ab3aabae28cb70f3640d"}, - {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e13a05db87d3b241c186d0936808d0e4e12decc267c617d54e9c643807e968b6"}, - {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4ba8d043fed7ffa117024d7ba66fdea011c0e7602327c6d73cacaea38abe4491"}, - {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dda3ed0a7869d2fa16aa41f9961ade73aa2c2e3b2fcb0a352524e7b744881889"}, - {file = "aiohttp-3.11.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:43bfd25113c1e98aec6c70e26d5f4331efbf4aa9037ba9ad88f090853bf64d7f"}, - {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3dd3e7e7c9ef3e7214f014f1ae260892286647b3cf7c7f1b644a568fd410f8ca"}, - {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:78c657ece7a73b976905ab9ec8be9ef2df12ed8984c24598a1791c58ce3b4ce4"}, - {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:db70a47987e34494b451a334605bee57a126fe8d290511349e86810b4be53b01"}, - {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:9e67531370a3b07e49b280c1f8c2df67985c790ad2834d1b288a2f13cd341c5f"}, - {file = "aiohttp-3.11.7-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:9202f184cc0582b1db15056f2225ab4c1e3dac4d9ade50dd0613ac3c46352ac2"}, - {file = "aiohttp-3.11.7-cp310-cp310-win32.whl", hash = "sha256:2257bdd5cf54a4039a4337162cd8048f05a724380a2283df34620f55d4e29341"}, - {file = "aiohttp-3.11.7-cp310-cp310-win_amd64.whl", hash = "sha256:b7215bf2b53bc6cb35808149980c2ae80a4ae4e273890ac85459c014d5aa60ac"}, - {file = "aiohttp-3.11.7-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:cea52d11e02123f125f9055dfe0ccf1c3857225fb879e4a944fae12989e2aef2"}, - {file = "aiohttp-3.11.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3ce18f703b7298e7f7633efd6a90138d99a3f9a656cb52c1201e76cb5d79cf08"}, - {file = "aiohttp-3.11.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:670847ee6aeb3a569cd7cdfbe0c3bec1d44828bbfbe78c5d305f7f804870ef9e"}, - {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4dda726f89bfa5c465ba45b76515135a3ece0088dfa2da49b8bb278f3bdeea12"}, - {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c25b74a811dba37c7ea6a14d99eb9402d89c8d739d50748a75f3cf994cf19c43"}, - {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e5522ee72f95661e79db691310290c4618b86dff2d9b90baedf343fd7a08bf79"}, - {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1fbf41a6bbc319a7816ae0f0177c265b62f2a59ad301a0e49b395746eb2a9884"}, - {file = "aiohttp-3.11.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:59ee1925b5a5efdf6c4e7be51deee93984d0ac14a6897bd521b498b9916f1544"}, - {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:24054fce8c6d6f33a3e35d1c603ef1b91bbcba73e3f04a22b4f2f27dac59b347"}, - {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:351849aca2c6f814575c1a485c01c17a4240413f960df1bf9f5deb0003c61a53"}, - {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:12724f3a211fa243570e601f65a8831372caf1a149d2f1859f68479f07efec3d"}, - {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:7ea4490360b605804bea8173d2d086b6c379d6bb22ac434de605a9cbce006e7d"}, - {file = "aiohttp-3.11.7-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:e0bf378db07df0a713a1e32381a1b277e62ad106d0dbe17b5479e76ec706d720"}, - {file = "aiohttp-3.11.7-cp311-cp311-win32.whl", hash = "sha256:cd8d62cab363dfe713067027a5adb4907515861f1e4ce63e7be810b83668b847"}, - {file = "aiohttp-3.11.7-cp311-cp311-win_amd64.whl", hash = "sha256:bf0e6cce113596377cadda4e3ac5fb89f095bd492226e46d91b4baef1dd16f60"}, - {file = "aiohttp-3.11.7-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:4bb7493c3e3a36d3012b8564bd0e2783259ddd7ef3a81a74f0dbfa000fce48b7"}, - {file = "aiohttp-3.11.7-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:e143b0ef9cb1a2b4f74f56d4fbe50caa7c2bb93390aff52f9398d21d89bc73ea"}, - {file = "aiohttp-3.11.7-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f7c58a240260822dc07f6ae32a0293dd5bccd618bb2d0f36d51c5dbd526f89c0"}, - {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8d20cfe63a1c135d26bde8c1d0ea46fd1200884afbc523466d2f1cf517d1fe33"}, - {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:12e4d45847a174f77b2b9919719203769f220058f642b08504cf8b1cf185dacf"}, - {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cf4efa2d01f697a7dbd0509891a286a4af0d86902fc594e20e3b1712c28c0106"}, - {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9ee6a4cdcbf54b8083dc9723cdf5f41f722c00db40ccf9ec2616e27869151129"}, - {file = "aiohttp-3.11.7-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c6095aaf852c34f42e1bd0cf0dc32d1e4b48a90bfb5054abdbb9d64b36acadcb"}, - {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1cf03d27885f8c5ebf3993a220cc84fc66375e1e6e812731f51aab2b2748f4a6"}, - {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:1a17f6a230f81eb53282503823f59d61dff14fb2a93847bf0399dc8e87817307"}, - {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:481f10a1a45c5f4c4a578bbd74cff22eb64460a6549819242a87a80788461fba"}, - {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:db37248535d1ae40735d15bdf26ad43be19e3d93ab3f3dad8507eb0f85bb8124"}, - {file = "aiohttp-3.11.7-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9d18a8b44ec8502a7fde91446cd9c9b95ce7c49f1eacc1fb2358b8907d4369fd"}, - {file = "aiohttp-3.11.7-cp312-cp312-win32.whl", hash = "sha256:3d1c9c15d3999107cbb9b2d76ca6172e6710a12fda22434ee8bd3f432b7b17e8"}, - {file = "aiohttp-3.11.7-cp312-cp312-win_amd64.whl", hash = "sha256:018f1b04883a12e77e7fc161934c0f298865d3a484aea536a6a2ca8d909f0ba0"}, - {file = "aiohttp-3.11.7-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:241a6ca732d2766836d62c58c49ca7a93d08251daef0c1e3c850df1d1ca0cbc4"}, - {file = "aiohttp-3.11.7-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:aa3705a8d14de39898da0fbad920b2a37b7547c3afd2a18b9b81f0223b7d0f68"}, - {file = "aiohttp-3.11.7-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9acfc7f652b31853eed3b92095b0acf06fd5597eeea42e939bd23a17137679d5"}, - {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dcefcf2915a2dbdbce37e2fc1622129a1918abfe3d06721ce9f6cdac9b6d2eaa"}, - {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c1f6490dd1862af5aae6cfcf2a274bffa9a5b32a8f5acb519a7ecf5a99a88866"}, - {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f1ac5462582d6561c1c1708853a9faf612ff4e5ea5e679e99be36143d6eabd8e"}, - {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c1a6309005acc4b2bcc577ba3b9169fea52638709ffacbd071f3503264620da"}, - {file = "aiohttp-3.11.7-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f5b973cce96793725ef63eb449adfb74f99c043c718acb76e0d2a447ae369962"}, - {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ce91a24aac80de6be8512fb1c4838a9881aa713f44f4e91dd7bb3b34061b497d"}, - {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:875f7100ce0e74af51d4139495eec4025affa1a605280f23990b6434b81df1bd"}, - {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:c171fc35d3174bbf4787381716564042a4cbc008824d8195eede3d9b938e29a8"}, - {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:ee9afa1b0d2293c46954f47f33e150798ad68b78925e3710044e0d67a9487791"}, - {file = "aiohttp-3.11.7-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8360c7cc620abb320e1b8d603c39095101391a82b1d0be05fb2225471c9c5c52"}, - {file = "aiohttp-3.11.7-cp313-cp313-win32.whl", hash = "sha256:7a9318da4b4ada9a67c1dd84d1c0834123081e746bee311a16bb449f363d965e"}, - {file = "aiohttp-3.11.7-cp313-cp313-win_amd64.whl", hash = "sha256:fc6da202068e0a268e298d7cd09b6e9f3997736cd9b060e2750963754552a0a9"}, - {file = "aiohttp-3.11.7-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:17829f37c0d31d89aa6b8b010475a10233774771f9b6dc2cc352ea4f8ce95d9a"}, - {file = "aiohttp-3.11.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d6177077a31b1aecfc3c9070bd2f11419dbb4a70f30f4c65b124714f525c2e48"}, - {file = "aiohttp-3.11.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:badda65ac99555791eed75e234afb94686ed2317670c68bff8a4498acdaee935"}, - {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0de6466b9d742b4ee56fe1b2440706e225eb48c77c63152b1584864a236e7a50"}, - {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:04b0cc74d5a882c9dacaeeccc1444f0233212b6f5be8bc90833feef1e1ce14b9"}, - {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c7af3e50e5903d21d7b935aceed901cc2475463bc16ddd5587653548661fdb"}, - {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c63f898f683d1379b9be5afc3dd139e20b30b0b1e0bf69a3fc3681f364cf1629"}, - {file = "aiohttp-3.11.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fdadc3f6a32d6eca45f9a900a254757fd7855dfb2d8f8dcf0e88f0fae3ff8eb1"}, - {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:d329300fb23e14ed1f8c6d688dfd867d1dcc3b1d7cd49b7f8c5b44e797ce0932"}, - {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:5578cf40440eafcb054cf859964bc120ab52ebe0e0562d2b898126d868749629"}, - {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:7b2f8107a3c329789f3c00b2daad0e35f548d0a55cda6291579136622099a46e"}, - {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:43dd89a6194f6ab02a3fe36b09e42e2df19c211fc2050ce37374d96f39604997"}, - {file = "aiohttp-3.11.7-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:d2fa6fc7cc865d26ff42480ac9b52b8c9b7da30a10a6442a9cdf429de840e949"}, - {file = "aiohttp-3.11.7-cp39-cp39-win32.whl", hash = "sha256:a7d9a606355655617fee25dd7e54d3af50804d002f1fd3118dd6312d26692d70"}, - {file = "aiohttp-3.11.7-cp39-cp39-win_amd64.whl", hash = "sha256:53c921b58fdc6485d6b2603e0132bb01cd59b8f0620ffc0907f525e0ba071687"}, - {file = "aiohttp-3.11.7.tar.gz", hash = "sha256:01a8aca4af3da85cea5c90141d23f4b0eee3cbecfd33b029a45a80f28c66c668"}, + {file = "aiohttp-3.11.9-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0411777249f25d11bd2964a230b3ffafcbed6cd65d0f2b132bc2b8f5b8c347c7"}, + {file = "aiohttp-3.11.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:499368eb904566fbdf1a3836a1532000ef1308f34a1bcbf36e6351904cced771"}, + {file = "aiohttp-3.11.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0b5a5009b0159a8f707879dc102b139466d8ec6db05103ec1520394fdd8ea02c"}, + {file = "aiohttp-3.11.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:176f8bb8931da0613bb0ed16326d01330066bb1e172dd97e1e02b1c27383277b"}, + {file = "aiohttp-3.11.9-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6435a66957cdba1a0b16f368bde03ce9c79c57306b39510da6ae5312a1a5b2c1"}, + {file = "aiohttp-3.11.9-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:202f40fb686e5f93908eee0c75d1e6fbe50a43e9bd4909bf3bf4a56b560ca180"}, + {file = "aiohttp-3.11.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:39625703540feb50b6b7f938b3856d1f4886d2e585d88274e62b1bd273fae09b"}, + {file = "aiohttp-3.11.9-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c6beeac698671baa558e82fa160be9761cf0eb25861943f4689ecf9000f8ebd0"}, + {file = "aiohttp-3.11.9-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:96726839a42429318017e67a42cca75d4f0d5248a809b3cc2e125445edd7d50d"}, + {file = "aiohttp-3.11.9-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:3f5461c77649358610fb9694e790956b4238ac5d9e697a17f63619c096469afe"}, + {file = "aiohttp-3.11.9-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:4313f3bc901255b22f01663eeeae167468264fdae0d32c25fc631d5d6e15b502"}, + {file = "aiohttp-3.11.9-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:d6e274661c74195708fc4380a4ef64298926c5a50bb10fbae3d01627d7a075b7"}, + {file = "aiohttp-3.11.9-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:db2914de2559809fdbcf3e48f41b17a493b58cb7988d3e211f6b63126c55fe82"}, + {file = "aiohttp-3.11.9-cp310-cp310-win32.whl", hash = "sha256:27935716f8d62c1c73010428db310fd10136002cfc6d52b0ba7bdfa752d26066"}, + {file = "aiohttp-3.11.9-cp310-cp310-win_amd64.whl", hash = "sha256:afbe85b50ade42ddff5669947afde9e8a610e64d2c80be046d67ec4368e555fa"}, + {file = "aiohttp-3.11.9-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:afcda759a69c6a8be3aae764ec6733155aa4a5ad9aad4f398b52ba4037942fe3"}, + {file = "aiohttp-3.11.9-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c5bba6b83fde4ca233cfda04cbd4685ab88696b0c8eaf76f7148969eab5e248a"}, + {file = "aiohttp-3.11.9-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:442356e8924fe1a121f8c87866b0ecdc785757fd28924b17c20493961b3d6697"}, + {file = "aiohttp-3.11.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f737fef6e117856400afee4f17774cdea392b28ecf058833f5eca368a18cf1bf"}, + {file = "aiohttp-3.11.9-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ea142255d4901b03f89cb6a94411ecec117786a76fc9ab043af8f51dd50b5313"}, + {file = "aiohttp-3.11.9-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6e1e9e447856e9b7b3d38e1316ae9a8c92e7536ef48373de758ea055edfd5db5"}, + {file = "aiohttp-3.11.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e7f6173302f8a329ca5d1ee592af9e628d3ade87816e9958dcf7cdae2841def7"}, + {file = "aiohttp-3.11.9-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a7c6147c6306f537cff59409609508a1d2eff81199f0302dd456bb9e7ea50c39"}, + {file = "aiohttp-3.11.9-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:e9d036a9a41fc78e8a3f10a86c2fc1098fca8fab8715ba9eb999ce4788d35df0"}, + {file = "aiohttp-3.11.9-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:2ac9fd83096df36728da8e2f4488ac3b5602238f602706606f3702f07a13a409"}, + {file = "aiohttp-3.11.9-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:d3108f0ad5c6b6d78eec5273219a5bbd884b4aacec17883ceefaac988850ce6e"}, + {file = "aiohttp-3.11.9-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:96bbec47beb131bbf4bae05d8ef99ad9e5738f12717cfbbf16648b78b0232e87"}, + {file = "aiohttp-3.11.9-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:fc726c3fa8f606d07bd2b500e5dc4c0fd664c59be7788a16b9e34352c50b6b6b"}, + {file = "aiohttp-3.11.9-cp311-cp311-win32.whl", hash = "sha256:5720ebbc7a1b46c33a42d489d25d36c64c419f52159485e55589fbec648ea49a"}, + {file = "aiohttp-3.11.9-cp311-cp311-win_amd64.whl", hash = "sha256:17af09d963fa1acd7e4c280e9354aeafd9e3d47eaa4a6bfbd2171ad7da49f0c5"}, + {file = "aiohttp-3.11.9-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:c1f2d7fd583fc79c240094b3e7237d88493814d4b300d013a42726c35a734bc9"}, + {file = "aiohttp-3.11.9-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d4b8a1b6c7a68c73191f2ebd3bf66f7ce02f9c374e309bdb68ba886bbbf1b938"}, + {file = "aiohttp-3.11.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bd3f711f4c99da0091ced41dccdc1bcf8be0281dc314d6d9c6b6cf5df66f37a9"}, + {file = "aiohttp-3.11.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44cb1a1326a0264480a789e6100dc3e07122eb8cd1ad6b784a3d47d13ed1d89c"}, + {file = "aiohttp-3.11.9-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7a7ddf981a0b953ade1c2379052d47ccda2f58ab678fca0671c7c7ca2f67aac2"}, + {file = "aiohttp-3.11.9-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6ffa45cc55b18d4ac1396d1ddb029f139b1d3480f1594130e62bceadf2e1a838"}, + {file = "aiohttp-3.11.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cca505829cdab58c2495ff418c96092d225a1bbd486f79017f6de915580d3c44"}, + {file = "aiohttp-3.11.9-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:44d323aa80a867cb6db6bebb4bbec677c6478e38128847f2c6b0f70eae984d72"}, + {file = "aiohttp-3.11.9-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:b2fab23003c4bb2249729a7290a76c1dda38c438300fdf97d4e42bf78b19c810"}, + {file = "aiohttp-3.11.9-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:be0c7c98e38a1e3ad7a6ff64af8b6d6db34bf5a41b1478e24c3c74d9e7f8ed42"}, + {file = "aiohttp-3.11.9-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:5cc5e0d069c56645446c45a4b5010d4b33ac6c5ebfd369a791b5f097e46a3c08"}, + {file = "aiohttp-3.11.9-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:9bcf97b971289be69638d8b1b616f7e557e1342debc7fc86cf89d3f08960e411"}, + {file = "aiohttp-3.11.9-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c7333e7239415076d1418dbfb7fa4df48f3a5b00f8fdf854fca549080455bc14"}, + {file = "aiohttp-3.11.9-cp312-cp312-win32.whl", hash = "sha256:9384b07cfd3045b37b05ed002d1c255db02fb96506ad65f0f9b776b762a7572e"}, + {file = "aiohttp-3.11.9-cp312-cp312-win_amd64.whl", hash = "sha256:f5252ba8b43906f206048fa569debf2cd0da0316e8d5b4d25abe53307f573941"}, + {file = "aiohttp-3.11.9-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:282e0a7ddd36ebc411f156aeaa0491e8fe7f030e2a95da532cf0c84b0b70bc66"}, + {file = "aiohttp-3.11.9-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ebd3e6b0c7d4954cca59d241970011f8d3327633d555051c430bd09ff49dc494"}, + {file = "aiohttp-3.11.9-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:30f9f89ae625d412043f12ca3771b2ccec227cc93b93bb1f994db6e1af40a7d3"}, + {file = "aiohttp-3.11.9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7a3b5b2c012d70c63d9d13c57ed1603709a4d9d7d473e4a9dfece0e4ea3d5f51"}, + {file = "aiohttp-3.11.9-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6ef1550bb5f55f71b97a6a395286db07f7f2c01c8890e613556df9a51da91e8d"}, + {file = "aiohttp-3.11.9-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:317251b9c9a2f1a9ff9cd093775b34c6861d1d7df9439ce3d32a88c275c995cd"}, + {file = "aiohttp-3.11.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21cbe97839b009826a61b143d3ca4964c8590d7aed33d6118125e5b71691ca46"}, + {file = "aiohttp-3.11.9-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:618b18c3a2360ac940a5503da14fa4f880c5b9bc315ec20a830357bcc62e6bae"}, + {file = "aiohttp-3.11.9-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a0cf4d814689e58f57ecd5d8c523e6538417ca2e72ff52c007c64065cef50fb2"}, + {file = "aiohttp-3.11.9-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:15c4e489942d987d5dac0ba39e5772dcbed4cc9ae3710d1025d5ba95e4a5349c"}, + {file = "aiohttp-3.11.9-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:ec8df0ff5a911c6d21957a9182402aad7bf060eaeffd77c9ea1c16aecab5adbf"}, + {file = "aiohttp-3.11.9-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:ed95d66745f53e129e935ad726167d3a6cb18c5d33df3165974d54742c373868"}, + {file = "aiohttp-3.11.9-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:647ec5bee7e4ec9f1034ab48173b5fa970d9a991e565549b965e93331f1328fe"}, + {file = "aiohttp-3.11.9-cp313-cp313-win32.whl", hash = "sha256:ef2c9499b7bd1e24e473dc1a85de55d72fd084eea3d8bdeec7ee0720decb54fa"}, + {file = "aiohttp-3.11.9-cp313-cp313-win_amd64.whl", hash = "sha256:84de955314aa5e8d469b00b14d6d714b008087a0222b0f743e7ffac34ef56aff"}, + {file = "aiohttp-3.11.9-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:e738aabff3586091221044b7a584865ddc4d6120346d12e28e788307cd731043"}, + {file = "aiohttp-3.11.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:28f29bce89c3b401a53d6fd4bee401ee943083bf2bdc12ef297c1d63155070b0"}, + {file = "aiohttp-3.11.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:31de2f10f63f96cc19e04bd2df9549559beadd0b2ee2da24a17e7ed877ca8c60"}, + {file = "aiohttp-3.11.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f31cebd8c27a36af6c7346055ac564946e562080ee1a838da724585c67474f"}, + {file = "aiohttp-3.11.9-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0bcb7f6976dc0b6b56efde13294862adf68dd48854111b422a336fa729a82ea6"}, + {file = "aiohttp-3.11.9-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1a8b13b9950d8b2f8f58b6e5842c4b842b5887e2c32e3f4644d6642f1659a530"}, + {file = "aiohttp-3.11.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9c23e62f3545c2216100603614f9e019e41b9403c47dd85b8e7e5015bf1bde0"}, + {file = "aiohttp-3.11.9-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ec656680fc53a13f849c71afd0c84a55c536206d524cbc831cde80abbe80489e"}, + {file = "aiohttp-3.11.9-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:36df00e0541f264ce42d62280281541a47474dfda500bc5b7f24f70a7f87be7a"}, + {file = "aiohttp-3.11.9-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:8dcfd14c712aa9dd18049280bfb2f95700ff6a8bde645e09f17c3ed3f05a0130"}, + {file = "aiohttp-3.11.9-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:14624d96f0d69cf451deed3173079a68c322279be6030208b045ab77e1e8d550"}, + {file = "aiohttp-3.11.9-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:4b01d9cfcb616eeb6d40f02e66bebfe7b06d9f2ef81641fdd50b8dd981166e0b"}, + {file = "aiohttp-3.11.9-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:928f92f80e2e8d6567b87d3316c1fd9860ccfe36e87a9a7f5237d4cda8baa1ba"}, + {file = "aiohttp-3.11.9-cp39-cp39-win32.whl", hash = "sha256:c8a02f74ae419e3955af60f570d83187423e42e672a6433c5e292f1d23619269"}, + {file = "aiohttp-3.11.9-cp39-cp39-win_amd64.whl", hash = "sha256:0a97d657f6cf8782a830bb476c13f7d777cfcab8428ac49dde15c22babceb361"}, + {file = "aiohttp-3.11.9.tar.gz", hash = "sha256:a9266644064779840feec0e34f10a89b3ff1d2d6b751fe90017abcad1864fa7c"}, ] [package.dependencies] @@ -1325,8 +1325,6 @@ optional = false python-versions = "*" files = [ {file = "jsonpath-ng-1.7.0.tar.gz", hash = "sha256:f6f5f7fd4e5ff79c785f1573b394043b39849fb2bb47bcead935d12b00beab3c"}, - {file = "jsonpath_ng-1.7.0-py2-none-any.whl", hash = "sha256:898c93fc173f0c336784a3fa63d7434297544b7198124a68f9a3ef9597b0ae6e"}, - {file = "jsonpath_ng-1.7.0-py3-none-any.whl", hash = "sha256:f3d7f9e848cba1b6da28c55b1c26ff915dc9e0b1ba7e752a53d6da8d5cbd00b6"}, ] [package.dependencies] @@ -2267,13 +2265,13 @@ windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pyjwt" -version = "2.10.0" +version = "2.10.1" description = "JSON Web Token implementation in Python" optional = false python-versions = ">=3.9" files = [ - {file = "PyJWT-2.10.0-py3-none-any.whl", hash = "sha256:543b77207db656de204372350926bed5a86201c4cbff159f623f79c7bb487a15"}, - {file = "pyjwt-2.10.0.tar.gz", hash = "sha256:7628a7eb7938959ac1b26e819a1df0fd3259505627b575e4bad6d08f76db695c"}, + {file = "PyJWT-2.10.1-py3-none-any.whl", hash = "sha256:dcdd193e30abefd5debf142f9adfcdd2b58004e644f25406ffaebd50bd98dacb"}, + {file = "pyjwt-2.10.1.tar.gz", hash = "sha256:3cc5772eb20009233caf06e9d8a0577824723b44e6648ee0a2aedb6cf9381953"}, ] [package.extras] @@ -2332,13 +2330,13 @@ tests = ["hypothesis (>=3.27.0)", "pytest (>=3.2.1,!=3.3.0)"] [[package]] name = "pytest" -version = "8.3.3" +version = "8.3.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"}, - {file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"}, + {file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, + {file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"}, ] [package.dependencies] @@ -2600,29 +2598,29 @@ test = ["hypothesis (==5.19.0)", "pytest (>=7.0.0)", "pytest-xdist (>=2.4.0)"] [[package]] name = "ruff" -version = "0.8.0" +version = "0.8.1" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.8.0-py3-none-linux_armv6l.whl", hash = "sha256:fcb1bf2cc6706adae9d79c8d86478677e3bbd4ced796ccad106fd4776d395fea"}, - {file = "ruff-0.8.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:295bb4c02d58ff2ef4378a1870c20af30723013f441c9d1637a008baaf928c8b"}, - {file = "ruff-0.8.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7b1f1c76b47c18fa92ee78b60d2d20d7e866c55ee603e7d19c1e991fad933a9a"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eb0d4f250a7711b67ad513fde67e8870109e5ce590a801c3722580fe98c33a99"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0e55cce9aa93c5d0d4e3937e47b169035c7e91c8655b0974e61bb79cf398d49c"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f4cd64916d8e732ce6b87f3f5296a8942d285bbbc161acee7fe561134af64f9"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c5c1466be2a2ebdf7c5450dd5d980cc87c8ba6976fb82582fea18823da6fa362"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2dabfd05b96b7b8f2da00d53c514eea842bff83e41e1cceb08ae1966254a51df"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:facebdfe5a5af6b1588a1d26d170635ead6892d0e314477e80256ef4a8470cf3"}, - {file = "ruff-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87a8e86bae0dbd749c815211ca11e3a7bd559b9710746c559ed63106d382bd9c"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:85e654f0ded7befe2d61eeaf3d3b1e4ef3894469cd664ffa85006c7720f1e4a2"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:83a55679c4cb449fa527b8497cadf54f076603cc36779b2170b24f704171ce70"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:812e2052121634cf13cd6fddf0c1871d0ead1aad40a1a258753c04c18bb71bbd"}, - {file = "ruff-0.8.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:780d5d8523c04202184405e60c98d7595bdb498c3c6abba3b6d4cdf2ca2af426"}, - {file = "ruff-0.8.0-py3-none-win32.whl", hash = "sha256:5fdb6efecc3eb60bba5819679466471fd7d13c53487df7248d6e27146e985468"}, - {file = "ruff-0.8.0-py3-none-win_amd64.whl", hash = "sha256:582891c57b96228d146725975fbb942e1f30a0c4ba19722e692ca3eb25cc9b4f"}, - {file = "ruff-0.8.0-py3-none-win_arm64.whl", hash = "sha256:ba93e6294e9a737cd726b74b09a6972e36bb511f9a102f1d9a7e1ce94dd206a6"}, - {file = "ruff-0.8.0.tar.gz", hash = "sha256:a7ccfe6331bf8c8dad715753e157457faf7351c2b69f62f32c165c2dbcbacd44"}, + {file = "ruff-0.8.1-py3-none-linux_armv6l.whl", hash = "sha256:fae0805bd514066f20309f6742f6ee7904a773eb9e6c17c45d6b1600ca65c9b5"}, + {file = "ruff-0.8.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b8a4f7385c2285c30f34b200ca5511fcc865f17578383db154e098150ce0a087"}, + {file = "ruff-0.8.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:cd054486da0c53e41e0086e1730eb77d1f698154f910e0cd9e0d64274979a209"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2029b8c22da147c50ae577e621a5bfbc5d1fed75d86af53643d7a7aee1d23871"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2666520828dee7dfc7e47ee4ea0d928f40de72056d929a7c5292d95071d881d1"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:333c57013ef8c97a53892aa56042831c372e0bb1785ab7026187b7abd0135ad5"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:288326162804f34088ac007139488dcb43de590a5ccfec3166396530b58fb89d"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b12c39b9448632284561cbf4191aa1b005882acbc81900ffa9f9f471c8ff7e26"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:364e6674450cbac8e998f7b30639040c99d81dfb5bbc6dfad69bc7a8f916b3d1"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b22346f845fec132aa39cd29acb94451d030c10874408dbf776af3aaeb53284c"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b2f2f7a7e7648a2bfe6ead4e0a16745db956da0e3a231ad443d2a66a105c04fa"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:adf314fc458374c25c5c4a4a9270c3e8a6a807b1bec018cfa2813d6546215540"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a885d68342a231b5ba4d30b8c6e1b1ee3a65cf37e3d29b3c74069cdf1ee1e3c9"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d2c16e3508c8cc73e96aa5127d0df8913d2290098f776416a4b157657bee44c5"}, + {file = "ruff-0.8.1-py3-none-win32.whl", hash = "sha256:93335cd7c0eaedb44882d75a7acb7df4b77cd7cd0d2255c93b28791716e81790"}, + {file = "ruff-0.8.1-py3-none-win_amd64.whl", hash = "sha256:2954cdbe8dfd8ab359d4a30cd971b589d335a44d444b6ca2cb3d1da21b75e4b6"}, + {file = "ruff-0.8.1-py3-none-win_arm64.whl", hash = "sha256:55873cc1a473e5ac129d15eccb3c008c096b94809d693fc7053f588b67822737"}, + {file = "ruff-0.8.1.tar.gz", hash = "sha256:3583db9a6450364ed5ca3f3b4225958b24f78178908d5c4bc0f46251ccca898f"}, ] [[package]] @@ -3092,4 +3090,4 @@ didcommv2 = ["didcomm-messaging"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "c9121c319eb42db81805bec50a15a153e7ef4f8bef5231a6b12a7a74b4ffe290" +content-hash = "59c846da8c32b9e1eb833391d459aecef062e9ba70fd6e788b2ec21d5fdfb0fd" diff --git a/pyproject.toml b/pyproject.toml index de8a3531bc..8810766495 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ repository = "https://github.com/openwallet-foundation/acapy" [tool.poetry.dependencies] python = "^3.12" -aiohttp = "~3.11.7" +aiohttp = "~3.11.9" aiohttp-apispec-acapy = "~3.0.2" aiohttp-cors = "~0.7.0" apispec = "^6.6.0" @@ -34,7 +34,7 @@ packaging = "~23.2" portalocker = "~2.10.1" prompt_toolkit = ">=2.0.9,<2.1.0" pydid = "^0.5.1" -pyjwt = "~2.10.0" +pyjwt = "~2.10.1" pyld = "^2.0.4" pynacl = "~1.5.0" python-dateutil = "^2.9.0" @@ -69,7 +69,7 @@ canonicaljson = "^2.0.0" [tool.poetry.group.dev.dependencies] pre-commit = "~3.8.0" # Sync with version in .pre-commit-config.yaml -ruff = "0.8.0" +ruff = "0.8.1" sphinx = "^5.3.0" sphinx-rtd-theme = ">=0.4.3" @@ -79,7 +79,7 @@ pydevd = "1.5.1" pydevd-pycharm = "~193.7288.30" # testing -pytest = "^8.3.3" +pytest = "^8.3.4" pytest-asyncio = "^0.24.0" pytest-cov = "^5.0.0" pytest-ruff = "^0.4.1" From 389e9d26405601b9611118aacb289e9aa176c018 Mon Sep 17 00:00:00 2001 From: Mourits de Beer <31511766+ff137@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:26:21 +0200 Subject: [PATCH 10/10] :zap: Add class caching to DeferLoad (#3361) Resolves #3360 Signed-off-by: ff137 Co-authored-by: jamshale <31809382+jamshale@users.noreply.github.com> --- acapy_agent/utils/classloader.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/acapy_agent/utils/classloader.py b/acapy_agent/utils/classloader.py index 29fd81bc4d..09d4799aea 100644 --- a/acapy_agent/utils/classloader.py +++ b/acapy_agent/utils/classloader.py @@ -181,18 +181,21 @@ def scan_subpackages(cls, package: str) -> Sequence[str]: class DeferLoad: """Helper to defer loading of a class definition.""" + _class_cache = {} # Shared cache for resolved classes + def __init__(self, cls_path: str): """Initialize the `DeferLoad` instance with a qualified class path.""" self._cls_path = cls_path - self._inst = None def __call__(self, *args, **kwargs): """Magic method to call the `DeferLoad` as a function.""" - return (self.resolved)(*args, **kwargs) + return self.resolved(*args, **kwargs) @property def resolved(self): """Accessor for the resolved class instance.""" - if not self._inst: - self._inst = ClassLoader.load_class(self._cls_path) - return self._inst + if self._cls_path not in DeferLoad._class_cache: + DeferLoad._class_cache[self._cls_path] = ClassLoader.load_class( + self._cls_path + ) + return DeferLoad._class_cache[self._cls_path]