jbholden / cdcpool_google

0 stars 1 forks source link

Tests with errors may corrupt database #19

Closed jbholden closed 10 years ago

jbholden commented 10 years ago

This issue is intended for informational purposes, so I will close it after the comment.

Some of the tests (specifically test update and test timezone) may leave the database in a bad state if an error occurs while running the test.

The reason is that the test creates objects in the datastore for the test, and then deletes them after the test completes. If an error occurs, the test may not delete the datastore objects that it created. As a result, this may cause other tests to fail.

I have found a couple of solutions to this:

Editing the database

Deleting players You can delete players with certain years by going to the admin address, interactive console, and execute this code (substitute the year number you are deleting)

query = db.GqlQuery("SELECT * from Player WHERE years IN :year",year=[1979])
for q in query:
   print q.name
   db.delete(q)

Timezone test error if an error occurs during the timezone test, then there may be some Game objects left in the datastore that will cause the games database test to fail. To fix this:

jbholden commented 10 years ago

One more comment about test time. Whenever a test creates and delete datastore objects, this usually requires a long time to run. It took me about an hour to run all the tests.