def test_serve_dynamicpage_nomodel_ok(self):
        '''This test case covers the case when dynamic page exists but does not have a model binded.'''

        expected_url = "/page/about"
        expected_result = "simple test rendered template"
        page = DynamicPage(template="/comp/template",
                           language="ro-RO",
                           keywords="keyword 1, keyword 2",
                           description="simple description",
                           title="simple title")
        page.id = 1

        self._test_serve_dynamicpage_scenario(page, None, expected_url, expected_result)
    def test_serve_dynamicpage_ok(self):
        '''This test case covers the case when dynamic page exists and have a model binded.'''

        expected_url = "/page/about"
        expected_result = "simple test rendered template"
        page = DynamicPage(template="/comp/template",
                           language="ro-RO",
                           keywords="keyword 1, keyword 2",
                           description="simple description",
                           title="simple title")
        page.id = 1

        page_model = DynamicPageModel(page_id=1, name="simple_attr", value="simple test")

        self._test_serve_dynamicpage_scenario(page, page_model, expected_url, expected_result)
    def test_dynamicpage_init_ok_defaults(self):
        '''This test case ensures all page meta information are initialized correctly with default values.'''

        model = DynamicPage()

        self.assertIsNone(model.id)
        self.assertIsNone(model.name)
        self.assertIsNone(model.url)
        self.assertIsNone(model.template)
        self.assertIsNone(model.keywords)
        self.assertIsNone(model.description)
        self.assertIsNone(model.title)
        self.assertEqual("en", model.language)
    def test_dynamicpage_init_ok(self):
        '''This test case ensures all page meta information are initialized correctly with given values.'''

        name = "/en/home"
        url = "/en/home"
        template = "/frontend/views/master.html"
        keywords = "keyword 1, ..."
        description = "description"
        title = "Home page"
        language = "en-US"

        model = DynamicPage(name, url, template, keywords, description, title, language)

        self.assertIsNone(model.id)
        self.assertEqual(name, model.name)
        self.assertEqual(url, model.url)
        self.assertEqual(template, model.template)
        self.assertEqual(keywords, model.keywords)
        self.assertEqual(description, model.description)
        self.assertEqual(title, model.title)
        self.assertEqual(language, model.language)