Repository: MGough/sensorhub

Issue:
Constructor argument
Hi, thanks for this, it's nicer than the code sample provided by the manufacturer.

I've noticed that the constructor now requires a positional argument, you might want to update the README's "how to use" paragraph perhaps?

I'm using `hub = SensorHub(None)` but I'm sure there are better ways to handle that.


Discussion:

Patch:
diff --git a/sensorhub/hub.py b/sensorhub/hub.py
index d1c72d8..baf98d3 100644
--- a/sensorhub/hub.py
+++ b/sensorhub/hub.py
@@ -31,7 +31,7 @@ class StatusRegisterErrorCode(Enum):
 class SensorHub:
     _bus: SMBus
 
-    def __init__(self, system_management_bus: SMBus):
+    def __init__(self, system_management_bus: SMBus = None):
         self._bus = system_management_bus or SMBus(DEVICE_BUS)
 
     def _read_sensor_board_register(self, buffer: SensorRegister) -> int:
diff --git a/setup.py b/setup.py
index 5b1420c..750c44f 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
 
 setuptools.setup(
     name="sensorhub",
-    version="2.0.0",
+    version="2.0.1",
     author="Merlin Gough",
     author_email="goughmerlin@gmail.com",
     description="A simple library to use with the DockerPi SensorHub (EP-0106)",


Test patch:
diff --git a/test/test_hub.py b/test/test_hub.py
index 4d639e6..bf40723 100644
--- a/test/test_hub.py
+++ b/test/test_hub.py
@@ -1,9 +1,9 @@
 from pytest import fixture, raises, mark
-from unittest.mock import call, Mock
+from unittest.mock import call, Mock, patch
 
 from smbus2 import SMBus
 
-from sensorhub.hub import SensorHub, SensorRegister
+from sensorhub.hub import SensorHub, SensorRegister, DEVICE_BUS
 
 
 @fixture
@@ -216,3 +216,12 @@ def test_barometer_pressure_returns_expected_reading(sensor_hub, bus, device_add
         call(device_address, SensorRegister.BAROMETRIC_PRESSURE_MIDDLE.value),
         call(device_address, SensorRegister.BAROMETRIC_PRESSURE_HIGH.value)
     ])
+
+
+@patch("sensorhub.hub.SMBus", autospec=True)
+def test_can_be_created_with_default_smbus(sm_bus):
+    hub = SensorHub()
+
+    assert hub._bus == sm_bus.return_value
+    sm_bus.assert_called_once_with(DEVICE_BUS)
+