Skip to content

Commit

Permalink
Adding a couple tests for testing disabled_requisites
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgreenaway committed Oct 14, 2018
1 parent 8cd3887 commit e3e63c9
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/unit/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,61 @@ def test_render_error_on_invalid_requisite(self):
with self.assertRaises(salt.exceptions.SaltRenderError):
state_obj.call_high(high_data)

def test_render_requisite_require_disabled(self):
'''
Test that the state compiler correctly deliver a rendering
exception when a requisite cannot be resolved
'''
with patch('salt.state.State._gather_pillar') as state_patch:
high_data = {
'step_one': OrderedDict([
('test', [
OrderedDict([
('require', [
OrderedDict([
('test', 'step_two')])])]),
'succeed_with_changes', {'order': 10000}]),
('__sls__', 'test.disable_require'),
('__env__', 'base')]),
'step_two': {'test': ['succeed_with_changes',
{'order': 10001}],
'__env__': 'base',
'__sls__': 'test.disable_require'}}

minion_opts = self.get_temp_config('minion')
minion_opts['disabled_requisites'] = ['require']
state_obj = salt.state.State(minion_opts)
ret = state_obj.call_high(high_data)
run_num = ret['test_|-step_one_|-step_one_|-succeed_with_changes']['__run_num__']
self.assertEqual(run_num, 0)

def test_render_requisite_require_in_disabled(self):
'''
Test that the state compiler correctly deliver a rendering
exception when a requisite cannot be resolved
'''
with patch('salt.state.State._gather_pillar') as state_patch:
high_data = {
'step_one': {'test': ['succeed_with_changes',
{'order': 10000}],
'__env__': 'base',
'__sls__': 'test.disable_require_in'},
'step_two': OrderedDict([
('test', [
OrderedDict([
('require_in', [
OrderedDict([
('test', 'step_one')])])]),
'succeed_with_changes', {'order': 10001}]),
('__sls__', 'test.disable_require_in'),
('__env__', 'base')])}

minion_opts = self.get_temp_config('minion')
minion_opts['disabled_requisites'] = ['require_in']
state_obj = salt.state.State(minion_opts)
ret = state_obj.call_high(high_data)
run_num = ret['test_|-step_one_|-step_one_|-succeed_with_changes']['__run_num__']
self.assertEqual(run_num, 0)

class HighStateTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
def setUp(self):
Expand Down

0 comments on commit e3e63c9

Please sign in to comment.