Esempio n. 1
0
 def test_select_best_url(self):
     spec = 'http://host1|https://host2:666/path/to|http://host3/path/'
     best = select_best_url(
         spec, MockPinger({
             'host1': 5,
             'host2': 3,
             'host3': 7
         }), MockLogger())
     self.assertEquals('https://host2:666/path/to', best)
 def test_restful_cache(self):
   httpd = None
   httpd_thread = None
   try:
     with temporary_dir() as cache_root:
       with pushd(cache_root):  # SimpleRESTHandler serves from the cwd.
         httpd = SocketServer.TCPServer(('localhost', 0), SimpleRESTHandler)
         port = httpd.server_address[1]
         httpd_thread = Thread(target=httpd.serve_forever)
         httpd_thread.start()
         with temporary_dir() as artifact_root:
           artifact_cache = RESTfulArtifactCache(MockLogger(), artifact_root,
                                                 'http://localhost:%d' % port)
           self.do_test_artifact_cache(artifact_cache)
   finally:
     if httpd:
       httpd.shutdown()
     if httpd_thread:
       httpd_thread.join()
Esempio n. 3
0
def make_dag(nodes):
    return DoubleDag(nodes, lambda t: t.dependencies, MockLogger(Report.INFO))
 def check(expected_type, spec):
   cache = create_artifact_cache(MockLogger(), artifact_root, spec, 'TestTask', 'testing')
   self.assertTrue(isinstance(cache, expected_type))
   self.assertEquals(cache.artifact_root, artifact_root)