Skip to content

Commit

Permalink
Add setupDir for making grace dir
Browse files Browse the repository at this point in the history
  • Loading branch information
iffy committed Jul 24, 2012
1 parent 53c6a42 commit 377e411
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
13 changes: 13 additions & 0 deletions grace/tac.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ def getTac(pipedef=None):
if pipedef:
template += '\nplumber.addPipe(%r, %r)\n' % pipedef
return template



def setupDir(dirname, pipedef):
"""
Create a grace directory.
@param dirname: XXX
@param pipedef: XXX
"""
fp = FilePath(dirname)
fp.makedirs()
fp.child('grace.tac').setContent(getTac(pipedef))
22 changes: 20 additions & 2 deletions grace/test/test_tac.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
grace_root = FilePath(__file__).parent().parent()
tac_template = grace_root.child('grace.tac')

from grace.tac import getTac
from grace.tac import getTac, setupDir


class getTacTest(TestCase):
Expand All @@ -25,4 +25,22 @@ def test_onepipe(self):
s = getTac(('src', 'dst'))
expected = tac_template.getContent()
expected += "\nplumber.addPipe('src', 'dst')\n"
self.assertEqual(s, expected)
self.assertEqual(s, expected)



class setupDirTest(TestCase):


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")

0 comments on commit 377e411

Please sign in to comment.