Skip to content

Commit

Permalink
Mac address case insensitivity and standardise to uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioisidoro committed Apr 11, 2020
1 parent 540cad7 commit dae74cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions simple_ruuvitag/ruuvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def convert_data_and_callback(self, data):
return

if mac_address:
# Standardise mac address to upper case
mac_address = mac_address.upper()
if mac_address in self.mac_blacklist:
log.debug("Skipping blacklisted mac %s", mac_address)
return
Expand Down
18 changes: 17 additions & 1 deletion tests/test_ruuvitag.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def mock_callbacks(self, callback):
"raw_data": 'some other device',
},
{
"address": 'CC:2C:6A:1E:59:3D',
"address": 'bb:2c:6a:1e:59:3e',
"raw_data": 'some other device',
},
{
"address": 'cc:2c:6a:1e:59:3d',
"raw_data": '1E0201060303AAFE1616AAFE10EE037275752E76692F23416A7759414D4663CD',
},
{
Expand Down Expand Up @@ -105,3 +109,15 @@ def test_blackisting_of_other_macs(self):
ble_client.start()

self.assertTrue('BB:2C:6A:1E:59:3D' in ble_client.mac_blacklist)
self.assertTrue('BB:2C:6A:1E:59:3E' in ble_client.mac_blacklist)

@patch('simple_ruuvitag.adaptors.dummy.DummyBle.mock_datas', mock_callbacks)
def test_case_insensitive_macs(self):
macs = ['cc:2c:6a:1e:59:3d']

ble_client = RuuviTagClient(mac_addresses=macs, adapter='dummy')
ble_client.start()

data = ble_client.get_current_datas()

self.assertTrue('CC:2C:6A:1E:59:3D' in data)

0 comments on commit dae74cf

Please sign in to comment.