mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
add test class
This commit is contained in:
parent
d7d4066c46
commit
b7257baade
3 changed files with 44 additions and 0 deletions
1
templates/test/directory/{{module_name}}.py
Normal file
1
templates/test/directory/{{module_name}}.py
Normal file
|
@ -0,0 +1 @@
|
|||
{{year}}
|
1
templates/test/template.yml
Normal file
1
templates/test/template.yml
Normal file
|
@ -0,0 +1 @@
|
|||
description: "A test template for unit testing the extend module"
|
42
tests/unit/utils/extend_test.py
Normal file
42
tests/unit/utils/extend_test.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
tests.unit.utils.extend_test
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the salt extend script
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.extend
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting import TestCase
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
|
||||
class ExtendTestCase(TestCase):
|
||||
def setUp(self):
|
||||
self.out = None
|
||||
|
||||
def tearDown(self):
|
||||
if self.out is not None:
|
||||
if os.path.exists(self.out):
|
||||
shutil.rmtree(self.out, True)
|
||||
|
||||
def test_run(self):
|
||||
out = salt.utils.extend.run('test', 'test', 'this description', '.', False)
|
||||
self.out = out
|
||||
self.assertTrue(os.path.exists(out))
|
||||
self.assertFalse(os.path.exists(os.path.join(out, 'template.yml')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from unit import run_tests
|
||||
run_tests(ExtendTestCase, needs_daemon=False)
|
Loading…
Add table
Reference in a new issue