Beispiel #1
0
    def test_get_content_file(self):
        path = "/a_web_page.html"

        content = HttpServer.get_content(path)

        with open(os.path.join("webroot", "a_web_page.html"), "rb") as f:
            self.assertEqual(f.read(), content)
    def test_get_content_python_file(self):
        path = "/make_time.py"

        content = HttpServer.get_content(path)

        with open(os.path.join("webroot", "make_time.py"), "rb") as f:
            self.assertEqual(f.read(), content)
Beispiel #3
0
    def test_get_content_dir(self):
        path = "/"

        content = HttpServer.get_content(path)

        self.assertIn(b"favicon.ico", content)
        self.assertIn(b"make_time.py", content)
        self.assertIn(b"sample.txt", content)
        self.assertIn(b"a_web_page.html", content)
Beispiel #4
0
    def test_get_content_not_found(self):
        path = "/foo/bar/baz/doesnt/exist"

        with self.assertRaises(FileNotFoundError):
            HttpServer.get_content(path)