def run_server_wsgi_intercept(dbfilename): host = 'localhost' port = 80 from pony_build import server, coordinator, dbsqlite from pony_build.web import create_publisher, urls dbfile = dbsqlite.open_shelf(dbfilename) dbfile = coordinator.IntDictWrapper(dbfile) ### pbs_app = coordinator.PonyBuildCoordinator(db=dbfile) wsgi_app = create_publisher(pbs_app) #the_server = server.create(host, port, pbs_app, wsgi_app) url = urls.calculate_base_url(host, port) urls.set_base_url(url) twill.add_wsgi_intercept('localhost', port, lambda: wsgi_app) global _server_url, _server_host, _server_port _server_host = host _server_port = port _server_url = 'http://%s:%d/' % (host, port)
def make_db(filename=DB_TEST_FILE): print 'FILENAME', filename try: os.unlink(filename) except OSError: pass db = dbsqlite.open_shelf(filename, 'c') db = coordinator.IntDictWrapper(db) coord = coordinator.PonyBuildCoordinator(db) client_info = dict(success=True, tags=['a_tag'], package='test-underway', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] coord.add_results('120.0.0.127', client_info, results) del coord db.close()
def make_db(filename=DB_TEST_FILE): try: os.unlink(filename) except OSError: pass db = dbsqlite.open_shelf(filename, 'c') db = coordinator.IntDictWrapper(db) coord = coordinator.PonyBuildCoordinator(db) ## CTB: note, make sure to add items to the database in the correct ## order: most recently received ==> last. # mangle the receipt time in the database, in order to test expiration client_info = dict(success=True, tags=['a_tag'], package='test-expire', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] (k, _) = coord.add_results('127.0.0.1', client_info, results) receipt, client_info, results_list = db[k] receipt['time'] = time.time() - 60*60*24 * 10 # -- 10 days ago db[k] = receipt, client_info, results_list # mangle the receipt time in the database, in order to test stale flag. client_info = dict(success=True, tags=['a_tag'], package='test-stale', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] (k, _) = coord.add_results('127.0.0.1', client_info, results) receipt, client_info, results_list = db[k] receipt['time'] = time.time() - 60*60*24 * 2 # -- 2 days ago db[k] = receipt, client_info, results_list # also add a fresh result client_info = dict(success=True, tags=['a_tag'], package='test-underway', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] (k, _) = coord.add_results('127.0.0.1', client_info, results) del coord db.close()
def setup(self): _db = dbsqlite.open_shelf() db = coordinator.IntDictWrapper(_db) self.coord = coordinator.PonyBuildCoordinator(db) self.some_client_info = dict(success=True, tags=['tag1'], package='package1', duration=0.1, host='test-machine', arch='foo') self.tagset = coordinator.build_tagset(self.some_client_info)
def make_db(filename=DB_TEST_FILE): try: os.unlink(filename) except OSError: pass db = dbsqlite.open_shelf(filename, 'c') db = coordinator.IntDictWrapper(db) coord = coordinator.PonyBuildCoordinator(db) client_info = dict(success=True, tags=['a_tag'], package='test-underway', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] coord.add_results('120.0.0.127', client_info, results) del coord db.close()
def make_db(filename=DB_TEST_FILE): try: os.unlink(filename) except OSError: pass db = dbsqlite.open_shelf(filename, 'c') db = coordinator.IntDictWrapper(db) coord = coordinator.PonyBuildCoordinator(db) client_info = dict(success=True, tags=['a_tag'], package='test-underway', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] coord.add_results('120.0.0.127', client_info, results) # mangle the receipt time in the database, in order to test stale flag. client_info = dict(success=True, tags=['a_tag'], package='test-stale', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] k = coord.add_results('120.0.0.127', client_info, results) receipt, client_info, results_list = db[k] receipt['time'] = 0 db[k] = receipt, client_info, results_list del coord db.close()
def make_db(filename=DB_TEST_FILE): try: os.unlink(filename) except OSError: pass db = dbsqlite.open_shelf(filename, 'c') db = coordinator.IntDictWrapper(db) coord = coordinator.PonyBuildCoordinator(db) ## CTB: note, make sure to add items to the database in the correct ## order: most recently received ==> last. # mangle the receipt time in the database, in order to test expiration client_info = dict(success=True, tags=['a_tag'], package='test-expire', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] (k, _) = coord.add_results('127.0.0.1', client_info, results) receipt, client_info, results_list = db[k] receipt['time'] = time.time() - 60 * 60 * 24 * 10 # -- 10 days ago db[k] = receipt, client_info, results_list # mangle the receipt time in the database, in order to test stale flag. client_info = dict(success=True, tags=['a_tag'], package='test-stale', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] (k, _) = coord.add_results('127.0.0.1', client_info, results) receipt, client_info, results_list = db[k] receipt['time'] = time.time() - 60 * 60 * 24 * 2 # -- 2 days ago db[k] = receipt, client_info, results_list # also add a fresh result client_info = dict(success=True, tags=['a_tag'], package='test-underway', duration=0.1, host='testhost', arch='fooarch') results = [ dict(status=0, name='abc', errout='', output='', command=['foo', 'bar'], type='test_the_test') ] (k, _) = coord.add_results('127.0.0.1', client_info, results) del coord db.close()