-
Notifications
You must be signed in to change notification settings - Fork 327
Concatenate error messages for the same path #2273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
aleph/tests/test_view_util.py
Outdated
| with self.assertRaises(BadRequest): | ||
| validate(data, schema) | ||
|
|
||
| # and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know how to check that error was raised and verify error details in one run 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can store the context in a variable if you want. Something like this should work:
with self.assertRaises(BadRequest) as ctx:
validate(data, schema)
self.assertEqual(ctx.exception.response.get_json().get("errors"), {"name": "'Bob' is too short", "password": "'1234' is too short"})There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the relevant section in the Python docs for reference: https://docs.python.org/3/library/unittest.html#:~:text=The%20context%20manager%20will%20store%20the%20caught%20exception%20object%20in%20its%20exception%20attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sunu thanks, that worked!
|
Thanks for raising this pull request @msmych we are taking a look now and we'll get back to you with any feedback. Needless to say we really appreciate you taking the time to work on this. |
sunu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @msmych, apart from the issue you've mentioned about the tests, this looks great! We can merge this in once you remove the duplicate calls in the tests.
aleph/tests/test_view_util.py
Outdated
| with self.assertRaises(BadRequest): | ||
| validate(data, schema) | ||
|
|
||
| # and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can store the context in a variable if you want. Something like this should work:
with self.assertRaises(BadRequest) as ctx:
validate(data, schema)
self.assertEqual(ctx.exception.response.get_json().get("errors"), {"name": "'Bob' is too short", "password": "'1234' is too short"})
aleph/tests/test_view_util.py
Outdated
| with self.assertRaises(BadRequest): | ||
| validate(data, schema) | ||
|
|
||
| # and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the relevant section in the Python docs for reference: https://docs.python.org/3/library/unittest.html#:~:text=The%20context%20manager%20will%20store%20the%20caught%20exception%20object%20in%20its%20exception%20attribute.
|
@sunu updated |
|
Thank you @msmych! |
* Bump flask from 2.0.2 to 2.0.3 (#2136) Bumps [flask](https://github.com/pallets/flask) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/pallets/flask/releases) - [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst) - [Commits](pallets/flask@2.0.2...2.0.3) --- updated-dependencies: - dependency-name: flask dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.8.2 to 2.8.3 in /ui (#2142) * Bump followthemoney from 2.8.2 to 2.8.3 (#2141) * Bump servicelayer[amazon,google] from 1.18.2 to 1.19.0 (#2143) * Set the node-sass version to 6.0.1 until we can start using dart instead (#2145) * Bump normality from 2.2.5 to 2.3.1 (#2153) * Bump sqlalchemy from 1.4.31 to 1.4.32 (#2148) * Fix search handler on home screen The `HomeScreen` component needs to be wrapped in the `withRouter` HOC in order to have access to the `navigate` prop. * Bump followthemoney from 2.8.3 to 2.8.5 (#2166) * Bump urllib3 from 1.26.8 to 1.26.9 (#2165) * Bump alembic from 1.7.6 to 1.7.7 (#2161) * Bump @alephdata/followthemoney from 2.8.3 to 2.8.4 in /ui (#2151) * Add French translations into Aleph * Fix helm build following recommendation and switching from using @master to @v0 * Bump @blueprintjs/core from 3.52.0 to 3.54.0 in /ui (#2172) * Bump @formatjs/intl-relativetimeformat from 9.5.2 to 10.0.1 in /ui (#2184) * Bump @blueprintjs/select from 3.18.11 to 3.19.1 in /ui (#2181) * Bump flask-talisman from 0.8.1 to 1.0.0 (#2167) * Bump @alephdata/followthemoney from 2.8.4 to 2.9.0 in /ui (#2197) * Bump normality from 2.3.1 to 2.3.2 (#2177) * Bump followthemoney from 2.8.5 to 2.9.0 (#2186) * Fixed Gunicorn worker timout issue (#2226) Co-authored-by: Grypus <grypus@Grypus.local> * Remove ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl (#2242) * Remove ALEPH_APP_TITLE and ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl * ALEPH_APP_TITLE back Co-authored-by: Matvey <realsmych@gmail.com> * Bump followthemoney from 2.9.0 to 2.9.1 (#2221) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump normality from 2.3.2 to 2.3.3 (#2212) Bumps [normality](https://github.com/pudo/normality) from 2.3.2 to 2.3.3. - [Release notes](https://github.com/pudo/normality/releases) - [Commits](pudo/normality@2.3.2...2.3.3) --- updated-dependencies: - dependency-name: normality dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.9.0 to 2.9.1 in /ui (#2230) Bumps [@alephdata/followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: "@alephdata/followthemoney" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jsonschema from 4.4.0 to 4.5.1 (#2258) Bumps [jsonschema](https://github.com/python-jsonschema/jsonschema) from 4.4.0 to 4.5.1. - [Release notes](https://github.com/python-jsonschema/jsonschema/releases) - [Changelog](https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst) - [Commits](python-jsonschema/jsonschema@v4.4.0...v4.5.1) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump file-selector from 0.2.4 to 0.6.0 in /ui (#2253) Bumps [file-selector](https://github.com/react-dropzone/file-selector) from 0.2.4 to 0.6.0. - [Release notes](https://github.com/react-dropzone/file-selector/releases) - [Commits](react-dropzone/file-selector@v0.2.4...v0.6.0) --- updated-dependencies: - dependency-name: file-selector dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump sqlalchemy from 1.4.32 to 1.4.36 (#2240) Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.4.32 to 1.4.36. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES.rst) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) --- updated-dependencies: - dependency-name: sqlalchemy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update cryptography requirement (#2241) Updates the requirements on [cryptography](https://github.com/pyca/cryptography) to permit the latest version. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](pyca/cryptography@36.0.0...37.0.0) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump apispec from 5.1.1 to 5.2.1 (#2247) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.1.1 to 5.2.1. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.1.1...5.2.1) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add config file examples for traefik/keycloak/minio setup (#2260) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS (#2246) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS * Move is_auto_admin to aleph.util * Add newline Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Tarashish Mishra <sunu@users.noreply.github.com> * Bump followthemoney from 2.9.1 to 2.9.2 (#2267) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.1 to 2.9.2. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.1...v2.9.2) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the FtM version, should fix trips (#2279) * Bump apispec from 5.2.1 to 5.2.2 (#2272) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.2.1...5.2.2) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump babel from 2.9.1 to 2.10.1 (#2224) Bumps [babel](https://github.com/python-babel/babel) from 2.9.1 to 2.10.1. - [Release notes](https://github.com/python-babel/babel/releases) - [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES.rst) - [Commits](python-babel/babel@v2.9.1...v2.10.1) --- updated-dependencies: - dependency-name: babel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Concatenate error messages for the same path (#2273) * Concatenate error messages for the same path * Simplify tests Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Steve Haffenden <steve.haffenden@gmail.com> Co-authored-by: Till Prochaska <mail@tillprochaska.de> Co-authored-by: PitaHat <79198460+PitaHat@users.noreply.github.com> Co-authored-by: Grypus <grypus@Grypus.local> Co-authored-by: Matvey Smychkov <msmych@yandex.com> Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Marina Brown <catskillmarina@gmail.com>
* Bump flask from 2.0.2 to 2.0.3 (#2136) Bumps [flask](https://github.com/pallets/flask) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/pallets/flask/releases) - [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst) - [Commits](pallets/flask@2.0.2...2.0.3) --- updated-dependencies: - dependency-name: flask dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.8.2 to 2.8.3 in /ui (#2142) * Bump followthemoney from 2.8.2 to 2.8.3 (#2141) * Bump servicelayer[amazon,google] from 1.18.2 to 1.19.0 (#2143) * Set the node-sass version to 6.0.1 until we can start using dart instead (#2145) * Bump normality from 2.2.5 to 2.3.1 (#2153) * Bump sqlalchemy from 1.4.31 to 1.4.32 (#2148) * Fix search handler on home screen The `HomeScreen` component needs to be wrapped in the `withRouter` HOC in order to have access to the `navigate` prop. * Bump followthemoney from 2.8.3 to 2.8.5 (#2166) * Bump urllib3 from 1.26.8 to 1.26.9 (#2165) * Bump alembic from 1.7.6 to 1.7.7 (#2161) * Bump @alephdata/followthemoney from 2.8.3 to 2.8.4 in /ui (#2151) * Add French translations into Aleph * Fix helm build following recommendation and switching from using @master to @v0 * Bump @blueprintjs/core from 3.52.0 to 3.54.0 in /ui (#2172) * Bump @formatjs/intl-relativetimeformat from 9.5.2 to 10.0.1 in /ui (#2184) * Bump @blueprintjs/select from 3.18.11 to 3.19.1 in /ui (#2181) * Bump flask-talisman from 0.8.1 to 1.0.0 (#2167) * Bump @alephdata/followthemoney from 2.8.4 to 2.9.0 in /ui (#2197) * Bump normality from 2.3.1 to 2.3.2 (#2177) * Bump followthemoney from 2.8.5 to 2.9.0 (#2186) * Fixed Gunicorn worker timout issue (#2226) Co-authored-by: Grypus <grypus@Grypus.local> * Remove ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl (#2242) * Remove ALEPH_APP_TITLE and ALEPH_SAMPLE_SEARCHES from aleph.env.tmpl * ALEPH_APP_TITLE back Co-authored-by: Matvey <realsmych@gmail.com> * Bump followthemoney from 2.9.0 to 2.9.1 (#2221) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump normality from 2.3.2 to 2.3.3 (#2212) Bumps [normality](https://github.com/pudo/normality) from 2.3.2 to 2.3.3. - [Release notes](https://github.com/pudo/normality/releases) - [Commits](pudo/normality@2.3.2...2.3.3) --- updated-dependencies: - dependency-name: normality dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @alephdata/followthemoney from 2.9.0 to 2.9.1 in /ui (#2230) Bumps [@alephdata/followthemoney](https://github.com/alephdata/followthemoney) from 2.9.0 to 2.9.1. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.0...v2.9.1) --- updated-dependencies: - dependency-name: "@alephdata/followthemoney" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jsonschema from 4.4.0 to 4.5.1 (#2258) Bumps [jsonschema](https://github.com/python-jsonschema/jsonschema) from 4.4.0 to 4.5.1. - [Release notes](https://github.com/python-jsonschema/jsonschema/releases) - [Changelog](https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst) - [Commits](python-jsonschema/jsonschema@v4.4.0...v4.5.1) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump file-selector from 0.2.4 to 0.6.0 in /ui (#2253) Bumps [file-selector](https://github.com/react-dropzone/file-selector) from 0.2.4 to 0.6.0. - [Release notes](https://github.com/react-dropzone/file-selector/releases) - [Commits](react-dropzone/file-selector@v0.2.4...v0.6.0) --- updated-dependencies: - dependency-name: file-selector dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump sqlalchemy from 1.4.32 to 1.4.36 (#2240) Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.4.32 to 1.4.36. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES.rst) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) --- updated-dependencies: - dependency-name: sqlalchemy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update cryptography requirement (#2241) Updates the requirements on [cryptography](https://github.com/pyca/cryptography) to permit the latest version. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](pyca/cryptography@36.0.0...37.0.0) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump apispec from 5.1.1 to 5.2.1 (#2247) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.1.1 to 5.2.1. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.1.1...5.2.1) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add config file examples for traefik/keycloak/minio setup (#2260) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS (#2246) * Pass is_admin to Role#load_or_create() based on ALEPH_ADMINS * Move is_auto_admin to aleph.util * Add newline Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Tarashish Mishra <sunu@users.noreply.github.com> * Bump followthemoney from 2.9.1 to 2.9.2 (#2267) Bumps [followthemoney](https://github.com/alephdata/followthemoney) from 2.9.1 to 2.9.2. - [Release notes](https://github.com/alephdata/followthemoney/releases) - [Commits](alephdata/followthemoney@v2.9.1...v2.9.2) --- updated-dependencies: - dependency-name: followthemoney dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the FtM version, should fix trips (#2279) * Bump apispec from 5.2.1 to 5.2.2 (#2272) Bumps [apispec](https://github.com/marshmallow-code/apispec) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/marshmallow-code/apispec/releases) - [Changelog](https://github.com/marshmallow-code/apispec/blob/dev/CHANGELOG.rst) - [Commits](marshmallow-code/apispec@5.2.1...5.2.2) --- updated-dependencies: - dependency-name: apispec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump babel from 2.9.1 to 2.10.1 (#2224) Bumps [babel](https://github.com/python-babel/babel) from 2.9.1 to 2.10.1. - [Release notes](https://github.com/python-babel/babel/releases) - [Changelog](https://github.com/python-babel/babel/blob/master/CHANGES.rst) - [Commits](python-babel/babel@v2.9.1...v2.10.1) --- updated-dependencies: - dependency-name: babel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Concatenate error messages for the same path (#2273) * Concatenate error messages for the same path * Simplify tests Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tarashish Mishra <sunu0000@gmail.com> Co-authored-by: Till Prochaska <mail@tillprochaska.de> Co-authored-by: PitaHat <79198460+PitaHat@users.noreply.github.com> Co-authored-by: Grypus <grypus@Grypus.local> Co-authored-by: Matvey Smychkov <msmych@yandex.com> Co-authored-by: Matvey <realsmych@gmail.com> Co-authored-by: Marina Brown <catskillmarina@gmail.com> Co-authored-by: Tarashish Mishra <sunu@users.noreply.github.com>
When there are multiple validation errors for the same path, the response error messages get overrided
This PR fixes that by concatenating error messages for the same path