Exemplo n.º 1
0
    def test_integer_resource_parameter_html_element(self):
        param = IntegerResourceParameter(name="option1")
        html = param.html_element()
        self.assertIsInstance(html, etree._Element)

        self.assertEqual("fieldset", html.tag)
        self.assertEqual(2, len(html))  # legend and input
        self.assertEqual("legend", html[0].tag)

        self.assertEqual("input", html[1].tag)
        self.assertEqual("option1", html[1].get("name"))
        self.assertEqual("number", html[1].get("type"))
        self.assertEqual(None, html[1].get("min"))
        self.assertEqual(None, html[1].get("max"))
        self.assertEqual(None, html[1].get("value"))
Exemplo n.º 2
0
    def test_integer_resource_parameter_html_element_with_min_max_default(
            self):
        param = IntegerResourceParameter(name="option1",
                                         default=20,
                                         min_val=10,
                                         max_val=30)
        html = param.html_element()
        self.assertIsInstance(html, etree._Element)

        self.assertEqual("fieldset", html.tag)
        self.assertEqual(2, len(html))  # legend and input
        self.assertEqual("legend", html[0].tag)

        self.assertEqual("input", html[1].tag)
        self.assertEqual("option1", html[1].get("name"))
        self.assertEqual("number", html[1].get("type"))
        self.assertEqual("10", html[1].get("min"))
        self.assertEqual("30", html[1].get("max"))
        self.assertEqual("20", html[1].get("value"))