UCL-INGI / INGInious

INGInious is a secure and automated exercises assessment platform using your own tests, also providing a pluggable interface with your existing LMS.
http://www.inginious.org
Other
208 stars 140 forks source link

[testing] Database Seeder for testing purposes #818

Open Donaschmi opened 2 years ago

Donaschmi commented 2 years ago

It is sometimes necessary to test functionalities that would require manually creating models (courses, students, tasks, ...) and it can quickly become cumbersome.

One solution to this is a database seeder (programmatically or CLI) that can create one or multiple instances of a model and related models.

For example, if I want to create a course with 100 fake students I can specify it when calling the seeder:

python3 seeder.py --model Course --fields name=lorem --with model=Student,count=100

(don't mind the parameter syntax, it is just an example)

Let's discuss if you think this would be useful.

anthonygego commented 2 years ago

Useful yes, but probably not as simple as it may seem.

There is no modeling layer in INGInious for now and many checks are done in the app logic. Writing such a tool with the code as is may lead to a lot of duplicate code to perform validity and integrity checks.

Moreover, there historically are two data storages that are still not merged: the MongoDB database and the course data and backup filesystems that have limited but existing relations. The plan at this time is still to put every non-file data in MongoDB and expose the data through filesystem emulation (using the webdav library). That would increase the overall application performance and ease the usage of a modelling layer that will be able to perform basic integrity checks that are currently done in the application logic.

In conclusion, writing such a tool right now or in the (near) future would require at least some refactors in several parts of the code to avoid duplicating a lot of quite sensible code.