-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
177 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
``busio.I2C`` | ||
============= | ||
|
||
.. autoclass:: circuitpython_mocks.busio.I2C | ||
:members: readfrom_into, writeto, writeto_then_readfrom, scan, try_lock, unlock, deinit | ||
|
||
I2C operations | ||
************** | ||
|
||
.. autoclass:: circuitpython_mocks.busio.operations.I2CRead | ||
.. autoclass:: circuitpython_mocks.busio.operations.I2CWrite | ||
.. autoclass:: circuitpython_mocks.busio.operations.I2CTransfer | ||
.. autoclass:: circuitpython_mocks.busio.operations.I2CScan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
``busio`` | ||
================= | ||
|
||
.. automodule:: circuitpython_mocks.busio | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
i2c | ||
spi | ||
uart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
``busio.SPI`` | ||
============= | ||
|
||
.. autoclass:: circuitpython_mocks.busio.SPI | ||
:members: readinto, write, write_readinto, configure, frequency, try_lock, unlock, deinit | ||
|
||
SPI operations | ||
************** | ||
|
||
.. autoclass:: circuitpython_mocks.busio.operations.SPIRead | ||
.. autoclass:: circuitpython_mocks.busio.operations.SPIWrite | ||
.. autoclass:: circuitpython_mocks.busio.operations.SPITransfer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
``busio.UART`` | ||
============== | ||
|
||
.. autoclass:: circuitpython_mocks.busio.UART | ||
:members: readinto, readline, write, in_waiting, reset_input_buffer, timeout, baudrate | ||
|
||
.. py:class:: circuitpython_mocks.busio.UART.Parity | ||
A mock enumeration of :external:py:class:`busio.Parity`. | ||
|
||
.. py:attribute:: ODD | ||
:type: Parity | ||
.. py:attribute:: EVEN | ||
:type: Parity | ||
|
||
UART operations | ||
*************** | ||
|
||
.. autoclass:: circuitpython_mocks.busio.operations.UARTRead | ||
.. autoclass:: circuitpython_mocks.busio.operations.UARTWrite | ||
.. autoclass:: circuitpython_mocks.busio.operations.UARTFlush |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
from collections import deque | ||
from circuitpython_mocks import board, busio | ||
from circuitpython_mocks.busio.operations import UARTRead, UARTWrite | ||
from circuitpython_mocks.busio.operations import UARTRead, UARTWrite, UARTFlush | ||
|
||
|
||
def test_singleton(): | ||
board_uart = board.UART() | ||
assert hasattr(board_uart, "expectations") | ||
assert isinstance(board_uart.expectations, deque) | ||
|
||
busio_uart = busio.UART(board.TX, board.RX) | ||
assert board_uart == busio_uart | ||
board_uart.timeout = 0.5 | ||
assert 0.5 == busio_uart.timeout | ||
busio_uart.baudrate = 115200 | ||
assert 115200 == board_uart.baudrate | ||
|
||
board_uart.expectations.append(UARTRead(bytearray(1))) | ||
assert busio_uart.expectations == board_uart.expectations | ||
buffer = bytearray(1) | ||
assert 1 == board_uart.in_waiting | ||
board_uart.readinto(buffer) | ||
assert not busio_uart.expectations | ||
|
||
busio_uart.expectations.append(UARTWrite(bytearray(1))) | ||
assert busio_uart.expectations == board_uart.expectations | ||
assert not busio_uart.in_waiting | ||
busio_uart.write(bytearray(1)) | ||
|
||
busio_uart.expectations.append(UARTFlush()) | ||
assert busio_uart.expectations == board_uart.expectations | ||
busio_uart.reset_input_buffer() | ||
|
||
# assert all expectations were used | ||
board_uart.done() | ||
assert busio_uart.expectations == board_uart.expectations |
Oops, something went wrong.