Skip to content

Commit f5f67b6

Browse files
committed
Fix tests
1 parent 706eaf9 commit f5f67b6

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

comitup/mdns.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ def string_array_to_txt_array(txt_array: List[str]) -> List[List[bytes]]:
105105
return [string_to_txt_array(x) for x in txt_array]
106106

107107

108-
def add_service(host: str, devindex: int, addr: str, addr6: str) -> None:
108+
def add_service(
109+
host: str, devindex: int, addr: Optional[str], addr6: Optional[str]
110+
) -> None:
109111
name = host
110112
(conf, data) = config.load_data()
111113
if ".local" in name:
@@ -181,29 +183,36 @@ def add_hosts(hosts: List[str]) -> None:
181183
addr = nm.get_active_ip(device)
182184
addr6 = nm.get_active_ip6(device)
183185
log.debug("add_hosts: {}, {}".format(name, addr))
184-
if (
185-
name in nm.get_phys_dev_names()
186-
and name in int_mapping
187-
):
186+
if name in nm.get_phys_dev_names() and name in int_mapping:
188187
index = int_mapping[name]
189188

190189
try:
191190
if addr and addr != "0.0.0.0":
192191
for host in hosts:
193-
log.debug("Add A record {}-{}-{}".format(host, index, addr))
192+
log.debug(
193+
"Add A record {}-{}-{}".format(host, index, addr)
194+
)
194195
make_a_record(host, index, addr)
195196

196197
entries = True
197198

198199
if addr6:
199200
for host in hosts:
200-
log.debug("Add AAAA record {}-{}-{}".format(host, index, addr6))
201+
log.debug(
202+
"Add AAAA record {}-{}-{}".format(
203+
host, index, addr6
204+
)
205+
)
201206
make_aaaa_record(host, index, addr6)
202207

203208
entries = True
204209

205210
if addr6 or (addr and addr != "0.0.0.0"):
206-
log.debug("Add service {}, {}, {}-{}".format(host, index, addr, addr6))
211+
log.debug(
212+
"Add service {}, {}, {}-{}".format(
213+
host, index, addr, addr6
214+
)
215+
)
207216
add_service(hosts[0], index, addr, addr6)
208217

209218
except Exception:

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
mypy_path: stubs
44

5-
[mypy-dbus,dbus.*,gi.*,pytest,RPi.*,venv]
5+
[mypy-dbus,dbus.*,gi.*,pytest,RPi.*,venv,setuptools]
66
ignore_missing_imports = true

stubs/NetworkManager.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ class Device(NMDbusInterface):
2424
def Disconnect() -> None: ...
2525
@staticmethod
2626
def GetAllAccessPoints() -> List[AccessPoint]: ...
27-
28-
class Ip4Config():
29-
Addresses: List[List[str]]
27+
class Ip4Config:
28+
Addresses: List[List[str]]
29+
class Ip6Config:
30+
Addresses: List[List[str]]
3031

3132
class Wireless(Device): ...
3233

test/test_mdns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_avahi_make_a_record(avahi_fxt):
4545

4646

4747
def test_avahi_add_service(avahi_fxt):
48-
mdns.add_service("host", "1", "1.2.3.4")
48+
mdns.add_service("host", "1", "1.2.3.4", "::1")
4949
assert mdns.group.AddService.called
5050

5151

0 commit comments

Comments
 (0)