# Path: dyndnsc/detector/base.py
# LOG = logging.getLogger(__name__)
# class IPDetector(Subject, DynamicCliMixin):
#     def __init__(self, *args, **kwargs):
#     def can_detect_offline(self):
#     def af(self):
#     def get_old_value(self):
#     def set_old_value(self, value):
#     def get_current_value(self, default=None):
#     def set_current_value(self, value):
#     def has_changed(self):
#     def configuration_key_prefix():


import unittest
    import socket
        import dyndnsc.detector.builtin
        import dyndnsc.detector.manager
        import dyndnsc.detector.dns as ns
        import dyndnsc.detector.base
        import dyndnsc.detector.dns as ns
        import dyndnsc.detector.command
        import dyndnsc.detector.rand
        import dyndnsc.detector.rand
from dyndnsc.detector.base import AF_INET, AF_INET6, AF_UNSPEC
        from dyndnsc.detector import socket_ip
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import null
        self.assertTrue(isinstance(detector.detect(), (type(None), str)))
        self.assertTrue(detector.detect() in ("::1", "127.0.0.1"))
        self.assertTrue(detector.get_current_value() in ("::1", "127.0.0.1"))

        # test address family restriction to ipv4:
        detector = dyndnsc.detector.command.IPDetector_Command(command=cmd, family="INET")
        self.assertEqual(AF_INET, detector.af())

        # test address family restriction to ipv6:
        detector = dyndnsc.detector.command.IPDetector_Command(command=cmd, family="INET6")
        self.assertEqual(AF_INET6, detector.af())

    def test_rand_ip_generator(self):
        """Run tests for RandomIPGenerator."""
        generator = dyndnsc.detector.rand.RandomIPGenerator()
        self.assertTrue(generator.is_reserved_ip("127.0.0.1"))
        self.assertFalse(generator.is_reserved_ip("83.169.1.157"))
        self.assertFalse(generator.is_reserved_ip(generator.random_public_ip()))
        # for the sake of randomness, detect a bunch of IPs:
        _count = 0
        generator = dyndnsc.detector.rand.RandomIPGenerator(100)
        for _count, theip in enumerate(generator):
            self.assertFalse(generator.is_reserved_ip(theip))
        self.assertEqual(_count, 99)

    def test_rand_detector(self):
        """Run tests for IPDetector_Random."""
        self.assertEqual("random", dyndnsc.detector.rand.IPDetector_Random.configuration_key)
        detector = dyndnsc.detector.rand.IPDetector_Random()
        self.assertTrue(detector.can_detect_offline())

# Path: dyndnsc/detector/base.py
# LOG = logging.getLogger(__name__)
# class IPDetector(Subject, DynamicCliMixin):
#     def __init__(self, *args, **kwargs):
#     def can_detect_offline(self):
#     def af(self):
#     def get_old_value(self):
#     def set_old_value(self, value):
#     def get_current_value(self, default=None):
#     def set_current_value(self, value):
#     def has_changed(self):
#     def configuration_key_prefix():


# Path: dyndnsc/tests/detector/test_all.py
import unittest
    import socket
        import dyndnsc.detector.builtin
        import dyndnsc.detector.manager
        import dyndnsc.detector.dns as ns
        import dyndnsc.detector.base
        import dyndnsc.detector.dns as ns
        import dyndnsc.detector.command
        import dyndnsc.detector.rand
        import dyndnsc.detector.rand
from dyndnsc.detector.base import AF_INET, AF_INET6, AF_UNSPEC
        from dyndnsc.detector import socket_ip
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import webcheck
        from dyndnsc.detector import null

        self.assertTrue(isinstance(detector.detect(), (type(None), str)))
        self.assertTrue(detector.detect() in ("::1", "127.0.0.1"))
        self.assertTrue(detector.get_current_value() in ("::1", "127.0.0.1"))

        # test address family restriction to ipv4:
        detector = dyndnsc.detector.command.IPDetector_Command(command=cmd, family="INET")
        self.assertEqual(AF_INET, detector.af())

        # test address family restriction to ipv6:
        detector = dyndnsc.detector.command.IPDetector_Command(command=cmd, family="INET6")
        self.assertEqual(AF_INET6, detector.af())

    def test_rand_ip_generator(self):
        """Run tests for RandomIPGenerator."""
        generator = dyndnsc.detector.rand.RandomIPGenerator()
        self.assertTrue(generator.is_reserved_ip("127.0.0.1"))
        self.assertFalse(generator.is_reserved_ip("83.169.1.157"))
        self.assertFalse(generator.is_reserved_ip(generator.random_public_ip()))
        # for the sake of randomness, detect a bunch of IPs:
        _count = 0
        generator = dyndnsc.detector.rand.RandomIPGenerator(100)
        for _count, theip in enumerate(generator):
            self.assertFalse(generator.is_reserved_ip(theip))
        self.assertEqual(_count, 99)

    def test_rand_detector(self):
        """Run tests for IPDetector_Random."""
        self.assertEqual("random", dyndnsc.detector.rand.IPDetector_Random.configuration_key)
        detector = dyndnsc.detector.rand.IPDetector_Random()
        self.assertTrue(detector.can_detect_offline())

        self.assertEqual(AF_INET, detector.af())