class NodeMasterClassTestCase(DZTestCase): """ Test the NodeMaster class without actually starting a server. """ def setUp(self): super(NodeMasterClassTestCase, self).setUp() self.nm = NodeMaster() #print "Local nm in pid = %d" % os.getpid() def tearDown(self): self.nm.destroy() del self.nm def test_nodemaster(self): self.assertEqual(self.nm.num_bundles(), 0) def test_nm_serve_bundle(self): port = self.get_random_free_port() self.assertTrue(self.is_port_open(port)) self.assertTrue(self.is_port_open(port)) self.nm.serve_bundle("test_deploy_app", "bundle_test_deploy_app_2011-fixture", port) self.assertFalse(self.is_port_open(port)) with self.assertRaises(ValueError): self.nm.serve_bundle("anyapp", "anybundle", port) return port def test_unserve(self): port = self.test_nm_serve_bundle() eventlet.sleep() self.assertEqual(self.nm.num_bundles(), 1) self.assertFalse(self.is_port_open(port)) self.nm.unserve(port) self.assertTrue(self.is_port_open(port))
def setUp(self): super(NodeMasterClassTestCase, self).setUp() self.nm = NodeMaster()