Example #1
0
 def test_parse_iso_timestamp(self):
   """
   Checks the parse_iso_timestamp() function.
   """
   
   test_inputs = {
     '2012-11-08T16:48:41.420251':
       datetime.datetime(2012, 11, 8, 16, 48, 41, 420251),
     '2012-11-08T16:48:41.000000':
       datetime.datetime(2012, 11, 8, 16, 48, 41, 0),
     '2012-11-08T16:48:41':
       datetime.datetime(2012, 11, 8, 16, 48, 41, 0),
   }
   
   for arg, expected in test_inputs.items():
     self.assertEqual(expected, str_tools.parse_iso_timestamp(arg))
   
   invalid_input = [
     None,
     32,
     'hello world',
     '2012-11-08T16:48:41.42025',   # too few microsecond digits
     '2012-11-08T16:48:41.4202511', # too many microsecond digits
     '2012-11-08T16:48',
   ]
   
   for arg in invalid_input:
     self.assertRaises(ValueError, str_tools.parse_iso_timestamp, arg)
Example #2
0
    def test_parse_iso_timestamp(self):
        """
    Checks the parse_iso_timestamp() function.
    """

        test_inputs = {
            '2012-11-08T16:48:41.420251':
            datetime.datetime(2012, 11, 8, 16, 48, 41, 420251),
            '2012-11-08T16:48:41.000000':
            datetime.datetime(2012, 11, 8, 16, 48, 41, 0),
            '2012-11-08T16:48:41':
            datetime.datetime(2012, 11, 8, 16, 48, 41, 0),
        }

        for arg, expected in test_inputs.items():
            self.assertEqual(expected, str_tools.parse_iso_timestamp(arg))

        invalid_input = [
            None,
            32,
            'hello world',
            '2012-11-08T16:48:41.42025',  # too few microsecond digits
            '2012-11-08T16:48:41.4202511',  # too many microsecond digits
            '2012-11-08T16:48',
        ]

        for arg in invalid_input:
            self.assertRaises(ValueError, str_tools.parse_iso_timestamp, arg)
Example #3
0
 def _parse(self):
   self.path = tuple(stem.control._parse_circ_path(self.path))
   
   if self.build_flags is not None:
     self.build_flags = tuple(self.build_flags.split(','))
   
   if self.created is not None:
     try:
       self.created = str_tools.parse_iso_timestamp(self.created)
     except ValueError, exc:
       raise stem.ProtocolError("Unable to parse create date (%s): %s" % (exc, self))
Example #4
0
    def _parse(self):
        self.path = tuple(stem.control._parse_circ_path(self.path))

        if self.build_flags is not None:
            self.build_flags = tuple(self.build_flags.split(','))

        if self.created is not None:
            try:
                self.created = str_tools.parse_iso_timestamp(self.created)
            except ValueError, exc:
                raise stem.ProtocolError(
                    "Unable to parse create date (%s): %s" % (exc, self))