Browse Source

refactor: move some tests from test_config.py to config/test_0x04_0x05_sync1_sync0.py

Fabian Peter Hammerle 3 years ago
parent
commit
ccd4312656
2 changed files with 42 additions and 23 deletions
  1. 42 0
      tests/config/test_0x04_0x05_sync1_sync0.py
  2. 0 23
      tests/test_config.py

+ 42 - 0
tests/config/test_0x04_0x05_sync1_sync0.py

@@ -0,0 +1,42 @@
+# python-cc1101 - Python Library to Transmit RF Signals via C1101 Transceivers
+#
+# Copyright (C) 2020 Fabian Peter Hammerle <fabian@hammerle.me>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+import pytest
+
+# pylint: disable=protected-access
+
+
+@pytest.mark.parametrize(
+    ("xfer_return_value", "sync_word"),
+    [([64, 211, 145], b"\xd3\x91"), ([64, 0, 0], b"\0\0")],
+)
+def test_get_sync_word(transceiver, xfer_return_value, sync_word):
+    transceiver._spi.xfer.return_value = xfer_return_value
+    assert transceiver.get_sync_word() == sync_word
+    transceiver._spi.xfer.assert_called_once_with([0x04 | 0xC0, 0, 0])
+
+
+def test_set_sync_word(transceiver):
+    transceiver._spi.xfer.return_value = [15, 15, 15]
+    transceiver.set_sync_word(b"\x12\x34")
+    transceiver._spi.xfer.assert_called_once_with([0x04 | 0x40, 0x12, 0x34])
+
+
+@pytest.mark.parametrize("sync_word", [b"", b"\0", "\x12\x34\x56"])
+def test_set_sync_word_invalid_length(transceiver, sync_word):
+    with pytest.raises(ValueError, match=r"\bexpected two bytes\b"):
+        transceiver.set_sync_word(sync_word)

+ 0 - 23
tests/test_config.py

@@ -24,29 +24,6 @@ import cc1101
 
 # pylint: disable=protected-access
 
-
-@pytest.mark.parametrize(
-    ("xfer_return_value", "sync_word"),
-    [([64, 211, 145], b"\xd3\x91"), ([64, 0, 0], b"\0\0")],
-)
-def test_get_sync_word(transceiver, xfer_return_value, sync_word):
-    transceiver._spi.xfer.return_value = xfer_return_value
-    assert transceiver.get_sync_word() == sync_word
-    transceiver._spi.xfer.assert_called_once_with([0x04 | 0xC0, 0, 0])
-
-
-def test_set_sync_word(transceiver):
-    transceiver._spi.xfer.return_value = [15, 15, 15]
-    transceiver.set_sync_word(b"\x12\x34")
-    transceiver._spi.xfer.assert_called_once_with([0x04 | 0x40, 0x12, 0x34])
-
-
-@pytest.mark.parametrize("sync_word", [b"", b"\0", "\x12\x34\x56"])
-def test_set_sync_word_invalid_length(transceiver, sync_word):
-    with pytest.raises(ValueError, match=r"\bexpected two bytes\b"):
-        transceiver.set_sync_word(sync_word)
-
-
 _FREQUENCY_CONTROL_WORD_HERTZ_PARAMS = [
     ([0x10, 0xA7, 0x62], 433000000),
     ([0x10, 0xAB, 0x85], 433420000),