2021-05-12 15:42:19 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright 2021 Red Hat
|
|
|
|
# GNU General Public License v3.0+
|
|
|
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
"""
|
|
|
|
Unit test file for netaddr test plugin: private
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
2022-05-26 17:18:57 +00:00
|
|
|
|
2021-05-12 15:42:19 +00:00
|
|
|
__metaclass__ = type
|
|
|
|
|
2024-03-28 06:00:53 +00:00
|
|
|
from unittest import TestCase
|
2022-05-26 17:18:57 +00:00
|
|
|
|
2021-05-12 15:42:19 +00:00
|
|
|
from ansible_collections.ansible.utils.plugins.test.private import _private
|
|
|
|
|
|
|
|
|
2024-03-28 06:00:53 +00:00
|
|
|
class TestPrivate(TestCase):
|
2021-05-12 15:42:19 +00:00
|
|
|
def setUp(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_invalid_data(self):
|
|
|
|
"""Check passing invalid argspec"""
|
|
|
|
|
|
|
|
# missing argument
|
|
|
|
with self.assertRaises(TypeError) as error:
|
|
|
|
_private()
|
|
|
|
self.assertIn("argument", str(error.exception))
|
|
|
|
|
|
|
|
def test_valid_data(self):
|
|
|
|
"""Check passing valid data as per criteria"""
|
|
|
|
|
|
|
|
result = _private(ip="10.1.1.1")
|
|
|
|
self.assertEqual(result, True)
|
|
|
|
|
|
|
|
result = _private(ip="8.8.8.8")
|
|
|
|
self.assertEqual(result, False)
|
|
|
|
|
|
|
|
result = _private(ip="string")
|
|
|
|
self.assertEqual(result, False)
|