@@ -474,6 +474,46 @@ def test_input_xhtml(self):
474474 input = input_xhtml (** attrs )
475475 self .assertEqual (input , '<input class="required" disabled="disabled" size="30" type="text"/>' )
476476
477+
478+ class HTMLPropertyTestClass (unittest .TestCase ):
479+ def setUp (self ):
480+ self .form = FieldStorage ()
481+ self .client = MockNull ()
482+ self .client .db = db = MockDatabase ()
483+ db .security .hasPermission = lambda * args , ** kw : True
484+ self .client .form = self .form
485+
486+ self .client ._props = MockNull ()
487+ # add client props for testing anti_csrf_nonce
488+ self .client .session_api = MockNull (_sid = "1234567890" )
489+ self .client .db .getuid = lambda : 10
490+
491+ class DateHTMLPropertyTestCase (HTMLPropertyTestClass ):
492+
493+ def test_DateHTMLWithText (self ):
494+ """Test methods when DateHTMLProperty._value is a string
495+ rather than a hyperdb.Date()
496+ """
497+ test_datestring = "2021-01-01 11:22:10"
498+ test_date = hyperdb .Date ("2" )
499+
500+ self .form .list .append (MiniFieldStorage ("test1@test" , test_datestring ))
501+ self .client ._props = test_date
502+
503+ self .client .db .classes = dict \
504+ ( test = MockNull (getprops = lambda : test_date )
505+ )
506+
507+ # client, classname, nodeid, prop, name, value,
508+ # anonymous=0, offset=None
509+ d = DateHTMLProperty (self .client , 'test' , '1' , self .client ._props ,
510+ 'test' , '' )
511+ self .assertIs (type (d ._value ), str )
512+ self .assertEqual (d .pretty (), "2021-01-01 11:22:10" )
513+ self .assertEqual (d .plain (), "2021-01-01 11:22:10" )
514+ input = """<input name="test1@test" size="30" type="text" value="2021-01-01 11:22:10"><a class="classhelp" data-calurl="test?@template=calendar&amp;property=test&amp;form=itemSynopsis&date=2021-01-01 11:22:10" data-height="200" data-width="300" href="javascript:help_window('test?@template=calendar&property=test&form=itemSynopsis&date=2021-01-01 11:22:10', 300, 200)">(cal)</a>"""
515+ self .assertEqual (d .field (), input )
516+
477517# common markdown test cases
478518class MarkdownTests :
479519 def mangleMarkdown2 (self , s ):
0 commit comments