def _runner(self, expected_ret, pillar_name=None): with patch('salt.utils.minions.CkMinions.check_minions', MagicMock(side_effect=side_effect)): pillar_name = pillar_name or fake_pillar_name actual_ret = nodegroups.ext_pillar(fake_minion_id, fake_pillar, pillar_name=pillar_name) self.assertDictEqual(actual_ret, expected_ret)
def _runner(self, expected_ret, pillar_name=None, nodegroup_matches=None): pillar_name = pillar_name or fake_pillar_name nodegroup_matches = nodegroup_matches or [ True, False, ] mock_nodegroup_match = MagicMock(side_effect=nodegroup_matches) with patch.object(nodegroups.Matcher, 'nodegroup_match', mock_nodegroup_match): actual_ret = nodegroups.ext_pillar(fake_minion_id, fake_pillar, pillar_name=pillar_name) self.assertDictEqual(actual_ret, expected_ret) fake_nodegroup_count = len(fake_nodegroups) self.assertEqual(mock_nodegroup_match.call_count, fake_nodegroup_count) mock_nodegroup_match.assert_has_calls( [call(x, fake_nodegroups) for x in fake_nodegroups.keys()])
def _runner(self, expected_ret, pillar_name=None): pillar_name = pillar_name or fake_pillar_name actual_ret = nodegroups.ext_pillar(fake_minion_id, fake_pillar, pillar_name=pillar_name) self.assertDictEqual(actual_ret, expected_ret)