def _test_import(self, env, filename, sheet = 1): req = Request({'SERVER_PORT': 0, 'SERVER_NAME': 'any', 'wsgi.url_scheme': 'any', 'wsgi.input': 'any', 'REQUEST_METHOD': 'GET' }, lambda x, y: _printme) try: from trac.test import MockPerm req.perm = MockPerm() except ImportError: pass req.authname = 'testuser' req.hdf = HDFWrapper([]) # replace by this if you want to generate HTML: req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs()) db = env.get_db_cnx() cursor = db.cursor() _exec(cursor, "select * from enum") enums_before = cursor.fetchall() _exec(cursor, "select * from component") components_before = cursor.fetchall() #print enums_before # when testing, always use the same time so that the results are comparable #print "importing " + filename + " with tickettime " + str(ImporterTestCase.TICKET_TIME) template, content_type = ImportModule(env)._do_import(filename, sheet, req, filename, ImporterTestCase.TICKET_TIME) #sys.stdout = tempstdout #req.display(template, content_type or 'text/html') #open('/tmp/out.html', 'w').write(req.hdf.render(template, None)) _exec(cursor, "select * from ticket") tickets = cursor.fetchall() _exec(cursor, "select * from ticket_custom") tickets_custom = cursor.fetchall() _exec(cursor, "select * from ticket_change") tickets_change = cursor.fetchall() _exec(cursor, "select * from enum") enums = [f for f in set(cursor.fetchall()) - set(enums_before)] _exec(cursor, "select * from component") components = [f for f in set(cursor.fetchall()) - set(components_before)] pp = pprint.PrettyPrinter(indent=4) return pp.pformat([ tickets, tickets_custom, tickets_change, enums, components ])
def _test_preview(self, env, filename): req = Request({'SERVER_PORT': 0, 'SERVER_NAME': 'any', 'wsgi.url_scheme': 'any', 'wsgi.input': 'any', 'REQUEST_METHOD': 'GET' }, lambda x, y: _printme) try: from trac.test import MockPerm req.perm = MockPerm() except ImportError: pass req.authname = 'testuser' req.hdf = HDFWrapper([]) # replace by this if you want to generate HTML: req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs()) template, content_type = ImportModule(env)._do_preview(filename, 1, req) #sys.stdout = tempstdout #req.display(template, content_type or 'text/html') #open('/tmp/out.html', 'w').write(req.hdf.render(template, None)) return str(req.hdf) + "\n"
def _test_import(self, env, filename, sheet=1): req = Request( { 'SERVER_PORT': 0, 'SERVER_NAME': 'any', 'wsgi.url_scheme': 'any', 'wsgi.input': 'any', 'REQUEST_METHOD': 'GET' }, lambda x, y: _printme) try: from trac.test import MockPerm req.perm = MockPerm() except ImportError: pass req.authname = 'testuser' req.hdf = HDFWrapper( [] ) # replace by this if you want to generate HTML: req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs()) db = env.get_db_cnx() cursor = db.cursor() _exec(cursor, "select * from enum") enums_before = cursor.fetchall() _exec(cursor, "select * from component") components_before = cursor.fetchall() #print enums_before # when testing, always use the same time so that the results are comparable #print "importing " + filename + " with tickettime " + str(ImporterTestCase.TICKET_TIME) template, content_type = ImportModule(env)._do_import( filename, sheet, req, filename, ImporterTestCase.TICKET_TIME) #sys.stdout = tempstdout #req.display(template, content_type or 'text/html') #open('/tmp/out.html', 'w').write(req.hdf.render(template, None)) _exec(cursor, "select * from ticket") tickets = cursor.fetchall() _exec(cursor, "select * from ticket_custom") tickets_custom = cursor.fetchall() _exec(cursor, "select * from ticket_change") tickets_change = cursor.fetchall() _exec(cursor, "select * from enum") enums = [f for f in set(cursor.fetchall()) - set(enums_before)] _exec(cursor, "select * from component") components = [ f for f in set(cursor.fetchall()) - set(components_before) ] pp = pprint.PrettyPrinter(indent=4) return pp.pformat( [tickets, tickets_custom, tickets_change, enums, components])
def _test_preview(self, env, filename): req = Request( { 'SERVER_PORT': 0, 'SERVER_NAME': 'any', 'wsgi.url_scheme': 'any', 'wsgi.input': 'any', 'REQUEST_METHOD': 'GET' }, lambda x, y: _printme) try: from trac.test import MockPerm req.perm = MockPerm() except ImportError: pass req.authname = 'testuser' req.hdf = HDFWrapper( [] ) # replace by this if you want to generate HTML: req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs()) template, content_type = ImportModule(env)._do_preview( filename, 1, req) #sys.stdout = tempstdout #req.display(template, content_type or 'text/html') #open('/tmp/out.html', 'w').write(req.hdf.render(template, None)) return str(req.hdf) + "\n"