Skip to content
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

Fix Deprecation Warnings in tests for the next release #1671

Open
7 tasks
m4ra opened this issue Aug 27, 2024 · 1 comment
Open
7 tasks

Fix Deprecation Warnings in tests for the next release #1671

m4ra opened this issue Aug 27, 2024 · 1 comment
Labels
Dev: Backend issue related to backend Prio: Medium fixed and released with next scheduled release

Comments

@m4ra
Copy link
Contributor

m4ra commented Aug 27, 2024

A list of items that need to be fixed from the warnings we get when we run the tests from the root directory:

py.test tests --reuse-db
  • Replace active_phase

active_phase is deprecated, use active_phase_ends_next or active_module_ends_next in the following test:
adhocracy4/adhocracy4/projects/models.py:574

  • Replace is_prj_group_member

using is_prj_group_member with an item is deprecated; use is_context_group_member from module predicates instead.
adhocracy4/adhocracy4/projects/predicates.py:10

  • Replace storage class

tests/projects/test_project_models.py::test_delete_project

.pyenv/versions/3.10.0/envs/a4/lib/python3.10/site-packages/easy_thumbnails/storage.py:27: RemovedInDjango51Warning: django.core.files.storage.get_storage_class is deprecated in favor of using django.core.files.storage.storages.

  • Update TopicFactory

.pyenv/versions/3.10.0/envs/a4/lib/python3.10/site-packages/factory/django.py:181: DeprecationWarning: TopicFactory._after_postgeneration will stop saving the instance after postgeneration hooks in the next major release.
If the save call is extraneous, set skip_postgeneration_save=True in the TopicFactory.Meta.
To keep saving the instance, move the save call to your postgeneration hooks or override _after_postgeneration.

  • Update ProjectFactory

.pyenv/versions/3.10.0/envs/a4/lib/python3.10/site-packages/factory/django.py:181: DeprecationWarning: ProjectFactory._after_postgeneration will stop saving the instance after postgeneration hooks in the next major release.
If the save call is extraneous, set skip_postgeneration_save=True in the ProjectFactory.Meta.
To keep saving the instance, move the save call to your postgeneration hooks or override _after_postgeneration.

  • Update UserFactory

.pyenv/versions/3.10.0/envs/a4/lib/python3.10/site-packages/factory/django.py:181: DeprecationWarning: UserFactory._after_postgeneration will stop saving the instance after postgeneration hooks in the next major release.
If the save call is extraneous, set skip_postgeneration_save=True in the UserFactory.Meta.
To keep saving the instance, move the save call to your postgeneration hooks or override _after_postgeneration.

  • Update OrganisationFactory

.pyenv/versions/3.10.0/envs/a4/lib/python3.10/site-packages/factory/django.py:181: DeprecationWarning: OrganisationFactory._after_postgeneration will stop saving the instance after postgeneration hooks in the next major release.
If the save call is extraneous, set skip_postgeneration_save=True in the OrganisationFactory.Meta.
To keep saving the instance, move the save call to your postgeneration hooks or override _after_postgeneration.

@m4ra m4ra added Prio: Medium fixed and released with next scheduled release Dev: Backend issue related to backend labels Aug 27, 2024
@m4ra
Copy link
Contributor Author

m4ra commented Oct 1, 2024

@rjlanari is this something you would like to work on? The two first items describe the solution inside the quoted text by pointing the file that needs to be edited and what should be changed. So those two fixes are relative easy.

The rest of the items that have to do with factories need some changes in their related fields (ForeignKey field of a Model).
Factories are a method to create data and populate the testing database.
The Topic and Project models are related. See class Topic and class Project here.
So their respective factories TopicFactory and ProjectFactory need to be related too.
Same with the User and Organisation factories.
All these factories are bundled in this file. The relation is marked with a SubFactory
How to handle relations in factories has changed in the current version of the factory package. Thus why we receive these warnings. How to do subfactories from now on, it is explained here.
However if you haven't looked into Django model relations before, I suggest you start from here, before looking into factories.
Have a look and see how far you can go with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev: Backend issue related to backend Prio: Medium fixed and released with next scheduled release
Projects
None yet
Development

No branches or pull requests

1 participant