def test_init_mimetypes(self):
     # Logger is required for this test.
     self.config.set("logger", "logmethod", "none")
     initialization.init_logger(self.config, "TESTING")
     initialization.init_mimetypes(self.config)
     self.assertEqual(mimetypes.types_map[".txt"], "text/plain")
     self.assertEqual(mimetypes.encodings_map[".bz2"], "bzip2")
     assert ".txt" in fileext.typemap["text/plain"]
Esempio n. 2
0
    def test_detect_mime_type(self):
        init_mimetypes(self.config)

        protocol = self.get_protocol("localhost /testfile.gmi 0")
        protocol.handle()

        response = self.wfile.getvalue().decode(errors="surrogateescape")
        self.assertTrue(response.startswith("2 text/gemini\r\n"))
Esempio n. 3
0
    def setUp(self):
        self.config = testutil.get_config()
        self.vfs = VFS_Real(self.config)
        self.selector = "/talsample.html.tal"
        self.protocol = testutil.get_testing_protocol(self.selector,
                                                      config=self.config)
        self.stat_result = self.vfs.stat(self.selector)

        # Initialize the custom mimetypes encoding map
        initialization.init_logger(self.config, "")
        initialization.init_mimetypes(self.config)
Esempio n. 4
0
 def setUp(self):
     config = testutil.get_config()
     initialization.init_logger(config, "TESTING")
     initialization.init_mimetypes(config)