def xml(self): root = Element("Timestamp", ns=wsuns) created = Element('Created', ns=wsuns) created.setText(str(DateTime(self.created))) expires = Element('Expires', ns=wsuns) expires.setText(str(DateTime(self.expires))) root.append(created) root.append(expires) return root
def xml(self): """ Get xml representation of the object. @return: The root node. @rtype: L{Element} """ root = Element('UsernameToken', ns=wssens) u = Element('Username', ns=wssens) u.setText(self.username) root.append(u) p = Element('Password', ns=wssens) p.setText(self.password) if self.password_digest: p.set("Type", wsdigest) p.setText(self.password_digest) root.append(p) if self.nonce is not None: n = Element('Nonce', ns=wssens) if self.nonce_has_encoding: n.set("EncodingType", nonce_encoding_type) n.setText(self.nonce) root.append(n) if self.created is not None: n = Element('Created', ns=wsuns) n.setText(str(DateTime(self.created))) root.append(n) return root
def testConvertToString(self, input, output): assert str(DateTime(input)) == output
def testConstructFromString_timezone(self, string, y, M, d, h, m, s, micros, tz_h, tz_m): tzdelta = datetime.timedelta(hours=tz_h, minutes=tz_m) tzinfo = FixedOffsetTimezone(tzdelta) ref = datetime.datetime(y, M, d, h, m, s, micros, tzinfo=tzinfo) assert DateTime(string).value == ref
def testConstructFromString_subsecondRounding(self, string, y, M, d, h, m, s, micros): ref = datetime.datetime(y, M, d, h, m, s, micros) assert DateTime(string).value == ref
def testConstructFromString(self, string, y, M, d, h, m, s, micros): assert DateTime(string).value == datetime.datetime(y, M, d, h, m, s, micros)
def testConstructFromDateTime(self): dt = datetime.datetime(2001, 12, 10, 1, 1) assert DateTime(dt).value is dt dt.replace(tzinfo=UtcTimezone()) assert DateTime(dt).value is dt
def sysdate(cls): utc = DateTime(cls.utc()) return str(utc)