# 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(detector.get_current_value() in ("::1", "127.0.0.1", "fe80::1%lo0"))
        # test address family restriction to ipv4:
        detector = ns.IPDetector_DNS(hostname="localhost", family="INET")
        self.assertEqual(AF_INET, detector.af())
        self.assertTrue(detector.detect() in ("127.0.0.1", ))
        # test address family restriction to ipv6:
        if HAVE_IPV6:
            detector = ns.IPDetector_DNS(hostname="localhost", family="INET6")
            self.assertEqual(AF_INET6, detector.af())
            val = detector.detect()
            self.assertTrue(val in ("::1", "fe80::1%lo0"), "%r not known" % val)

    def test_command_detector(self):
        """Run tests for IPDetector_Command."""
        cmd = "echo 127.0.0.1"
        self.assertEqual("command", dyndnsc.detector.command.IPDetector_Command.configuration_key)
        detector = dyndnsc.detector.command.IPDetector_Command(command=cmd)
        self.assertFalse(detector.can_detect_offline())
        self.assertEqual(AF_UNSPEC, detector.af())
        self.assertEqual(None, detector.get_current_value())
        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")

# 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(detector.get_current_value() in ("::1", "127.0.0.1", "fe80::1%lo0"))
        # test address family restriction to ipv4:
        detector = ns.IPDetector_DNS(hostname="localhost", family="INET")
        self.assertEqual(AF_INET, detector.af())
        self.assertTrue(detector.detect() in ("127.0.0.1", ))
        # test address family restriction to ipv6:
        if HAVE_IPV6:
            detector = ns.IPDetector_DNS(hostname="localhost", family="INET6")
            self.assertEqual(AF_INET6, detector.af())
            val = detector.detect()
            self.assertTrue(val in ("::1", "fe80::1%lo0"), "%r not known" % val)

    def test_command_detector(self):
        """Run tests for IPDetector_Command."""
        cmd = "echo 127.0.0.1"
        self.assertEqual("command", dyndnsc.detector.command.IPDetector_Command.configuration_key)
        detector = dyndnsc.detector.command.IPDetector_Command(command=cmd)
        self.assertFalse(detector.can_detect_offline())
        self.assertEqual(AF_UNSPEC, detector.af())
        self.assertEqual(None, detector.get_current_value())
        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())