extend test-cases to check the database is still operable (not locked) after all the errors during the simulation

pull/2171/head
sebres 2018-07-05 16:23:33 +02:00
parent 3be82a9ce9
commit bd54d472b3
1 changed files with 8 additions and 0 deletions

View File

@ -268,6 +268,7 @@ class DatabaseTest(LogCaptureTestCase):
self.assertEqual(readtickets[i].getIP(), ticket.getIP())
self.assertEqual(len(readtickets[i].getMatches()), len(ticket.getMatches()))
self.pruneLog('[test-phase 2] simulate errors')
## simulate errors in dumps/loads:
priorEnc = database.PREFER_ENC
try:
@ -287,6 +288,13 @@ class DatabaseTest(LogCaptureTestCase):
finally:
database.PREFER_ENC = priorEnc
## check the database is still operable (not locked) after all the errors:
self.pruneLog('[test-phase 3] still operable?')
self.db.addBan(self.jail, FailTicket("127.0.0.8"))
readtickets = self.db.getBans(jail=self.jail)
self.assertEqual(len(readtickets), 15)
self.assertNotLogged("json loads failed", "json dumps failed")
def _testAdd3Bans(self):
self.testAddJail()
for i in (1, 2, 3):