def testtimeFromString(self): dateTimeStr = "2011-12-21 16:45:08" self.assertEqual( datetime.datetime.strptime( dateTimeStr, DATE_TIME_SEPARATOR.join((DATE_FORMAT, TIME_FORMAT))), timeFromString(dateTimeStr))
def _readDeviceElement(self, element, result): ''' Reads the given element representing a device test execution result. ''' name = element.findtext("name") if name is None: raise XmlMissingTagError(element.tag, "name") status = element.findtext("status") if status is None: raise XmlMissingTagError(element.tag, "status") d = _Device() d.name = name port = element.findtext("port") if port: port = int(port) d.address = (element.findtext("address"), port) d.description = element.findtext("description") device = result.device(d) device.status = status date = element.findtext("date") if date: device.date = utils.timeFromString(date) time = element.findtext("time") if time: device.time = float(time) errors = element.find("errors") if errors is not None: for error in errors.findall("error"): device.errors.append(error.text) cores = element.find("cores") if cores is not None: device.cores = [] for core in cores.findall("core"): path = core.findtext("path") if path is None: raise XmlMissingTagError("core", "path") mtime = core.findtext("date") or 0.0 mtime = mtime and utils.timeStampFromString(mtime) size = long(core.findtext("size") or 0) device.cores.append(FileDetails(path, mtime=mtime, size=size)) return d
def testSanity(self): dateTimeStr = "2011-12-21 16:45:08" self.assertEqual(dateTimeStr, timeToString(timeFromString(dateTimeStr)))
def testtimeFromStringWithNone(self): self.assertEqual(None, timeFromString(""))
def testtimeFromString(self): dateTimeStr = "2011-12-21 16:45:08" self.assertEqual(datetime.datetime.strptime(dateTimeStr, DATE_TIME_SEPARATOR.join((DATE_FORMAT, TIME_FORMAT))), timeFromString(dateTimeStr))