class QueryStringHandlerTester(unittest.TestCase): def setUp(self): self.handler = QueryStringHandler() def testInvalidQueryString(self): self.assertEqual(self.handler.getReport('gunniAwesome'), None) def testLegalQueryString(self): self.assertNotEqual(self.handler.getReport('1eh3'), None) def testNoneQueryString(self): self.assertEqual(self.handler.getReport(None), None)
class ThreadHelper(threading.Thread): def __init__(self, queue, report, lock): threading.Thread.__init__(self) self.handler = QueryStringHandler() self.queue = queue self.report = report self.lock = lock def run(self): while True: try: print "Items left in queue: " + str(self.queue.qsize()) dataSetReport = self.handler.getReport(self.queue.get()) if dataSetReport: self.lock.acquire() self.report.append(dataSetReport) self.lock.release() except Queue.Empty, e: logging.error(e) except thread.error, e: logging.error(e) except:
def __init__(self, queue, report, lock): threading.Thread.__init__(self) self.handler = QueryStringHandler() self.queue = queue self.report = report self.lock = lock
def setUp(self): self.handler = QueryStringHandler()