示例#1
0
 def test_additional(self):
     """Test with Content-Type header with additional informations."""
     reply = stubs.FakeNetworkReply(
         headers={'Content-Type': 'image/example; encoding=UTF-8'})
     mimetype, rest = http.parse_content_type(reply)
     self.assertEqual(mimetype, 'image/example')
     self.assertEqual(rest, ' encoding=UTF-8')
示例#2
0
 def test_mimetype(self):
     """Test with simple Content-Type header."""
     reply = stubs.FakeNetworkReply(
         headers={'Content-Type': 'image/example'})
     mimetype, rest = http.parse_content_type(reply)
     self.assertEqual(mimetype, 'image/example')
     self.assertIsNone(rest)
示例#3
0
 def _check_filename(self, header, filename):
     """Check if the passed header has the given filename."""
     reply = stubs.FakeNetworkReply(headers={'Content-Disposition': header})
     cd_inline, cd_filename = http.parse_content_disposition(reply)
     self.assertIsNotNone(cd_filename)
     self.assertEqual(cd_filename, filename)
     self.assertFalse(cd_inline)
示例#4
0
    def test_attonly(self):
        """'attachment' only.

        UA should offer to download the resource.
        """
        reply = stubs.FakeNetworkReply(
            headers={'Content-Disposition': 'attachment'})
        cd_inline, cd_filename = http.parse_content_disposition(reply)
        self.assertFalse(cd_inline)
        self.assertEqual(cd_filename, DEFAULT_NAME)
示例#5
0
 def test_empty(self):
     """Test with empty Content-Type header."""
     reply = stubs.FakeNetworkReply(headers={'Content-Type': ''})
     mimetype, rest = http.parse_content_type(reply)
     self.assertEqual(mimetype, '')
     self.assertIsNone(rest)
示例#6
0
 def test_not_existing(self):
     """Test without any Content-Type header."""
     reply = stubs.FakeNetworkReply()
     mimetype, rest = http.parse_content_type(reply)
     self.assertIsNone(mimetype)
     self.assertIsNone(rest)
示例#7
0
 def _check_ignored(self, header):
     """Check if the passed header is ignored."""
     reply = stubs.FakeNetworkReply(headers={'Content-Disposition': header})
     cd_inline, cd_filename = http.parse_content_disposition(reply)
     self.assertEqual(cd_filename, DEFAULT_NAME)
     self.assertTrue(cd_inline)
示例#8
0
 def _check_unnamed(self, header):
     """Check if the passed header results in an unnamed attachment."""
     reply = stubs.FakeNetworkReply(headers={'Content-Disposition': header})
     cd_inline, cd_filename = http.parse_content_disposition(reply)
     self.assertEqual(cd_filename, DEFAULT_NAME)
     self.assertFalse(cd_inline)