render empty token correctly

This commit is contained in:
meejah 2021-04-15 19:19:14 -06:00
parent aa58b85ace
commit bfd8312ef0
2 changed files with 21 additions and 4 deletions

View File

@ -178,6 +178,7 @@ class TransitServerState(object):
d = "-"
if self._token is not None:
d = self._token[:16].decode("ascii")
if self._side is not None:
d += "-" + self._side.decode("ascii")
else:

View File

@ -22,6 +22,7 @@ from ..usage import (
)
from ..transit_server import (
WebSocketTransitConnection,
TransitServerState,
)
@ -677,3 +678,18 @@ class UsageWebSockets(Usage):
)
self._pumps.append(pump)
return client_protocol
class State(unittest.TestCase):
"""
Tests related to server_state.TransitServerState
"""
def setUp(self):
self.state = TransitServerState(None, None)
def test_empty_token(self):
self.assertEqual(
"-",
self.state.get_token(),
)