Exemplo n.º 1
0
    def test_mobilizeable(self):
        from mobilize.httputil import mobilizeable
        # Test requests that are expected to be mobilizeable
        testdata_yes = [
            {'content-type' : 'text/html'},
            {'content-type' : 'application/xhtml+xml'},
            ]

        testdata_no = [
            {'content-type' : 'text/css'},
            {'content-type' : 'image/png'},
            ]
        for ii, headers in enumerate(testdata_yes):
            self.assertTrue(mobilizeable(headers), ii)
        for ii, headers in enumerate(testdata_no):
            self.assertFalse(mobilizeable(headers), ii)
Exemplo n.º 2
0
 def test_mobilizeable(self):
     '''tests for mobilize.httputil.mobilizeable'''
     testdata = [
         {'is_m' : False,
          'headers' : dict([('date', 'Tue, 05 Oct 2010 22:32:54 GMT'), ('connection', 'Keep-Alive'), ('etag', '"5e60d8-37e-491aadf613440"'), ('keep-alive', 'timeout=15, max=100'), ('server', 'Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch mod_wsgi/3.2 Python/2.6.6 mod_perl/2.0.4 Perl/v5.10.0'), ('content-type', 'image/x-icon')]),
          },
         {'is_m' : False,
          'headers' : {
                 'content-type' : 'image/x-icon',
                 },
          },
         {'is_m' : False,
          'headers' : {
                 'content-type' : 'text/css',
                 },
          },
         {'is_m' : False,
          'headers' : {
                 'content-type' : 'text/plain',
                 },
          },
         {'is_m' : True,
          'headers' : {
                 'content-type' : 'text/html',
                 },
          },
         {'is_m' : True,
          'headers' : {
                 'content-type' : 'application/xhtml+xml',
                 },
          },
         ]
     from mobilize.httputil import mobilizeable
     for ii, td in enumerate(testdata):
         resp = td['headers']
         expected = td['is_m']
         actual = mobilizeable(resp)
         msg = 'e: %s, a: %s [%d]' % (expected, actual, ii)
         self.assertEqual(expected, actual, msg)