def test_start_waits(self): """ Start should not return until it's actually working. """ runner = Runner() base = FilePath(tempfile.mkdtemp()) root = base.child('root') src = base.child('src') dst = base.child('dst') _ = yield runner.start(root.path, 'unix:'+src.path, 'unix:'+dst.path) self.assertTrue(root.child('grace.pid').exists(), "Should have a pid") pid = root.child('grace.pid').getContent().strip() self.addCleanup(self.kill, pid) self.assertTrue(root.child('grace.socket').exists(), "Should have a " "socket") self.assertTrue(root.exists(), "Should have made the root dir") tac = root.child('grace.tac') self.assertTrue(tac.exists(), "Should have made grace.tac") self.assertEqual(tac.getContent(), getTac(('unix:'+src.path, 'unix:'+dst.path)), "Should have made the tac file using getTac")
def test_onepipe(self): """ You can add a pipe to the tac file """ s = getTac(('src', 'dst')) expected = tac_template.getContent() expected += "\nplumber.addPipe('src', 'dst')\n" self.assertEqual(s, expected)
def test_dne(self): """ If the directory does not exist, it will create the directory and put a tac file in it. """ tmp = FilePath(self.mktemp()) setupDir(tmp.path, ('foo', 'bar')) self.assertTrue(tmp.exists(), "Should make the directory") tac = tmp.child('grace.tac') self.assertTrue(tac.exists(), "Should make the tac file") self.assertEqual(tac.getContent(), getTac(('foo', 'bar')), "Should copy the tac template in")
def test_exists(self): """ If the directory and a file already exist, overwrite them """ tmp = FilePath(self.mktemp()) setupDir(tmp.path, ('ape', 'gorilla')) setupDir(tmp.path, ('foo', 'bar')) self.assertTrue(tmp.exists(), "Should make the directory") tac = tmp.child('grace.tac') self.assertTrue(tac.exists(), "Should make the tac file") self.assertEqual(tac.getContent(), getTac(('foo', 'bar')), "Should copy the tac template in")
def test_nopipes(self): """ You can get the tacfile without any extra Pipes. """ s = getTac() self.assertEqual(s, tac_template.getContent())