Example #1
0
 def test_clc_module_not_found(self):
     # Setup Mock Import Function
     real_import = __import__
     def mock_import(name, *args):
         if name == 'clc': raise ImportError
         return real_import(name, *args)
     # Under Test
     with mock.patch('__builtin__.__import__', side_effect=mock_import):
         reload(clc_aa_policy)
         clc_aa_policy.ClcAntiAffinityPolicy(self.module)
     # Assert Expected Behavior
     self.module.fail_json.assert_called_with(msg='clc-python-sdk required for this module')
     reload(clc_aa_policy)
Example #2
0
 def test_requests_invalid_version(self):
     # Setup Mock Import Function
     real_import = __import__
     def mock_import(name, *args):
         if name == 'requests':
             args[0]['requests'].__version__ = '2.4.0'
         return real_import(name, *args)
     # Under Test
     with mock.patch('__builtin__.__import__', side_effect=mock_import):
         reload(clc_aa_policy)
         clc_aa_policy.ClcAntiAffinityPolicy(self.module)
     # Assert Expected Behavior
     self.module.fail_json.assert_called_with(msg='requests library  version should be >= 2.5.0')
     reload(clc_aa_policy)
Example #3
0
 def test_requests_module_not_found(self):
     # Setup Mock Import Function
     real_import = __import__
     def mock_import(name, *args):
         if name == 'requests':
             args[0]['requests'].__version__ = '2.7.0'
             raise ImportError
         return real_import(name, *args)
     # Under Test
     with mock.patch('__builtin__.__import__', side_effect=mock_import):
         reload(clc_aa_policy)
         clc_aa_policy.ClcAntiAffinityPolicy(self.module)
     # Assert Expected Behavior
     self.module.fail_json.assert_called_with(msg='requests library is required for this module')
     reload(clc_aa_policy)