agdsn / pycroft

The AG DSN management system
Apache License 2.0
20 stars 9 forks source link

Replace fixture #25

Closed lukasjuhrich closed 3 years ago

lukasjuhrich commented 8 years ago

Redmine metadata

Attribute Value
done_ratio 0
status New
start_date 2016/03/02
created_on 2016/03/02 11:38:46 +0100
author @shreyder
priority Low
updated_on 2016/09/18 19:13:54 +0200
tracker Bug
asigned_to None

The fixture project ("PyPI":https://pypi.python.org/pypi/fixture "GithHub":https://github.com/fixture-py/fixture "Docs":http://farmdev.com/projects/fixture/) is dead.

It is our only dependency that does not support Python 3, it hasn't seen much development activity lately and the project owner "stated":https://github.com/fixture-py/fixture/issues/21#issuecomment-98429578 that he doesn't use the project anymore.

In the long run, we only have two options

Fixing fixture ourselves (i.e. adding Python 3 support and fixing future problems) and try to get our fixes upstream

Switching to a different project

Both options are not really great and involve a lot of work. Fixture was developed for SQLAlchemy 0.4 among other things and will break in the future. So aside from missing Python 3 support there will be problems and therefore work in the future.

There is no other project with a similar, declarative API. There is the sqlalchemy_fixtures ("PyPI":https://pypi.python.org/pypi/SQLAlchemy-Fixtures "GitHub":https://github.com/kvesteri/sqlalchemy-fixtures "Docs":https://sqlalchemy-fixtures.readthedocs.org/en/latest/) package, which must not be confused with sqlalchemy_fixture ("PyPI":https://pypi.python.org/pypi/sqlalchemy-fixture "BitBucket":https://bitbucket.org/efreeze/sqlalchemy-fixture), which is just a fixture fork or fixture itself, not really clear at this point. sqlalchemy_fixture is just a single file with less than 200 lines, which looks a bit too simple.

The most promising replacements seem to be mixer ("PyPI":https://pypi.python.org/pypi/mixer "GitHub":https://github.com/klen/mixer "Docs":https://mixer.readthedocs.org/en/latest/) and factory_boy ("PyPI":https://pypi.python.org/pypi/factory_boy/ "GitHub":https://github.com/rbarrois/factory_boy "Docs":https://factoryboy.readthedocs.org/en/latest/). Both use a imperative instead of a declarative approach to obtain test data, so either all test data must be converted from declarative fixture DataSets into function calls or a we write wrapper that uses our current declarative DataSets to create the test data with either mixer or factory_boy.

This issue has been automatically imported from redmine on 2016-09-28 19:08:42.330511

lukasjuhrich commented 7 years ago

In the meantime, python3 support has been added (See this commit).

However, I think we should still replace fixture. It is not pleasant to work with, and a lot of things like the batch creation of dummy objects can be handled a lot easier with the alternatives. Granted, they currently appear to be missing Automated creation of fixtures in a simple, declarative way, but that can be fixed. In any way, I think it is a good thing to rethink the fixture workflow, as it took me plenty of time to get testing with the current fixture setup worked out.

Anyway, the important thing at the moment is that we can hopefully port to python3 without having to reference this issue.

lukasjuhrich commented 6 years ago

I just wanted to note that using factory_boy will make creating example data way easier, because the library can easily incorporate a wide variety of fakers (for names etc.) and creating lots of users is as easy as UserFactory.create_batch(500).

lukasjuhrich commented 5 years ago

Related: #340

lukasjuhrich commented 4 years ago

the up-to-date replacement status can be viewed in PR #401

lukasjuhrich commented 3 years ago

Current test failures (when using pytest runner): [moved to #416]