Closed sjjd26 closed 1 year ago
One thing to look at is the warnings after testing which I think has to do with when the database is cleared due to the order in which this happens? Not completely sure though.
One thing to look at is the warnings after testing which I think has to do with when the database is cleared due to the order in which this happens? Not completely sure though.
I've had a look through the code and am pretty happy with it, I'll spend just a bit looking into this issue myself first too to see if we can solve it.
Edit: I can't tell if that error is all fo the same test_get_plant_invalid_id test, or all 3 tests above it but it seeems the tables for the other objects were deleted before that test was run?
All good for you to merge as far as I am concerned :) If you see the change I made, I just fully destructed the database the way that was already happening at the end of all the tests but instead made this happen per module. Running this and your version didn't really seem to have much of a difference in running time which was my main concern and it removes the warning 😄
Thanks for sorting this out!
Sweet yea I thought about that also but thought it might take too much time, thanks for fixing.
Have reorganised the tests so that the database is reset for each module (each test file). This is done using a setup fixture which now should be included in all tests (only strictly needed in the first test of each module I think but should be safer to just include it in all tests).
Also added a new file called populatetests.py which just includes all of the add(object) functions so that it's all in one place. Along with this is a populate_db function which calls each individual function for a reproducable populated database.
I also tried splitting the tests into classes for each purpose, i.e. a class for get methods and another for post methods in the same file, but I couldn't get the setup fixture to run in any of the class test functions for some reason. This could be explored later but I don't think it's super necessary.