diff --git a/.copier-answers.yml b/.copier-answers.yml index fbdd5f5b0..4c2bd1160 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.29 +_commit: v1.39 _src_path: git+https://github.com/oca/oca-addons-repo-template ci: GitHub convert_readme_fragments_to_markdown: false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..e0d56685a --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +test-requirements.txt merge=union diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index afd7524ef..43b82fe8e 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -17,6 +17,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.11" + cache: 'pip' + cache-dependency-path: '.pre-commit-config.yaml' - name: Get python version run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - uses: actions/cache@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d0f95283..5ec4eb783 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: makepot: "true" services: postgres: - image: postgres:12.0 + image: postgres:12 env: POSTGRES_USER: odoo POSTGRES_PASSWORD: odoo @@ -63,6 +63,13 @@ jobs: run: oca_init_test_database - name: Run tests run: oca_run_tests + - name: Upload screenshots from JS tests + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: Screenshots of failed JS tests - ${{ matrix.name }}${{ join(matrix.include) }} + path: /tmp/odoo_tests/${{ env.PGDATABASE }} + if-no-files-found: ignore - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83a3352c9..9b8df0210 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools - rev: d5fab7ee87fceee858a3d01048c78a548974d935 + rev: f9b919b9868143135a9c9cb03021089cabba8223 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons @@ -107,6 +107,7 @@ repos: additional_dependencies: - "eslint@8.24.0" - "eslint-plugin-jsdoc@" + - "globals@" - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: @@ -143,7 +144,7 @@ repos: - --settings=. exclude: /__init__\.py$ - repo: https://github.com/acsone/setuptools-odoo - rev: 3.1.8 + rev: 3.3.2 hooks: - id: setuptools-odoo-make-default - id: setuptools-odoo-get-requirements diff --git a/.pylintrc b/.pylintrc index 554913276..0a521c31f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -25,19 +25,25 @@ disable=all enable=anomalous-backslash-in-string, api-one-deprecated, api-one-multi-together, - assignment-from-none, - attribute-deprecated, class-camelcase, - dangerous-default-value, dangerous-view-replace-wo-priority, - development-status-allowed, duplicate-id-csv, - duplicate-key, duplicate-xml-fields, duplicate-xml-record-id, eval-referenced, - eval-used, incoherent-interpreter-exec-perm, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -48,73 +54,68 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout, - # messages that do not cause the lint step to fail - consider-merging-classes-inherited, + missing-manifest-dependency, + too-complex,, create-user-wo-reset-password, dangerous-filter-wo-user, - deprecated-module, file-not-used, - invalid-commit, - missing-manifest-dependency, missing-newline-extrafiles, - missing-readme, no-utf8-coding-comment, - odoo-addons-relative-import, old-api7-method-defined, + unnecessary-utf8-coding-comment, + # messages that do not cause the lint step to fail + consider-merging-classes-inherited, + deprecated-module, + invalid-commit, + missing-readme, + odoo-addons-relative-import, redefined-builtin, - too-complex, - unnecessary-utf8-coding-comment + manifest-external-assets [REPORTS] diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 7a0cd4efe..098393aad 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -17,19 +17,25 @@ disable=all enable=anomalous-backslash-in-string, api-one-deprecated, api-one-multi-together, - assignment-from-none, - attribute-deprecated, class-camelcase, - dangerous-default-value, dangerous-view-replace-wo-priority, - development-status-allowed, duplicate-id-csv, - duplicate-key, duplicate-xml-fields, duplicate-xml-record-id, eval-referenced, - eval-used, incoherent-interpreter-exec-perm, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -40,56 +46,50 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout [REPORTS] diff --git a/README.md b/README.md index 48137f08c..d9fd89988 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ +[![Support the OCA](https://odoo-community.org/readme-banner-image)](https://odoo-community.org/get-involved?utm_source=repo-readme) + +# Rest Frameworks [![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=16.0) [![Pre-commit Status](https://github.com/OCA/rest-framework/actions/workflows/pre-commit.yml/badge.svg?branch=16.0)](https://github.com/OCA/rest-framework/actions/workflows/pre-commit.yml?query=branch%3A16.0) [![Build Status](https://github.com/OCA/rest-framework/actions/workflows/test.yml/badge.svg?branch=16.0)](https://github.com/OCA/rest-framework/actions/workflows/test.yml?query=branch%3A16.0) @@ -7,8 +10,6 @@ -# Rest Frameworks - This repository has nice modules to interact with Odoo using JSON and HTTP requests. diff --git a/extendable_fastapi/tests/test_generic_extendable.py b/extendable_fastapi/tests/test_generic_extendable.py index 195c29780..60ec28205 100644 --- a/extendable_fastapi/tests/test_generic_extendable.py +++ b/extendable_fastapi/tests/test_generic_extendable.py @@ -87,7 +87,11 @@ def test_post_user(self): with self._create_test_client(router=demo_pydantic_router) as test_client: response: Response = test_client.post( - "/post_user", content=pydantic_data.model_dump_json() + "/post_user", + headers={ + "Content-Type": "application/json", + }, + content=pydantic_data.model_dump_json(), ) self.assertEqual(response.status_code, 200) res = response.json() @@ -115,7 +119,11 @@ def test_post_private_user(self): with self._create_test_client(router=demo_pydantic_router) as test_client: response: Response = test_client.post( - "/post_private_user", content=pydantic_data.model_dump_json() + "/post_private_user", + headers={ + "Content-Type": "application/json", + }, + content=pydantic_data.model_dump_json(), ) self.assertEqual(response.status_code, 200) user = response.json() @@ -143,7 +151,11 @@ def test_post_private_user_generic(self): with self._create_test_client(router=demo_pydantic_router) as test_client: response: Response = test_client.post( - "/post_private_user_generic", content=pydantic_data.model_dump_json() + "/post_private_user_generic", + headers={ + "Content-Type": "application/json", + }, + content=pydantic_data.model_dump_json(), ) self.assertEqual(response.status_code, 200) res = response.json() @@ -204,5 +216,9 @@ def test_extra_forbid_response_fails(self): router=demo_pydantic_router ) as test_client: test_client.post( - "/post_private_customer", content=pydantic_data.model_dump_json() + "/post_private_customer", + headers={ + "Content-Type": "application/json", + }, + content=pydantic_data.model_dump_json(), ) diff --git a/fastapi_auth_partner/tests/test_auth.py b/fastapi_auth_partner/tests/test_auth.py index 04f24ccf5..a7267a045 100644 --- a/fastapi_auth_partner/tests/test_auth.py +++ b/fastapi_auth_partner/tests/test_auth.py @@ -45,6 +45,9 @@ def _register_partner(self): with self._create_test_client() as test_client, self.new_mails() as new_mails: response: Response = test_client.post( "/auth/register", + headers={ + "Content-Type": "application/json", + }, content=json.dumps( { "name": "Loriot", @@ -59,6 +62,9 @@ def _register_partner(self): def _login(self, test_client, password="supersecret"): response: Response = test_client.post( "/auth/login", + headers={ + "Content-Type": "application/json", + }, content=json.dumps( { "login": "loriot@example.org", @@ -105,6 +111,9 @@ def test_request_reset_password(self): with self._create_test_client() as test_client, self.new_mails() as new_mails: response: Response = test_client.post( "/auth/request_reset_password", + headers={ + "Content-Type": "application/json", + }, content=json.dumps({"login": "loriot@example.org"}), ) self.assertEqual(response.status_code, status.HTTP_200_OK, response.text) @@ -121,6 +130,9 @@ def test_request_reset_password(self): token = str(new_mails.body).split("token=")[1].split('">')[0] response: Response = test_client.post( "/auth/set_password", + headers={ + "Content-Type": "application/json", + }, content=json.dumps( { "password": "megasecret", @@ -155,6 +167,9 @@ def test_validate_email(self): with self._create_test_client() as test_client: response: Response = test_client.post( "/auth/validate_email", + headers={ + "Content-Type": "application/json", + }, content=json.dumps({"token": token}), ) self.assertEqual(response.status_code, status.HTTP_200_OK, response.text) diff --git a/fastapi_auth_partner/tests/test_fastapi_auth_partner_demo.py b/fastapi_auth_partner/tests/test_fastapi_auth_partner_demo.py index 0539cef17..f6651b99a 100644 --- a/fastapi_auth_partner/tests/test_fastapi_auth_partner_demo.py +++ b/fastapi_auth_partner/tests/test_fastapi_auth_partner_demo.py @@ -48,6 +48,9 @@ def _register_partner(self): return self.url_open( "/fastapi_auth_partner_demo/auth/register", timeout=1000, + headers={ + "Content-Type": "application/json", + }, data=json.dumps( { "name": "Loriot",