def test_empty_content(self):
        html = HTMLPageWriter()
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(fp.getvalue(),
                         """<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
""")
Example #2
0
    def test_empty_content(self):
        html = HTMLPageWriter()
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(
            fp.getvalue(), """<html>
<head>
<title></title>
<head>
<body>
</body>
</html>
""")
    def test_simple_content(self):
        html = HTMLPageWriter("Test")
        html.add("This is a test")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(fp.getvalue(),
                         """<html>
<head>
<title>Test</title>
</head>
<body>
This is a test</body>
</html>
""")
    def write(self, outfile):
        """
        Write document contents to a file

        """
        html = HTMLPageWriter(self._title)
        for css_rule in self._css_rules:
            html.addCSSRule(css_rule)
        html.add(self.html())
        html.write("%s" % outfile)
Example #5
0
    def test_add_css_rules(self):
        html = HTMLPageWriter("Test")
        html.addCSSRule("body { color: blue; }")
        html.add("<p>This is a test</p>")
        html.add("<p>We can see how well it works...</p>")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(
            fp.getvalue(), """<html>
<head>
<title>Test</title>
<style type=\"text/css\">
body { color: blue; }</style>
<head>
<body>
<p>This is a test</p>
<p>We can see how well it works...</p></body>
</html>
""")
Example #6
0
    def write(self,outfile):
        """
        Write document contents to a file

        Arguments
          outfile (str): path to file to write
            HTML document to
        """
        html = HTMLPageWriter(self._title)
        for css_rule in self._css_rules:
            html.addCSSRule(css_rule)
        html.add(self.html())
        html.write("%s" % outfile)
Example #7
0
    def test_add_javascript(self):
        html = HTMLPageWriter("Test")
        html.addJavaScript("// Comment")
        html.add("<p>This is a test</p>")
        html.add("<p>We can see how well it works...</p>")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(
            fp.getvalue(), """<html>
<head>
<title>Test</title>
<script language='javascript' type='text/javascript'><!--
// Comment
--></script>
<head>
<body>
<p>This is a test</p>
<p>We can see how well it works...</p></body>
</html>
""")
    def write(self, outfile):
        """
        Write document contents to a file

        """
        html = HTMLPageWriter(self._title)
        for css_rule in self._css_rules:
            html.addCSSRule(css_rule)
        html.add(self.html())
        html.write("%s" % outfile)
    def test_add_css_rules(self):
        html = HTMLPageWriter("Test")
        html.addCSSRule("body { color: blue; }")
        html.add("<p>This is a test</p>")
        html.add("<p>We can see how well it works...</p>")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(fp.getvalue(),
                         """<html>
<head>
<title>Test</title>
<style type=\"text/css\">
body { color: blue; }</style>
</head>
<body>
<p>This is a test</p>
<p>We can see how well it works...</p></body>
</html>
""")
Example #10
0
    def test_multiple_content_additions(self):
        html = HTMLPageWriter("Test")
        html.add("<p>This is a test</p>")
        html.add("<p>We can see how well it works...</p>")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(
            fp.getvalue(), """<html>
<head>
<title>Test</title>
<head>
<body>
<p>This is a test</p>
<p>We can see how well it works...</p></body>
</html>
""")
    def test_add_javascript(self):
        html = HTMLPageWriter("Test")
        html.addJavaScript("// Comment")
        html.add("<p>This is a test</p>")
        html.add("<p>We can see how well it works...</p>")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(fp.getvalue(),
                         """<html>
<head>
<title>Test</title>
<script language='javascript' type='text/javascript'><!--
// Comment
--></script>
</head>
<body>
<p>This is a test</p>
<p>We can see how well it works...</p></body>
</html>
""")
    def test_multiple_content_additions(self):
        html = HTMLPageWriter("Test")
        html.add("<p>This is a test</p>")
        html.add("<p>We can see how well it works...</p>")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(fp.getvalue(),
                         """<html>
<head>
<title>Test</title>
</head>
<body>
<p>This is a test</p>
<p>We can see how well it works...</p></body>
</html>
""")
Example #13
0
    def test_simple_content(self):
        html = HTMLPageWriter("Test")
        html.add("This is a test")
        fp = cStringIO.StringIO()
        html.write(fp=fp)
        self.assertEqual(
            fp.getvalue(), """<html>
<head>
<title>Test</title>
<head>
<body>
This is a test</body>
</html>
""")