Exemple #1
0
 def test_request_mobilizeable(self):
     from mobilize.httputil import RequestInfo
     env_noajax = dict(wsgienviron())
     reqinfo_noajax = RequestInfo(env_noajax)
     self.assertTrue(reqinfo_noajax.mobilizeable)
     
     env_ajax = dict(wsgienviron())
     env_ajax['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
     reqinfo_ajax = RequestInfo(env_ajax)
     self.assertFalse(reqinfo_ajax.mobilizeable)
Exemple #2
0
 def test_get_request_headers(self):
     expected = {
          'Content-Length': '151',
          'Content-Type' : 'application/x-www-form-urlencoded',
          'Host': 'example.com',
          'Accept-Language': 'en-us,en;q=0.5',
          'Accept-Encoding': 'identity',
          'Keep-Alive': '115',
          'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
          'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100710 Firefox/3.6.7',
          'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
          'Connection': 'keep-alive',
          'Referer': 'http://example.mwuclient.com:2280/windsong_place_contact.html',
          'Pragma': 'no-cache',
          'Cache-Control': 'no-cache',
          'X-Forwarded-For' : '10.0.2.2',
          'X-MWU-Mobilize' : '1',
          }
     from mobilize.httputil import RequestInfo
     reqinfo = RequestInfo(wsgienviron())
     actual = reqinfo.headers({})
     self.assertDictEqual(expected, actual)
     self.assertEqual(reqinfo.body, 'hello')
     self.assertEqual(reqinfo.method, 'POST')
     self.assertEqual(reqinfo.url, 'http://example.com/Scripts/FormMail_WP2.asp')
     self.assertEqual(reqinfo.rel_url, '/Scripts/FormMail_WP2.asp')
Exemple #3
0
 def test_rawheaders(self):
     from mobilize.httputil import RequestInfo
     reqinfo = RequestInfo(wsgienviron())
     rawheaders = reqinfo.rawheaders()
     self.assertTrue(type(rawheaders) is dict, type(rawheaders))
     self.assertSequenceEqual('Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100710 Firefox/3.6.7', rawheaders['User-Agent'])