Skip to content

Commit 3cce86c

Browse files
committed
no cover
1 parent e431d5f commit 3cce86c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/pms/extra/mqtt.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def publisher(
1717
"""returns function to publish to `topic` at `host`"""
1818
c = Client(client_id=topic)
1919
c.enable_logger(logger) # type:ignore[arg-type]
20-
if username:
20+
if username: # pragma: no cover
2121
c.username_pw_set(username, password)
2222

2323
c.on_connect = lambda client, userdata, flags, rc: client.publish(
@@ -41,11 +41,8 @@ class Data(NamedTuple):
4141
value: float
4242

4343
def __str__(self):
44-
return f"{self.date:%F %T},{self.location},{self.measurement},{self.value}"
45-
46-
@property
47-
def date(self) -> datetime:
48-
return datetime.fromtimestamp(self.time)
44+
date = datetime.fromtimestamp(self.time)
45+
return f"{date:%F %T},{self.location},{self.measurement},{self.value}"
4946

5047
@staticmethod
5148
def now() -> int:
@@ -99,7 +96,7 @@ def on_message(client: Client, userdata, msg):
9996

10097
c = Client(client_id=topic)
10198
c.enable_logger(logger) # type:ignore[arg-type]
102-
if username:
99+
if username: # pragma: no cover
103100
c.username_pw_set(username, password)
104101

105102
c.on_connect = lambda client, userdata, flags, rc: client.subscribe(topic)

0 commit comments

Comments
 (0)