|
6 | 6 |
|
7 | 7 | import errno |
8 | 8 | import logging |
9 | | -import os |
10 | 9 | import socket |
11 | 10 | import time |
12 | 11 | import unittest |
13 | 12 | import unittest.mock |
14 | | -from threading import Event |
15 | 13 | from typing import Dict, Optional # noqa # used in type hints |
16 | 14 |
|
17 | 15 | import pytest |
18 | 16 |
|
19 | 17 | import zeroconf as r |
20 | | -from zeroconf import ServiceBrowser, ServiceInfo, Zeroconf, ZeroconfServiceTypes, const |
| 18 | +from zeroconf import ServiceBrowser, ServiceInfo, Zeroconf, const |
21 | 19 |
|
22 | | -from . import has_working_ipv6, _clear_cache, _inject_response |
| 20 | +from . import _clear_cache |
23 | 21 |
|
24 | 22 | log = logging.getLogger('zeroconf') |
25 | 23 | original_logging_level = logging.NOTSET |
@@ -459,135 +457,6 @@ def test_lookups(self): |
459 | 457 | assert registry.get_types() == [type_] |
460 | 458 |
|
461 | 459 |
|
462 | | -class ServiceTypesQuery(unittest.TestCase): |
463 | | - def test_integration_with_listener(self): |
464 | | - |
465 | | - type_ = "_test-srvc-type._tcp.local." |
466 | | - name = "xxxyyy" |
467 | | - registration_name = "%s.%s" % (name, type_) |
468 | | - |
469 | | - zeroconf_registrar = Zeroconf(interfaces=['127.0.0.1']) |
470 | | - desc = {'path': '/~paulsm/'} |
471 | | - info = ServiceInfo( |
472 | | - type_, |
473 | | - registration_name, |
474 | | - 80, |
475 | | - 0, |
476 | | - 0, |
477 | | - desc, |
478 | | - "ash-2.local.", |
479 | | - addresses=[socket.inet_aton("10.0.1.2")], |
480 | | - ) |
481 | | - zeroconf_registrar.register_service(info) |
482 | | - |
483 | | - try: |
484 | | - service_types = ZeroconfServiceTypes.find(interfaces=['127.0.0.1'], timeout=0.5) |
485 | | - assert type_ in service_types |
486 | | - _clear_cache(zeroconf_registrar) |
487 | | - service_types = ZeroconfServiceTypes.find(zc=zeroconf_registrar, timeout=0.5) |
488 | | - assert type_ in service_types |
489 | | - |
490 | | - finally: |
491 | | - zeroconf_registrar.close() |
492 | | - |
493 | | - @unittest.skipIf(not has_working_ipv6(), 'Requires IPv6') |
494 | | - @unittest.skipIf(os.environ.get('SKIP_IPV6'), 'IPv6 tests disabled') |
495 | | - def test_integration_with_listener_v6_records(self): |
496 | | - |
497 | | - type_ = "_test-srvc-type._tcp.local." |
498 | | - name = "xxxyyy" |
499 | | - registration_name = "%s.%s" % (name, type_) |
500 | | - addr = "2606:2800:220:1:248:1893:25c8:1946" # example.com |
501 | | - |
502 | | - zeroconf_registrar = Zeroconf(interfaces=['127.0.0.1']) |
503 | | - desc = {'path': '/~paulsm/'} |
504 | | - info = ServiceInfo( |
505 | | - type_, |
506 | | - registration_name, |
507 | | - 80, |
508 | | - 0, |
509 | | - 0, |
510 | | - desc, |
511 | | - "ash-2.local.", |
512 | | - addresses=[socket.inet_pton(socket.AF_INET6, addr)], |
513 | | - ) |
514 | | - zeroconf_registrar.register_service(info) |
515 | | - |
516 | | - try: |
517 | | - service_types = ZeroconfServiceTypes.find(interfaces=['127.0.0.1'], timeout=0.5) |
518 | | - assert type_ in service_types |
519 | | - _clear_cache(zeroconf_registrar) |
520 | | - service_types = ZeroconfServiceTypes.find(zc=zeroconf_registrar, timeout=0.5) |
521 | | - assert type_ in service_types |
522 | | - |
523 | | - finally: |
524 | | - zeroconf_registrar.close() |
525 | | - |
526 | | - @unittest.skipIf(not has_working_ipv6(), 'Requires IPv6') |
527 | | - @unittest.skipIf(os.environ.get('SKIP_IPV6'), 'IPv6 tests disabled') |
528 | | - def test_integration_with_listener_ipv6(self): |
529 | | - |
530 | | - type_ = "_test-srvc-type._tcp.local." |
531 | | - name = "xxxyyy" |
532 | | - registration_name = "%s.%s" % (name, type_) |
533 | | - |
534 | | - zeroconf_registrar = Zeroconf(ip_version=r.IPVersion.V6Only) |
535 | | - desc = {'path': '/~paulsm/'} |
536 | | - info = ServiceInfo( |
537 | | - type_, |
538 | | - registration_name, |
539 | | - 80, |
540 | | - 0, |
541 | | - 0, |
542 | | - desc, |
543 | | - "ash-2.local.", |
544 | | - addresses=[socket.inet_aton("10.0.1.2")], |
545 | | - ) |
546 | | - zeroconf_registrar.register_service(info) |
547 | | - |
548 | | - try: |
549 | | - service_types = ZeroconfServiceTypes.find(ip_version=r.IPVersion.V6Only, timeout=0.5) |
550 | | - assert type_ in service_types |
551 | | - _clear_cache(zeroconf_registrar) |
552 | | - service_types = ZeroconfServiceTypes.find(zc=zeroconf_registrar, timeout=0.5) |
553 | | - assert type_ in service_types |
554 | | - |
555 | | - finally: |
556 | | - zeroconf_registrar.close() |
557 | | - |
558 | | - def test_integration_with_subtype_and_listener(self): |
559 | | - subtype_ = "_subtype._sub" |
560 | | - type_ = "_type._tcp.local." |
561 | | - name = "xxxyyy" |
562 | | - # Note: discovery returns only DNS-SD type not subtype |
563 | | - discovery_type = "%s.%s" % (subtype_, type_) |
564 | | - registration_name = "%s.%s" % (name, type_) |
565 | | - |
566 | | - zeroconf_registrar = Zeroconf(interfaces=['127.0.0.1']) |
567 | | - desc = {'path': '/~paulsm/'} |
568 | | - info = ServiceInfo( |
569 | | - discovery_type, |
570 | | - registration_name, |
571 | | - 80, |
572 | | - 0, |
573 | | - 0, |
574 | | - desc, |
575 | | - "ash-2.local.", |
576 | | - addresses=[socket.inet_aton("10.0.1.2")], |
577 | | - ) |
578 | | - zeroconf_registrar.register_service(info) |
579 | | - |
580 | | - try: |
581 | | - service_types = ZeroconfServiceTypes.find(interfaces=['127.0.0.1'], timeout=0.5) |
582 | | - assert discovery_type in service_types |
583 | | - _clear_cache(zeroconf_registrar) |
584 | | - service_types = ZeroconfServiceTypes.find(zc=zeroconf_registrar, timeout=0.5) |
585 | | - assert discovery_type in service_types |
586 | | - |
587 | | - finally: |
588 | | - zeroconf_registrar.close() |
589 | | - |
590 | | - |
591 | 460 | def test_ptr_optimization(): |
592 | 461 |
|
593 | 462 | # instantiate a zeroconf instance |
|
0 commit comments