Closed orelgueta closed 1 year ago
OK there's one more solution which is actually the best I think. We create a special sandbox DB for each pytest instance and empty it after the run. I thought it stays there forever until we manually remove it but apparently MongoDB drops an empty DB automatically. If this indeed works then #513 will close this issue.
Really difficult.
The cleanest would be using the mock feature - as we want to test our code and not the database. But I see the disadvantage (having to learn how it works, another dependency).
I agree that your second point would be best. But I also see that #513 is working, so I stop answering...
Yes, tests worked, let's merge and keep an eye for the future. Glad I tested this random idea I had before implementing something more complicated...
I need some input on how to deal with the current DB issue since it requires taking a decision. First I will describe the test:
test_insert_files_db
, tests the function which inserts a file to the DB.The issue is the following:
Possible solutions:
insert_file_to_db
method is quite central in simtools, but it's also fairly simple so it's not a big deal.None
when we try to read the file we inserted. This should solve the issue when we run simultaneous tests in the CI, but will keep the original functionality of the test when running locally as developing (I vote for this solution for now).db_handler
because it's always better to test the real DB when possible in my opinion.Thoughts @GernotMaier, @VictorBarbosaMartins?