示例#1
0
 def test_minimum_maximum(self):
     time = TimeInput()
     time.minimum = datetime.time(12, 14)
     time.maximum = datetime.time(19, 45)
     assert_equal('<input max="19:45:00" min="12:14:00" type="time"/>',
                  str(time))
     time.minimum = None
     time.maximum = None
     assert_equal('<input type="time"/>', str(time))
示例#2
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)
示例#3
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)
示例#4
0
 def test_construct_with_arguments(self):
     time = TimeInput("time-name", datetime.time(14, 30, 12))
     assert_equal("time-name", time.name)
     assert_equal(datetime.time(14, 30, 12), time.time)
     assert_equal(
         '<input name="time-name" type="time" '
         'value="14:30:12"/>', str(time))
示例#5
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))
示例#6
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)
示例#7
0
 def test_minimum_maximum(self):
     time = TimeInput()
     time.minimum = datetime.time(12, 14)
     time.maximum = datetime.time(19, 45)
     assert_equal('<input max="19:45:00" min="12:14:00" type="time"/>',
                  str(time))
     time.minimum = None
     time.maximum = None
     assert_equal('<input type="time"/>', str(time))
示例#8
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)
示例#9
0
 def test_step_set_invalid(self):
     time = TimeInput()
     with assert_raises(ValueError):
         time.step = 0
示例#10
0
 def test_maximum_below_minimum(self):
     time = TimeInput()
     time.minimum = datetime.time(12, 1)
     with assert_raises(ValueError):
         time.maximum = datetime.time(12, 0)
示例#11
0
 def test_step_set_invalid(self):
     time = TimeInput()
     with assert_raises(ValueError):
         time.step = 0
示例#12
0
 def test_maximum_below_minimum(self):
     time = TimeInput()
     time.minimum = datetime.time(12, 1)
     with assert_raises(ValueError):
         time.maximum = datetime.time(12, 0)