示例#1
0
class GardenerTest(unittest.TestCase):

    def setUp(self):
        self.gardener = Gardener(verbose = True)
        DelayedCall.debug = True
        
    def tearDown(self):        
        return self.gardener.connection_pool.closeCachedConnections()

    # live has a long moved around
    def test_live_com(self):
        
        d = self.gardener.get_url('live.com')
        def outcome(dump):
            #print 'dump', pprint.pprint(dump)
            pass
        def err(error):
            print 'err', pprint.pprint(error)
            self.fail('gardener failure')
                                    
        d.addCallback(outcome)
        d.addErrback(err)
        return d
    
    
    def test_netclaim_net(self):
        #DelayedCall.debug = True
        d = self.gardener.get_url('netclaim.net')
        def outcome(dump):
            print 'dump', pprint.pprint(dump)
            return dump
        def err(error):
            print 'err', pprint.pprint(error)
            self.fail('gardener failure')
                                                
        d.addCallback(outcome)
        d.addErrback(err)
        return d
    
    def test_yieldmanager_com(self):
        
        d = self.gardener.get_url('yieldmanager.com')
        def outcome(dump):
            self.fail('gardener failure expected for yieldmanager.com')
            #print 'dump', pprint.pprint(dump)
            pass
        def err(error):
            print 'failure is success', error.value.message
            #self.fail('access manager failure', error)
            #print 'err', pprint.pprint(error)            
                        
        d.addCallback(outcome)
        d.addErrback(err)
        return d        
示例#2
0
def main(reactor, *argv):
    
    options = Options()
    try:
        options.parseOptions(argv)
    except usage.UsageError as errortext:
        sys.stderr.write(str(options) + '\n')
        sys.stderr.write('ERROR: %s\n' % (errortext,))
        raise SystemExit(1)

    d = Gardener().get_url(options['url'])
    d.addCallback(lambda path: pprint.pprint(path))
    d.addErrback(lambda error: pprint.pprint(error.value))
    return d
示例#3
0
class GardenerServerTest(unittest.TestCase):
    
    default_port = 8111

    def setUp(self):
        self.server = reactor.listenTCP(GardenerServerTest.default_port, server.Site(GardenerResource()))
        self.gardener = Gardener()
        #DelayedCall.debug = True
        
    def tearDown(self):
        d = self.server.stopListening()        
        d.addCallback(lambda ign: self.gardener.connection_pool.closeCachedConnections())
        return d
        
    def test_local_resource(self):        
        d = self.gardener.get_url('localhost:' + str(self.default_port) )
        d.addCallback(lambda ign: True)
        d.addErrback(lambda ign: self.fail('garden server failure'))
        return d
示例#4
0
 def setUp(self):
     self.gardener = Gardener(verbose = True)
     DelayedCall.debug = True
示例#5
0
 def setUp(self):
     self.server = reactor.listenTCP(GardenerServerTest.default_port, server.Site(GardenerResource()))
     self.gardener = Gardener()