1111from switchbot .const .lock import LockStatus
1212from switchbot .models import SwitchBotAdvertisement
1313
14+ from . import AirPurifierTestCase
15+
1416ADVERTISEMENT_DATA_DEFAULTS = {
1517 "local_name" : "" ,
1618 "manufacturer_data" : {},
@@ -2647,9 +2649,9 @@ def test_s10_with_empty_data() -> None:
26472649
26482650
26492651@pytest .mark .parametrize (
2650- ( "manufacturer_data" , "service_data" , "data" , "model" ) ,
2652+ "test_case" ,
26512653 [
2652- (
2654+ AirPurifierTestCase (
26532655 b"\xf0 \x9e \x9e \x96 j\xd6 \xa1 \x81 \x88 \xe4 \x00 \x01 \x95 \x00 \x00 " ,
26542656 b"7\x00 \x00 \x95 -\x00 " ,
26552657 {
@@ -2664,8 +2666,10 @@ def test_s10_with_empty_data() -> None:
26642666 "sequence_number" : 161 ,
26652667 },
26662668 "7" ,
2669+ "Air Purifier Table" ,
2670+ SwitchbotModel .AIR_PURIFIER_TABLE ,
26672671 ),
2668- (
2672+ AirPurifierTestCase (
26692673 b'\xcc \x8d \xa2 \xa7 \x92 >\t "\x80 \x00 0\x00 \x0f \x00 \x00 ' ,
26702674 b"*\x00 \x00 \x15 \x04 \x00 " ,
26712675 {
@@ -2680,8 +2684,10 @@ def test_s10_with_empty_data() -> None:
26802684 "sequence_number" : 9 ,
26812685 },
26822686 "*" ,
2687+ "Air Purifier" ,
2688+ SwitchbotModel .AIR_PURIFIER ,
26832689 ),
2684- (
2690+ AirPurifierTestCase (
26852691 b"\xcc \x8d \xa2 \xa7 \xe4 \xa6 \x0b \x83 \x88 d\x00 \xea `\x00 \x00 " ,
26862692 b"+\x00 \x00 \x15 \x04 \x00 " ,
26872693 {
@@ -2696,8 +2702,10 @@ def test_s10_with_empty_data() -> None:
26962702 "sequence_number" : 11 ,
26972703 },
26982704 "+" ,
2705+ "Air Purifier" ,
2706+ SwitchbotModel .AIR_PURIFIER ,
26992707 ),
2700- (
2708+ AirPurifierTestCase (
27012709 b"\xcc \x8d \xa2 \xa7 \xc1 \xae \x9b \x81 \x8c \xb2 \x00 \x01 \x94 \x00 \x00 " ,
27022710 b"8\x00 \x00 \x95 -\x00 " ,
27032711 {
@@ -2712,8 +2720,10 @@ def test_s10_with_empty_data() -> None:
27122720 "sequence_number" : 155 ,
27132721 },
27142722 "8" ,
2723+ "Air Purifier Table" ,
2724+ SwitchbotModel .AIR_PURIFIER_TABLE ,
27152725 ),
2716- (
2726+ AirPurifierTestCase (
27172727 b"\xcc \x8d \xa2 \xa7 \xc1 \xae \x9e \xa1 \x8c \x80 0\x01 \x95 \x00 \x00 " ,
27182728 b"8\x00 \x00 \x95 -\x00 " ,
27192729 {
@@ -2728,8 +2738,10 @@ def test_s10_with_empty_data() -> None:
27282738 "sequence_number" : 158 ,
27292739 },
27302740 "8" ,
2741+ "Air Purifier Table" ,
2742+ SwitchbotModel .AIR_PURIFIER_TABLE ,
27312743 ),
2732- (
2744+ AirPurifierTestCase (
27332745 b"\xcc \x8d \xa2 \xa7 \xc1 \xae \x9e \x05 \x8c \x80 0\x01 \x95 \x00 \x00 " ,
27342746 b"8\x00 \x00 \x95 -\x00 " ,
27352747 {
@@ -2744,26 +2756,28 @@ def test_s10_with_empty_data() -> None:
27442756 "sequence_number" : 158 ,
27452757 },
27462758 "8" ,
2759+ "Air Purifier Table" ,
2760+ SwitchbotModel .AIR_PURIFIER_TABLE ,
27472761 ),
27482762 ],
27492763)
2750- def test_air_purifier_active (manufacturer_data , service_data , data , model ) -> None :
2764+ def test_air_purifier_active (test_case : AirPurifierTestCase ) -> None :
27512765 ble_device = generate_ble_device ("aa:bb:cc:dd:ee:ff" , "any" )
27522766 adv_data = generate_advertisement_data (
2753- manufacturer_data = {2409 : manufacturer_data },
2754- service_data = {"0000fd3d-0000-1000-8000-00805f9b34fb" : service_data },
2767+ manufacturer_data = {2409 : test_case . manufacturer_data },
2768+ service_data = {"0000fd3d-0000-1000-8000-00805f9b34fb" : test_case . service_data },
27552769 rssi = - 97 ,
27562770 )
27572771 result = parse_advertisement_data (ble_device , adv_data )
27582772 assert result == SwitchBotAdvertisement (
27592773 address = "aa:bb:cc:dd:ee:ff" ,
27602774 data = {
2761- "rawAdvData" : service_data ,
2762- "data" : data ,
2775+ "rawAdvData" : test_case . service_data ,
2776+ "data" : test_case . data ,
27632777 "isEncrypted" : False ,
2764- "model" : model ,
2765- "modelFriendlyName" : "Air Purifier" ,
2766- "modelName" : SwitchbotModel . AIR_PURIFIER ,
2778+ "model" : test_case . model ,
2779+ "modelFriendlyName" : test_case . modelFriendlyName ,
2780+ "modelName" : test_case . modelName ,
27672781 },
27682782 device = ble_device ,
27692783 rssi = - 97 ,
@@ -2796,7 +2810,7 @@ def test_air_purifier_passive() -> None:
27962810 "sequence_number" : 161 ,
27972811 },
27982812 "isEncrypted" : False ,
2799- "model" : "8 " ,
2813+ "model" : "+ " ,
28002814 "modelFriendlyName" : "Air Purifier" ,
28012815 "modelName" : SwitchbotModel .AIR_PURIFIER ,
28022816 },
0 commit comments