コード例 #1
0
 def test_motd_create(self):
     ''' test for creating motd'''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = MockONTAPConnection(kind='motd')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     assert not exc.value.args[0]['changed']
コード例 #2
0
 def call_command(self, module_args):
     ''' utility function to call apply '''
     module_args.update(self.set_default_args())
     set_module_args(module_args)
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = MockONTAPConnection('motd')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     return exc.value.args[0]['changed']
コード例 #3
0
 def test_if_all_methods_catch_exception(self):
     set_module_args(self.set_default_args())
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = MockONTAPConnection('motd_fail')
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.motd_get()
     assert '' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.modify_motd()
     assert 'Error creating motd: ' in exc.value.args[0]['msg']
コード例 #4
0
 def test_ensure_get_called_existing(self):
     ''' test for existing motd'''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     my_obj.server = MockONTAPConnection(kind='motd')
     assert my_obj.motd_get()
コード例 #5
0
 def test_ensure_motd_get_called(self):
     ''' fetching details of motd '''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     my_obj.server = self.server
     assert my_obj.motd_get() is None
コード例 #6
0
 def test_module_fail_when_required_args_missing(self):
     ''' required arguments are reported as errors '''
     with pytest.raises(AnsibleFailJson) as exc:
         set_module_args({})
         my_module()
     print('Info: %s' % exc.value.args[0]['msg'])