Skip to content

Commit 506536a

Browse files
authored
Add VBMLClient.format() (#221)
This calls the https://vbml.vestaboard.com/format endpoint, which formats a message string into rows of character codes.
1 parent e351ec3 commit 506536a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/vesta/clients.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,14 @@ def compose(
416416
r = self.http.post("/compose", json=data)
417417
r.raise_for_status()
418418
return r.json()
419+
420+
def format(self, message: str) -> Rows:
421+
"""Formats a message string into rows of character codes.
422+
423+
.. versionadded:: 0.13.0
424+
425+
:returns: Rows of character codes representing the formatted message
426+
"""
427+
data = {"message": message}
428+
r = self.http.post("/format", json=data)
429+
return r.json()

tests/test_clients.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,10 @@ def test_compose(self, vbml_client: VBMLClient, respx_mock: MockRouter):
325325
def test_component_no_components(self, vbml_client: VBMLClient):
326326
with pytest.raises(ValueError, match=r"expected at least one component"):
327327
vbml_client.compose([])
328+
329+
def test_format(self, vbml_client: VBMLClient, respx_mock: MockRouter):
330+
chars = [[0] * COLS] * ROWS
331+
respx_mock.post("https://vbml.vestaboard.com/format").respond(json=chars)
332+
333+
assert vbml_client.format("message") == chars
334+
assert respx_mock.calls.called

0 commit comments

Comments
 (0)