コード例 #1
0
    def test_update(self, *args):
        # Configure the arguments that would be sent to the Ansible module
        set_module_args(dict(
            auto_check='no',
            auto_phone_home='no',
            password='******',
            server='localhost',
            user='******'
        ))

        # Configure the parameters that would be returned by querying the
        # remote device
        current = ApiParameters(params=load_fixture('load_sys_software_update.json'))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['auto_check'] is False
コード例 #2
0
 def test_api_parameters(self):
     args = dict(
         autoCheck="enabled",
         frequency="daily"
     )
     p = ApiParameters(params=args)
     assert p.auto_check == 'enabled'
     assert p.frequency == 'daily'