예제 #1
0
 def test_defaults(self):
     input_ = DateInput()
     assert_equal("date", input_.type)
     assert_equal("", input_.name)
     assert_is_none(input_.date)
     assert_equal("", input_.value)
     assert_equal('<input type="date"/>', str(input_))
예제 #2
0
 def test_defaults(self):
     number = NumberInput()
     assert_equal("number", number.type)
     assert_equal("", number.name)
     assert_equal("", number.value)
     assert_is_none(number.number)
     assert_equal('<input type="number"/>', str(number))
예제 #3
0
 def test_remove_attribute(self):
     element = Element("div")
     element.remove_attribute("foo")
     element.set_attribute("foo", "bar")
     element.remove_attribute("foo")
     assert_is_none(element.get_attribute("foo"))
     assert_equal([b'<div>', b"</div>"], list(iter(element)))
예제 #4
0
 def test_data(self):
     class MyElement(Element):
         attr = data_attribute("attr")
     element = MyElement("div")
     assert_is_none(element.get_attribute("data-attr"))
     element.attr = "foo"
     assert_equal("foo", element.get_attribute("data-attr"))
     element.set_attribute("data-attr", "bar")
     assert_equal("bar", element.attr)
예제 #5
0
 def test_step(self):
     time = TimeInput()
     time.step = 12.3
     assert_equal(12.3, time.step)
     assert_equal('<input step="12.3" type="time"/>', str(time))
     time.step = None
     assert_is_none(time.step)
     assert_equal('<input type="time"/>', str(time))
     time.set_attribute("step", "any")
     assert_is_none(time.step)
예제 #6
0
 def test_value(self):
     input_ = DateInput()
     input_.value = "2012-03-08"
     assert_equal(datetime.date(2012, 3, 8), input_.date)
     input_.value = "invalid"
     assert_is_none(input_.date)
     assert_equal('<input type="date" value="invalid"/>', str(input_))
     input_.date = None
     assert_equal("", input_.value)
     assert_equal('<input type="date"/>', str(input_))
예제 #7
0
 def test_data_external(self):
     element = Element("div")
     element.set_attribute("data-foo", "bar")
     assert_equal("bar", element.data["foo"])
     element.data["xyz"] = "abc"
     assert_equal("abc", element.get_attribute("data-xyz"))
     element.data.clear()
     assert_is_none(element.get_attribute("data-foo"))
     element.set_attribute("data-old", "")
     element.data = {}
     assert_is_none(element.get_attribute("data-old"))
예제 #8
0
 def test_id(self):
     element = Element("div")
     element.id = "Test-ID"
     assert_equal("Test-ID", element.id)
     assert_equal('<div id="Test-ID"></div>', str(element))
     element.id = ""
     assert_is_none(element.id)
     assert_equal('<div></div>', str(element))
     element.id = None
     assert_is_none(element.id)
     assert_equal('<div></div>', str(element))
예제 #9
0
 def test_float(self):
     class MyElement(Element):
         attr = float_html_attribute("data-attr")
     element = MyElement("div")
     assert_is_none(element.attr)
     assert_equal("<div></div>", str(element))
     element.attr = 4.2
     assert_equal(4.2, element.attr)
     assert_equal('<div data-attr="4.2"></div>', str(element))
     element.attr = None
     assert_is_none(element.attr)
     assert_equal('<div></div>', str(element))
예제 #10
0
 def test_regular(self):
     class MyElement(Element):
         attr = html_attribute("data-attr")
     element = MyElement("div")
     assert_is_none(element.attr)
     assert_equal("<div></div>", str(element))
     element.attr = "Foo"
     assert_equal("Foo", element.attr)
     assert_equal('<div data-attr="Foo"></div>', str(element))
     element.attr = None
     assert_is_none(element.attr)
     assert_equal("<div></div>", str(element))
예제 #11
0
 def test_time(self):
     class MyElement(Element):
         attr = time_html_attribute("data-time")
     element = MyElement("div")
     assert_is_none(element.attr)
     assert_equal("<div></div>", str(element))
     element.attr = datetime.time(14, 13, 9)
     assert_equal(datetime.time(14, 13, 9), element.attr)
     assert_equal('<div data-time="14:13:09"></div>', str(element))
     element.attr = None
     assert_is_none(element.attr)
     assert_equal('<div></div>', str(element))
     element.set_attribute("data-time", "09:33:04")
     assert_equal(datetime.time(9, 33, 4), element.attr)
예제 #12
0
 def test_defaults(self):
     time = TimeInput()
     assert_equal("", time.name)
     assert_is_none(time.time)
     assert_is_none(time.minimum)
     assert_is_none(time.maximum)
     assert_is_none(time.step)
     assert_equal('<input type="time"/>', str(time))
