salt/tests/integration/modules/cp.py
2012-04-03 23:46:45 -06:00

59 lines
1.6 KiB
Python

# Import python libs
import os
# Import salt libs
import integration
class CPModuleTest(integration.ModuleCase):
'''
Validate the test module
'''
def test_get_file(self):
'''
cp.get_file
'''
tgt = os.path.join(integration.TMP, 'scene33')
self.run_function(
'cp.get_file',
[
'salt://grail/scene33',
tgt,
])
with open(tgt, 'r') as scene:
data = scene.read()
self.assertIn('KNIGHT: They\'re nervous, sire.', data)
self.assertNotIn('bacon', data)
def test_get_template(self):
'''
cp.get_template
'''
tgt = os.path.join(integration.TMP, 'scene33')
self.run_function(
'cp.get_template',
[
'salt://grail/scene33',
tgt,
'spam=bacon',
])
with open(tgt, 'r') as scene:
data = scene.read()
self.assertIn('bacon', data)
self.assertNotIn('spam', data)
def test_get_dir(self):
'''
cp.get_dir
'''
tgt = os.path.join(integration.TMP, 'many')
self.run_function(
'cp.get_dir',
[
'salt://grail',
tgt
])
self.assertIn('grail', os.listdir(tgt))
self.assertIn('36', os.listdir(os.path.join(tgt, 'grail')))
self.assertIn('empty', os.listdir(os.path.join(tgt, 'grail')))
self.assertIn('scene', os.listdir(os.path.join(tgt, 'grail', '36')))