added state test template

This commit is contained in:
Anthony Shaw 2016-07-25 14:32:02 +10:00
parent a73bbc03de
commit 2dcedb1548
3 changed files with 60 additions and 1 deletions

View File

@ -21,7 +21,8 @@ except ImportError as ie:
MODULE_OPTIONS = [
('module', 'Execution module'),
('state', 'State module'),
('module_test', 'Execution module unit test')
('module_test', 'Execution module unit test'),
('state_test', 'State module unit test')
]

View File

@ -0,0 +1,12 @@
{
"full_name": "",
"email": "",
"project_name": "project_name",
"project_slug": "tests",
"repo_name": "project_name",
"project_short_description": "short_description",
"release_date": "2016-06-06",
"year": "2016",
"version": "Carbon",
"open_source_license": ["Apache Software License 2.0"]
}

View File

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`{{cookiecutter.full_name}} <{{cookiecutter.email}}>`
'''
# Import Python Libs
from __future__ import absolute_import
# Import Salt Testing Libs
from salttesting import skipIf
from tests.unit import ModuleTestCase, hasDependency
from salttesting.mock import (
patch,
NO_MOCK,
NO_MOCK_REASON
)
from salttesting.helpers import ensure_in_syspath
from salt.states import {{cookiecutter.project_name}}
ensure_in_syspath('../../')
SERVICE_NAME = '{{cookiecutter.project_name}}'
{{cookiecutter.project_name}}.__salt__ = {}
@skipIf(NO_MOCK, NO_MOCK_REASON)
class {{cookiecutter.project_name|capitalize}}TestCase(ModuleTestCase):
def setUp(self):
# Optionally, tell the tests that you have a module installed into sys.modules
# hasDependency('library_name')
def get_config(service):
# generator for the configuration of the tests
return {}
self.setup_loader()
self.loader.set_result({{cookiecutter.project_name}}, 'config.option', get_config)
def test_behaviour(self):
# Test inherent behaviours
pass
if __name__ == '__main__':
from unit import run_tests
run_tests({{cookiecutter.project_name|capitalize}}TestCase)