예제 #13
0
 def test_step_get_invalid(self):
     time = TimeInput()
     time.set_attribute("step", "invalid")
     assert_is_none(time.step)
     time.set_attribute("step", "0")
     assert_is_none(time.step)
     time.set_attribute("step", "-1")
     assert_is_none(time.step)
예제 #14
0
def assertIsNone(res):
    try:
        asserts.assert_is_none(res)
    except Exception as e:
        logger.error(e)
예제 #15
0
 def test_get_selected_value__no_selected(self):
     select = Select()
     select.create_option("L1", "v1")
     assert_is_none(select.selected_value)
예제 #16
0
 def test_get_selected_option__option_group_has_string_child(self):
     select = Select()
     group = select.create_group("")
     group.append("XXX")
     assert_is_none(select.selected_option)
예제 #17
0
 def test_get_selected_option__non_option_elements(self):
     select = Select()
     select.append("String Content")
     assert_is_none(select.selected_option)
예제 #18
0
 def test_data_with_default(self):
     class MyElement(Element):
         attr = data_attribute("attr", "def")
     element = MyElement("div")
     element.attr = "def"
     assert_is_none(element.get_attribute("data-attr"))
예제 #19
0
 def test_url(self):
     script = Script(url="script.js")
     assert_equal("script.js", script.url)
     assert_is_none(script.script)
     assert_equal([b'<script src="script.js">', b'</script>'],
                  list(iter(script)))
예제 #20
0
 def test_defaults(self):
     file_input = FileInput()
     assert_equal("", file_input.name)
     assert_is_none(file_input.max_length)
     assert_equal('<input type="file"/>', str(file_input))
예제 #21
0
 def test_for(self):
     label = Label()
     assert_is_none(label.for_)
     label.for_ = "my-id"
     assert_equal("my-id", label.for_)
     assert_equal('<label for="my-id"></label>', str(label))
예제 #22
0
 def test_get_selected_value__no_selected(self):
     select = Select()
     select.create_option("L1", "v1")
     assert_is_none(select.selected_value)
예제 #23
0
 def test_get_selected_option__option_group_has_string_child(self):
     select = Select()
     group = select.create_group("")
     group.append("XXX")
     assert_is_none(select.selected_option)
예제 #24
0
 def test_url(self):
     script = Script(url="script.js")
     assert_equal("script.js", script.url)
     assert_is_none(script.script)
     assert_equal([b'<script src="script.js">', b"</script>"],
                  list(iter(script)))
예제 #25
0
 def test_script(self):
     script = Script(script='alert("foo");')
     assert_is_none(script.url)
     assert_equal('alert("foo");', script.script)
     assert_equal([b"<script>", b'alert("foo");', b"</script>"],
                  list(iter(script)))
예제 #26
0
 def test_data_with_default(self):
     class MyElement(Element):
         attr = data_attribute("attr", "def")
     element = MyElement("div")
     element.attr = "def"
     assert_is_none(element.get_attribute("data-attr"))
예제 #27
0
 def test_time__invalid_value(self):
     class MyElement(Element):
         attr = time_html_attribute("data-time")
     element = MyElement("div")
     element.set_attribute("data-time", "INVALID")
     assert_is_none(element.attr)
예제 #28
0
 def test_defaults(self):
     file_input = FileInput()
     assert_equal("", file_input.name)
     assert_is_none(file_input.max_length)
     assert_equal('<input type="file"/>', str(file_input))
예제 #29
0
 def test_get_selected_option__no_selected_elements(self):
     select = Select()
     select.create_option("L1", "v1")
     select.create_option("L2", "v2")
     select.create_option("L3", "v3")
     assert_is_none(select.selected_option)
예제 #30
0
 def test_get_selected_option__non_option_elements(self):
     select = Select()
     select.append("String Content")
     assert_is_none(select.selected_option)
예제 #31
0
 def test_get_attribute(self):
     element = Element("div")
     assert_is_none(element.get_attribute("foo"))
     assert_equal("XXX", element.get_attribute("foo", default="XXX"))
예제 #32
0
 def test_get_selected_option__no_selected_elements(self):
     select = Select()
     select.create_option("L1", "v1")
     select.create_option("L2", "v2")
     select.create_option("L3", "v3")
     assert_is_none(select.selected_option)
예제 #33
0
 def test_script(self):
     script = Script(script='alert("foo");')
     assert_is_none(script.url)
     assert_equal('alert("foo");', script.script)
     assert_equal([b'<script>', b'alert("foo");', b'</script>'],
                  list(iter(script)))
예제 #34
0
 def test_time__invalid_value(self):
     class MyElement(Element):
         attr = time_html_attribute("data-time")
     element = MyElement("div")
     element.set_attribute("data-time", "INVALID")
     assert_is_none(element.attr)