generated from pimoroni/boilerplate-python
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from pimoroni/feature/switch-counters
Add switch counter support
- Loading branch information
Showing
3 changed files
with
73 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
|
||
def test_setup_switch_counter(smbus2, ioe): | ||
ioe.setup_switch_counter(1) | ||
|
||
|
||
def test_read_switch_counter(smbus2, ioe): | ||
smbus2.i2c_msg.read().__iter__.return_value = [0b10000010] | ||
assert ioe.read_switch_counter(1) == (2, True) | ||
|
||
smbus2.i2c_msg.read().__iter__.return_value = [0b00000010] | ||
assert ioe.read_switch_counter(1) == (2, False) | ||
|
||
|
||
def test_switch_counter_invalid_pin(smbus2, ioe): | ||
with pytest.raises(ValueError): | ||
ioe.setup_switch_counter(10) | ||
|
||
with pytest.raises(ValueError): | ||
ioe.read_switch_counter(10) |