Example #1
0
 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
Example #2
0
 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
Example #3
0
 def testConvertToString(self, input, output):
     assert str(DateTime(input)) == output
Example #4
0
 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
Example #5
0
 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
Example #6
0
 def testConstructFromString(self, string, y, M, d, h, m, s, micros):
     assert DateTime(string).value == datetime.datetime(y, M, d, h, m, s,
         micros)
Example #7
0
 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
Example #8
0
 def sysdate(cls):
     utc = DateTime(cls.utc())
     return str(utc)