def test__yes_context(): """ Tests _yes function when it exists in __context__ """ with patch.dict(chocolatey.__context__, {"chocolatey._yes": ["--yes"]}): result = chocolatey._yes() expected = ["--yes"] # Did it return correctly assert result == expected # Did it populate __context__ assert chocolatey.__context__["chocolatey._yes"] == expected
def test__yes_version_less_than(): """ Test _yes when Chocolatey version is less than 0.9.9 """ mock_version = MagicMock(return_value="0.9.0") with patch("salt.modules.chocolatey.chocolatey_version", mock_version): result = chocolatey._yes() expected = [] # Did it return correctly assert result == expected # Did it populate __context__ assert chocolatey.__context__["chocolatey._yes"] == expected
def test__yes_context(self): ''' Tests _yes function when it exists in __context__ ''' with patch.dict(chocolatey.__context__, {'chocolatey._yes': ['--yes']}): result = chocolatey._yes() expected = ['--yes'] # Did it return correctly self.assertListEqual(result, expected) # Did it populate __context__ self.assertEqual(chocolatey.__context__['chocolatey._yes'], expected)
def test__yes_version_less_than(self): ''' Test _yes when Chocolatey version is less than 0.9.9 ''' mock_version = MagicMock(return_value='0.9.0') with patch('salt.modules.chocolatey.chocolatey_version', mock_version): result = chocolatey._yes() expected = [] # Did it return correctly self.assertListEqual(result, expected) # Did it populate __context__ self.assertEqual(chocolatey.__context__['chocolatey._yes'], expected)
def test__yes_version_greater(self): """ Test _yes when Chocolatey version is greater than 0.9.9 """ mock_version = MagicMock(return_value="10.0.0") with patch("salt.modules.chocolatey.chocolatey_version", mock_version): result = chocolatey._yes() expected = ["--yes"] # Did it return correctly self.assertListEqual(result, expected) # Did it populate __context__ self.assertEqual(chocolatey.__context__["chocolatey._yes"], expected)
def test__yes_context(self): """ Tests _yes function when it exists in __context__ """ with patch.dict(chocolatey.__context__, {"chocolatey._yes": ["--yes"]}): result = chocolatey._yes() expected = ["--yes"] # Did it return correctly self.assertListEqual(result, expected) # Did it populate __context__ self.assertEqual(chocolatey.__context__["chocolatey._yes"], expected)