# randomly add many more optional flags
}
- word_count = int( (random.random() * 3) % 3) + 1 # search phrase has 1-4 words
- search_term = ''
-
- for i in range(0, word_count):
- word = words[ int(random.random() * len(words)) ]
- search_term += '%s ' % word[0:len(word)-1]
-
+ search_term = eg_utils.random_phrase(None, 3) # search phrase has 1-3 words
logInfo('Search term="%s" args="%s"' % (search_term, str(search_args)))
res = eg_tasks.TASKS['BibSearchTask'].run(
registerTask(UserTransactionsByType())
+class UserSearchTask(AbstractMethodTask):
+
+ def __init__(self):
+ AbstractMethodTask.__init__(self)
+ self.service = 'open-ils.actor'
+ self.method = 'open-ils.actor.patron.search.advanced'
+
+ def run(self, **kw):
+ return self.runMethod(eg_utils.authtoken(), kw['search_args'], 100)
+
+registerTask(UserSearchTask())
+
--- /dev/null
+from constrictor.task import Task
+from constrictor.script import Script, ScriptManager, ScriptThread
+from constrictor.log import *
+import eg_utils, eg_data, eg_tasks
+import random
+
+eg_utils.init()
+
+class UserSearchScript(Script):
+
+ def run(self):
+
+ dm = eg_data.DataManager()
+
+ # TODO pull names from the cencus data files we have for generating test users
+ search_args = {
+ 'family_name' : {'value' : eg_utils.random_phrase(1), 'group' : 0},
+ 'first_given_name' : {'value' : eg_utils.random_phrase(1), 'group' : 0}
+ }
+
+ logInfo('Search for patron %s' % str(search_args))
+
+ try:
+ res = eg_tasks.TASKS['UserSearchTask'].run(search_args = search_args)
+
+ logInfo('Search returned %d hits' % len(res))
+ except Exception, e:
+ logErrror(e)
+
+ return True
+
+ScriptManager.go(UserSearchScript())
+
+
+
from oils.utils.utils import md5sum
from oils.event import Event
from oils.const import *
-import os, errno
+import os, errno, random
props = Properties.getProperties()
+words = None
def init():
+ global words
loadIDL()
initOsrf()
props.setProperty('evergreen.orgIDs', str(user.home_ou()))
+ words_file = open('/usr/share/dict/words') # add config property
+ words = words_file.readlines()
+ words_file.close()
def initOsrf():
class ILSEventException(Exception):
pass
+
+def random_phrase(num_words, max_num_words=3):
+
+ if num_words is None:
+ num_words = int( (random.random() * max_num_words) % max_num_words) + 1
+
+ phrase = ''
+
+ for i in range(0, num_words):
+ word = words[ int(random.random() * len(words)) ]
+ phrase += '%s ' % word[0:len(word)-1]
+
+ return phrase
+