Skip to content
Permalink
Browse files

freestyle support: restore correct order of parameters.

Also add a test so that we don't break this again in the future.
  • Loading branch information...
Flameeyes committed May 16, 2019
1 parent 7b4d366 commit a5a60d9c4bc6423ec5e68fb0c20a997dce245c96
Showing with 24 additions and 1 deletion.
  1. +1 −1 glucometerutils/support/freestyle.py
  2. +23 −0 test/test_freestyle.py
@@ -28,7 +28,7 @@
_INIT_SEQUENCE = (0x04, 0x05, 0x15, 0x01)

_FREESTYLE_MESSAGE = construct.Struct(
'hid_report' / construct.Const(construct.Byte, 0),
'hid_report' / construct.Const(0, construct.Byte),
'message_type' / construct.Byte,
'command' / construct.Padded(
63, # command can only be up to 62 bytes, but one is used for length.
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: MIT
"""Tests for the common FreeStyle functions.."""

# pylint: disable=protected-access,missing-docstring

from absl.testing import absltest

from glucometerutils.support import freestyle


class TestFreeStyle(absltest.TestCase):

def test_outgoing_command(self):
"""Test the generation of a new outgoing message."""

self.assertEqual(
b'\0\x17\7command\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'
b'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
freestyle._FREESTYLE_MESSAGE.build(
{'message_type': 23, 'command': b'command'}),
)

0 comments on commit a5a60d9

Please sign in to comment.
You can’t perform that action at this time.