Exemple #1
0
    def test_ensure_feature_is_enabled_called(self):
        set_module_args(dict(
            nitro_user='******',
            nitro_pass='******',
            nsip='192.0.2.1',
            state='present',
            save_config=False,
        ))
        from ansible_collections.notmintest.not_a_real_collection.plugins.modules import netscaler_lb_vserver

        client_mock = Mock()

        lb_vserver_proxy_mock = Mock()
        feature_mock = Mock()

        with patch.multiple(
            'ansible_collections.notmintest.not_a_real_collection.plugins.modules.netscaler_lb_vserver',
            get_nitro_client=Mock(return_value=client_mock),
            lb_vserver_exists=Mock(side_effect=[True, True]),
            lb_vserver_identical=Mock(side_effect=[True, True]),
            servicegroup_bindings_identical=Mock(side_effect=[True, True]),
            service_bindings_identical=Mock(side_effect=[True, True]),

            ConfigProxy=Mock(return_value=lb_vserver_proxy_mock),
            ensure_feature_is_enabled=feature_mock,
            do_state_change=Mock(return_value=Mock(errorcode=0)),
        ):
            self.module = netscaler_lb_vserver
            self.exited()
            feature_mock.assert_called_with(client_mock, 'LB')
    def test_ensure_feature_is_enabled_called(self):
        set_module_args(
            dict(
                nitro_user='******',
                nitro_pass='******',
                nsip='192.0.2.1',
                state='present',
            ))
        from ansible_collections.notmintest.not_a_real_collection.plugins.modules import netscaler_gslb_service

        gslb_service_proxy_mock = Mock()
        ensure_feature_is_enabled_mock = Mock()
        client_mock = Mock()

        with patch.multiple(
                'ansible_collections.notmintest.not_a_real_collection.plugins.modules.netscaler_gslb_service',
                get_nitro_client=Mock(return_value=client_mock),
                gslb_service_exists=Mock(side_effect=[False, True]),
                gslb_service_identical=Mock(side_effect=[True]),
                nitro_exception=self.MockException,
                ensure_feature_is_enabled=ensure_feature_is_enabled_mock,
                monkey_patch_nitro_api=Mock(),
                ConfigProxy=Mock(return_value=gslb_service_proxy_mock),
        ):
            self.module = netscaler_gslb_service
            self.exited()
            ensure_feature_is_enabled_mock.assert_called_with(
                client_mock, 'GSLB')