2010-03-11 18:53:45 -04:00
|
|
|
#!/usr/bin/env python3
|
2007-08-14 13:47:39 -03:00
|
|
|
|
2009-11-03 13:13:59 -04:00
|
|
|
import collections
|
2008-03-24 02:51:45 -03:00
|
|
|
import errno
|
|
|
|
import socket
|
|
|
|
import sys
|
2007-08-14 13:47:39 -03:00
|
|
|
import unittest
|
2008-05-20 18:35:26 -03:00
|
|
|
from test import support
|
2007-08-14 13:47:39 -03:00
|
|
|
|
2008-05-26 13:32:26 -03:00
|
|
|
import xmlrpc.client as xmlrpclib
|
2007-08-14 13:47:39 -03:00
|
|
|
|
|
|
|
class CurrentTimeTest(unittest.TestCase):
|
|
|
|
|
2008-06-10 23:37:01 -03:00
|
|
|
def test_current_time(self):
|
2007-08-14 13:47:39 -03:00
|
|
|
# Get the current time from xmlrpc.com. This code exercises
|
|
|
|
# the minimal HTTP functionality in xmlrpclib.
|
|
|
|
server = xmlrpclib.ServerProxy("http://time.xmlrpc.com/RPC2")
|
2008-03-24 02:51:45 -03:00
|
|
|
try:
|
|
|
|
t0 = server.currentTime.getCurrentTime()
|
|
|
|
except socket.error as e:
|
2009-11-03 13:13:59 -04:00
|
|
|
self.skipTest("network error: %s" % e)
|
2008-03-24 02:51:45 -03:00
|
|
|
return
|
2007-08-14 13:47:39 -03:00
|
|
|
|
|
|
|
# Perform a minimal sanity check on the result, just to be sure
|
|
|
|
# the request means what we think it means.
|
|
|
|
t1 = xmlrpclib.DateTime()
|
|
|
|
|
|
|
|
dt0 = xmlrpclib._datetime_type(t0.value)
|
|
|
|
dt1 = xmlrpclib._datetime_type(t1.value)
|
|
|
|
if dt0 > dt1:
|
|
|
|
delta = dt0 - dt1
|
|
|
|
else:
|
|
|
|
delta = dt1 - dt0
|
|
|
|
# The difference between the system time here and the system
|
|
|
|
# time on the server should not be too big.
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertTrue(delta.days <= 1)
|
2007-08-14 13:47:39 -03:00
|
|
|
|
2009-11-03 13:13:59 -04:00
|
|
|
def test_python_builders(self):
|
|
|
|
# Get the list of builders from the XMLRPC buildbot interface at
|
|
|
|
# python.org.
|
2010-11-10 18:36:43 -04:00
|
|
|
self.skipTest("XMLRPC interface removed in Buildbot 0.8.2")
|
2009-11-03 13:13:59 -04:00
|
|
|
server = xmlrpclib.ServerProxy("http://www.python.org/dev/buildbot/all/xmlrpc/")
|
|
|
|
try:
|
|
|
|
builders = server.getAllBuilders()
|
|
|
|
except socket.error as e:
|
|
|
|
self.skipTest("network error: %s" % e)
|
|
|
|
return
|
|
|
|
|
|
|
|
# Perform a minimal sanity check on the result, just to be sure
|
|
|
|
# the request means what we think it means.
|
|
|
|
self.assertIsInstance(builders, collections.Sequence)
|
2010-07-05 19:11:16 -03:00
|
|
|
self.assertTrue([x for x in builders if "3.x" in x], builders)
|
2009-11-03 13:13:59 -04:00
|
|
|
|
2007-08-14 13:47:39 -03:00
|
|
|
|
|
|
|
def test_main():
|
2008-05-20 18:35:26 -03:00
|
|
|
support.requires("network")
|
|
|
|
support.run_unittest(CurrentTimeTest)
|
2007-08-14 13:47:39 -03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
test_main()
|