Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
admd committed Oct 29, 2019
1 parent 6aedf58 commit 198d7f6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unit/test_minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,38 @@ def test_when_ping_interval_is_set_the_callback_should_be_added_to_periodic_call
finally:
minion.destroy()

def test_when_passed_start_event_grains(self):
mock_opts = self.get_config('minion', from_scratch=True)
mock_opts['start_event_grains'] = ["os"]
io_loop = tornado.ioloop.IOLoop()
io_loop.make_current()
minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
try:
minion.tok = MagicMock()
minion._send_req_sync = MagicMock()
minion._fire_master('Minion has started', 'minion_start')
load = minion._send_req_sync.call_args[0][0]

self.assertTrue('grains' in load)
self.assertTrue('os' in load['grains'])
finally:
minion.destroy()

def test_when_not_passed_start_event_grains(self):
mock_opts = self.get_config('minion', from_scratch=True)
io_loop = tornado.ioloop.IOLoop()
io_loop.make_current()
minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
try:
minion.tok = MagicMock()
minion._send_req_sync = MagicMock()
minion._fire_master('Minion has started', 'minion_start')
load = minion._send_req_sync.call_args[0][0]

self.assertTrue('grains' not in load)
finally:
minion.destroy()

def test_minion_retry_dns_count(self):
'''
Tests that the resolve_dns will retry dns look ups for a maximum of
Expand Down

0 comments on commit 198d7f6

Please sign in to comment.