Logo Search packages:      
Sourcecode: karrigell version File versions  Download package


00001 """Fonctionnal testing for "Python In HTML" (PIH) and "HTML In Python" (HIP).
__author__ = "Didier Wenzek (didier.wenzek@free.fr)"

# The code under test is in the .. directory.
import sys

# We use the Python unit testing framework
import unittest
import thread, time
from util import *

00014 class TemplateTest(unittest.TestCase):
      """Testing the Karrigell Scripting languages.
      A test is prepared with the addScript() and removeScript() methods.
      which are used to set up the root directory with scripts picked from
      the data directory.
      The Karrigell response is returned by the getPage() method
      as a Page object with a status and a content attribute.
      The expected response can be retrieved from the data repository with the
      getGoldenFile() method.
      The Karrigell response can then be tested against the expected response,
      using any of the unittest methods like assertEqual().

      def setUp(self):

00035       def test_PIH_InsertPython(self):
            """<% and %> tags are used to insert python code in HTML."""
            import time
            page = getPage("/time.pih")
            today = time.strftime("%d:%m:%y",time.localtime(time.time()))
            expected = getGoldenFile("time.out", date=today)
            self.assertEqual(page.status, 200)
            self.assertEqual(page.content, expected)

00045       def test_PIH_PrintValue(self):
            """<%= an %> tags are used to print python value."""
            page = getPage("/value.pih")
            expected = getGoldenFile("value.out")
            self.assertEqual(page.status, 200)
            self.assertEqual(page.content + '\n', expected)

00053       def test_PIH_Indentation(self):
            """Python indentation is managed using the <% end %> tag."""
            page = getPage("/indent.pih", 'POST', params={'hour':'22'})
            expected = getGoldenFile("indent.out")
            self.assertEqual(page.status, 200)
            self.assertEqual(page.content, expected)

00061       def test_PIH_IndentTag(self):
            """Within <indent> tag HTML must follow Python indentation."""
            page = getPage("/indent_tag.pih", 'POST', params={'hour':'22'})
            expected = getGoldenFile("indent_tag.out")
            self.assertEqual(page.status, 200)
            self.assertEqual(page.content, expected)

00069       def test_PIH_EmbeddedBlocks(self):
            """Python blocks may be embedded."""
            page = getPage("/embedded.pih")
            expected = getGoldenFile("embedded.out")
            self.assertEqual(page.status, 200)
            self.assertEqual(page.content, expected)

00077       def test_HIP_Principes(self):
            """Literal text in python are printed to the response stream"""
            page = getPage("/the_smiths.hip")
            expected = getGoldenFile("the_smiths.out")
            self.assertEqual(page.status, 200)
            self.assertEqual(page.content, expected)

if __name__ == "__main__":

Generated by  Doxygen 1.6.0   Back to index