Ticket #6116: ticket6116.patch

File ticket6116.patch, 1.5 KB (added by Can Ibanoglu, 7 years ago)

Added tests for twisted.web.http.stringToDatetime

  • twisted/web/test/test_http.py

     
    4141            time2 = http.stringToDatetime(timestr)
    4242            self.assertEqual(time, time2)
    4343
     44    def test_stringToDatetimeSecondDateFormat(self):
     45        """
     46        Tests wheter a date string of the format
     47        'Monday, 01-Jan-70 00:00:00 GMT' works as expected.
     48        """
     49        time = 1235543421
     50        timestr = 'Wednesday, 25-Feb-09 06:30:21 GMT'
     51        time2 = 132312312
     52        timestr2 = 'Tuesday, 12-Mar-74 09:25:12 GMT'
     53        self.assertEqual(time, http.stringToDatetime(timestr))
     54        self.assertEqual(time2, http.stringToDatetime(timestr2))
    4455
     56    def test_stringToDatetimeThirdDateFormat(self):
     57        """
     58        Tests whether ANSI C asctime() format works as expected.
     59        """
     60        time = 132312312
     61        timestr = "Tue, Mar 12 09:25:12 1974"
     62        self.assertEqual(time, http.stringToDatetime(timestr))
     63
     64    def test_stringToDatetimeUnkownFormat(self):
     65        """
     66        Tests whether unknown date strings raise ValueError as
     67        expected.
     68        """
     69        timestr = 'abc'
     70        self.assertRaises(ValueError, http.stringToDatetime, timestr)
     71
    4572class DummyHTTPHandler(http.Request):
    4673
    4774    def process(self):