def test_get_html_file_headers(self): result = mimetype.get_type_headers("hello.html", None) expected = { "Content-Type": "application/octet-stream", "Content-Disposition": "attachment", "X-Content-Type-Options": "nosniff", } self.assertEqual(result, expected)
def test_get_html_file_headers(self): result = mimetype.get_type_headers('hello.html', None) expected = { 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment', 'X-Content-Type-Options': 'nosniff' } self.assertEqual(result, expected)
def test_get_normal_headers(self): dataset = [('hello', '#!', 'text/plain; charset=ascii'), ('hello.jpg', None, 'image/jpeg'), ('hello.jpg', '#!', 'image/jpeg'), ('hello.jpg', '\0', 'image/jpeg'), (None, '😋', 'text/plain; charset=utf-8'), ('hello', '\0', 'application/octet-stream')] for data in dataset: result = mimetype.get_type_headers(data[0], data[1]) self.assertEqual(result['Content-Type'], data[2])
def test_get_normal_headers(self): dataset = [('hello', b'#!', 'text/plain; charset=ascii'), ('hello.jpg', None, 'image/jpeg'), ('hello.jpg', b'#!', 'image/jpeg'), ('hello.jpg', b'\0', 'image/jpeg'), (None, '😋'.encode("utf-8"), 'text/plain; charset=utf-8'), ('hello', b'\0', 'application/octet-stream')] for data in dataset: result = mimetype.get_type_headers(data[0], data[1]) self.assertEqual( result['Content-Type'], data[2], "Wrong Content-Type for filename %r and content %r" % (data[0], data[1]))
def test_get_normal_headers(self): dataset = [ ("hello", b"#!", "text/plain; charset=ascii"), ("hello.jpg", None, "image/jpeg"), ("hello.jpg", b"#!", "image/jpeg"), ("hello.jpg", b"\0", "image/jpeg"), (None, "😋".encode("utf-8"), "text/plain; charset=utf-8"), ("hello", b"\0", "application/octet-stream"), ] for data in dataset: result = mimetype.get_type_headers(data[0], data[1]) self.assertEqual( result["Content-Type"], data[2], "Wrong Content-Type for filename %r and content %r" % (data[0], data[1]), )
def test_get_none_header(self): self.assertIsNone(mimetype.get_type_headers("hello", None))