<commit_before># modu
# Copyright (C) 2007-2008 <NAME>
#
# $Id$
#
# See LICENSE for details

"""
Tests for the L{modu.web.app} module.
"""

import os, os.path

from twisted.trial import unittest
from twisted.internet import defer

from zope.interface import implements

from modu.util import test
from modu.web import resource, app
from modu import web

class AppTestCase(unittest.TestCase):
	"""
	Test the WSGI application flow.
	"""
	def get_request(self, uri, form_data={}):
		"""
		The request generator for this TestCase.
		"""
		environ = test.generate_test_wsgi_environment(form_data)
		
		environ['REQUEST_URI'] = uri
		environ['HTTP_HOST'] = '____basic-test-domain____:1234567'
		environ['SERVER_NAME'] = '____basic-test-domain____'
		environ['HTTP_PORT'] = '1234567'
		
		application = app.get_application(environ)
		self.failIf(application is  None, "Didn't get an application object.")
		
		req = app.configure_request(environ, application)
		#queue.activate_content_queue(req)
		
		return req
	
	
	def test_load(self):
		"""
		A functional test for Application instantiation.
		
		This test attempts to load the basic test application defined in
		L{modu.sites.test_site} by creating a sample environ dict, passed
		to L{modu.web.app.get_application()}.
		"""
		environ = test.generate_test_wsgi_environment()		
		application = app.get_application(environ)
		self.failIf(application is not None, "Got an Application object when expecting None.")
		
		environ['HTTP_HOST'] = '____basic-test-domain____:1234567'
		environ['SERVER_NAME'] = '____basic-test-domain____'<commit_msg>added test for JIT req variables<commit_after># modu
# Copyright (C) 2007-2008 <NAME>
#
# $Id$
#
# See LICENSE for details

"""
Tests for the L{modu.web.app} module.
"""

import os, os.path

from twisted.trial import unittest
from twisted.internet import defer

from zope.interface import implements

from modu.util import test
from modu.web import resource, app
from modu import web

class AppTestCase(unittest.TestCase):
	"""
	Test the WSGI application flow.
	"""
	def get_request(self, uri, form_data={}):
		"""
		The request generator for this TestCase.
		"""
		environ = test.generate_test_wsgi_environment(form_data)
		
		environ['REQUEST_URI'] = uri
		environ['HTTP_HOST'] = '____basic-test-domain____:1234567'
		environ['SERVER_NAME'] = '____basic-test-domain____'
		environ['HTTP_PORT'] = '1234567'
		
		application = app.get_application(environ)
		self.failIf(application is  None, "Didn't get an application object.")
		
		req = app.configure_request(environ, application)
		
		return req
	
	def test_jit(self):
		req = self.get_request()
		
		self.failUnless(req.get('modu.session', None) is None)
		self.failUnless(req.get('modu.user', None) is None)
		self.failUnless(req.get('modu.pool', None) is None)
		self.failUnless(req.get('modu.store', None) is None)
	
	def test_load(self):
		"""
		A functional test for Application instantiation.
		
		This test attempts to load the basic test application defined in
		L{modu.sites.test_site} by creating a sample environ dict, passed
		to L{modu.web.app.get_application()}.
		"""
		environ = test.generate_test_wsgi_environment()		
		application = app.get_application(environ)
		self.failIf(application is not None, "Got an Application object when expecting None.")
		
		environ['HTTP_HOST'] = '____basic-test-domain____:1234567'
		environ['SERVER_NAME'] = '____basic-test-domain____'
{'fraction_non_alphanumeric': 0.11396094433109881, 'fraction_numerical': 0.016904692509472456, 'mean_word_length': 4.6262295081967215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5682229', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1090, 'n_words': 293}