def test__main__unregister_source__physical(self):
        self.load_module_args(state="absent")
        # => Configure Patchers
        patch_list = self.patch__methods(reg_return=1)

        with self.assertRaises(AnsibleExitJson) as exc:
            cohesity_source.main()

        result = exc.exception.args[0]
        self.assertEqual(result['changed'], True, result)
        self.assertEqual(
            result['msg'],
            'Unregistration of Cohesity Protection Source Complete', result)
        self.unload_patchers(patch_list)
    def test__main__unregister_source__no_change(self):
        self.load_module_args(state="absent")
        # => Configure Patchers
        patch_list = self.patch__methods(reg_return=False)

        with self.assertRaises(AnsibleExitJson) as exc:
            cohesity_source.main()

        result = exc.exception.args[0]
        self.assertEqual(result['changed'], False, result)
        self.assertEqual(
            result['msg'],
            'The Protection Source for this host is currently not registered',
            result)
        self.unload_patchers(patch_list)
    def test__main__register_source__nas_smb__check_fail(self):
        patchers = dict(patchers=[])
        override_args = dict(endpoint="\\\\server\\share",
                             environment="GenericNas",
                             nas_protocol="SMB")
        self.load_module_args(**override_args)
        # => Configure Patchers
        patch_list = self.patch__methods()
        # patch_list['register_patcher'].stop()

        with self.assertRaises(AnsibleFailJson) as exc:
            cohesity_source.main()

        result = exc.exception.args[0]
        self.assertEqual(result['changed'], False, result)
        self.assertEqual(
            result['msg'],
            'The following variables are mandatory for this action (creation) when working with environment type (GenericNas)',
            result)
        self.unload_patchers(patch_list)
    def test__main__register_source__nas_smb__check_pass(self):
        patchers = dict(patchers=[])
        override_args = dict(endpoint="\\\\server\\share",
                             environment="GenericNas",
                             nas_protocol="SMB",
                             nas_username="******",
                             nas_password="******")
        self.load_module_args(**override_args)
        # => Configure Patchers
        patch_list = self.patch__methods()

        with self.assertRaises(AnsibleExitJson) as exc:
            cohesity_source.main()

        result = exc.exception.args[0]
        self.assertEqual(result['changed'], True, result)
        self.assertEqual(
            result['msg'],
            'Registration of Cohesity Protection Source Complete', result)
        self.unload_patchers(patch_list)