Skip to content

Commit

Permalink
Update zeroconf test to display expected result
Browse files Browse the repository at this point in the history
  • Loading branch information
Lohrer committed Jan 2, 2024
1 parent dad3e77 commit 9d18f30
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/test_zeroconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@

def test_zeroconf():
""" Unit test for zeroconf advertisement """
FAKE_PORT = 9898

# get default network interface
# get network interface and MAC address that the service is expected to be advertised on
iface = ni.gateways()['default'][ni.AF_INET][1]
FAKE_PORT = 9898
try:
mac_addr = ni.ifaddresses(iface)[ni.AF_LINK][0]['addr']
except:
mac_addr = 'none'

AMPLIPI_ZC_NAME = f'amplipi-{mac_addr}._amplipi._tcp.local.'
print(f'Expecting that "{AMPLIPI_ZC_NAME}" is advertised to interface {iface}')

services_advertised = {}

Expand All @@ -34,14 +41,6 @@ def on_service_state_change(zeroconf: Zeroconf, service_type: str, name: str, st
# wait enough time for a response from the service
sleep(2)

# figure out what the name will be
try:
mac_addr = ni.ifaddresses(iface)[ni.AF_LINK][0]['addr']
except:
mac_addr = 'none'

AMPLIPI_ZC_NAME = f'amplipi-{mac_addr}._amplipi._tcp.local.'

# stop the advertiser
event.set()
zc_reg.join()
Expand Down

0 comments on commit 9d18f30

Please sign in to comment.