Add assemble module

This adds a module that concatenates (ie. assembles) a file from
fragments in a directory in alphabetical order.  It chains the file
module afterward to fix up ownership and permission.  This also adds
tests for the assemble module with fragments in assemble.d.
This commit is contained in:
Stephen Fromm
2012-06-11 23:09:54 -07:00
parent 93ac6c5ba0
commit 9cf182c225
6 changed files with 158 additions and 0 deletions

View File

@@ -231,5 +231,28 @@ class TestRunner(unittest.TestCase):
def test_service(self):
# TODO: tests for the service module
pass
def test_assemble(self):
input = self._get_test_file('assemble.d')
metadata = self._get_test_file('metadata.json')
output = self._get_stage_file('sample.out')
result = self._run('assemble', [
"src=%s" % input,
"dest=%s" % output,
"metadata=%s" % metadata
])
assert os.path.exists(output)
out = file(output).read()
assert out.find("first") != -1
assert out.find("second") != -1
assert out.find("third") != -1
assert result['changed'] == True
assert 'md5sum' in result
assert 'failed' not in result
result = self._run('assemble', [
"src=%s" % input,
"dest=%s" % output,
"metadata=%s" % metadata
])
assert result['changed'] == False

View File

@@ -0,0 +1,2 @@
# This is the first comment.
[somegroup]

View File

@@ -0,0 +1,2 @@
# This is the second comment.
127.0.0.2

View File

@@ -0,0 +1,4 @@
# This is the third comment.
[somegroup:vars]
foo=bar
# 無 可 無 非 常 無