コード例 #1
0
    def test_idempotent_disable_datacenter(self, *args):
        set_module_args(
            dict(state='disabled',
                 password='******',
                 server='localhost',
                 user='******',
                 name='foo'))

        client = AnsibleF5Client(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            f5_product_name=self.spec.f5_product_name)

        current = Parameters(load_fixture('load_gtm_datacenter_disabled.json'))

        mm = ModuleManager(client)

        # Override methods to force specific logic in the module to happen
        mm.exists = Mock(return_value=True)
        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 False
        assert results['enabled'] is False
コード例 #2
0
    def test_create_datacenter(self, *args):
        set_module_args(
            dict(state='present',
                 password='******',
                 server='localhost',
                 user='******',
                 name='foo'))

        client = AnsibleF5Client(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            f5_product_name=self.spec.f5_product_name)
        mm = ModuleManager(client)

        # Override methods to force specific logic in the module to happen
        mm.exists = Mock(side_effect=[False, True])
        mm.create_on_device = Mock(return_value=True)

        results = mm.exec_module()
        assert results['changed'] is True