Skip to content

Commit 1d962bd

Browse files
committed
Test code was not testing the loop that retries otk database updates
if there is an OS busy error. Hopefully this change will simulate the case where there is a pre-existing otks database and the roundup instance opens the existing otk database rather than opening one that it created.
1 parent 98c80ca commit 1d962bd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/rest_common.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
from roundup.anypy.strings import b2s, s2b
1717
import random
1818

19+
from roundup.backends.sessions_dbm import OneTimeKeys
20+
from roundup.anypy.dbm_ import anydbm, whichdb
21+
1922
from .db_test_base import setupTracker
2023

2124
from .mocknull import MockNull
@@ -39,6 +42,14 @@ def setUp(self):
3942
# open the database
4043
self.db = self.instance.open('admin')
4144

45+
# Create the Otk db.
46+
# This allows a test later on to open the existing db and
47+
# set a class attribute to test the open retry loop
48+
# just as though this process was using a pre-existing db
49+
# rather then the new one we create.
50+
otk = OneTimeKeys(self.db)
51+
otk.set('key', key="value")
52+
4253
# Get user id (user4 maybe). Used later to get data from db.
4354
self.joeid = self.db.user.create(
4455
username='joe',
@@ -629,6 +640,12 @@ def testRestRateLimit(self):
629640
self.db.config['WEB_API_CALLS_PER_INTERVAL'] = 20
630641
self.db.config['WEB_API_INTERVAL_IN_SEC'] = 60
631642

643+
# Otk code never passes through the
644+
# retry loop. Not sure why but I can force it
645+
# through the loop by setting the internal _db_type
646+
# setting once the db is created by the previous command.
647+
self.db.Otk._db_type = whichdb("%s/%s"%(self.db.Otk.dir, self.db.Otk.name))
648+
632649
print("Now realtime start:", datetime.utcnow())
633650
# don't set an accept header; json should be the default
634651
# use up all our allowed api calls

0 commit comments

Comments
 (0)