mirror of
				https://github.com/python-kasa/python-kasa.git
				synced 2025-11-03 22:22:06 +00:00 
			
		
		
		
	Cleanup fixture filenames (#448)
* Mark mocked fixtures as such * Use consistent filenames including the swver * Remove executable bit * Remove duplicate KL130(US) * Remove unnecessary mocks where we have real ones available * Fix filenames in tests
This commit is contained in:
		@@ -127,7 +127,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        >>> bulb = SmartBulb("127.0.0.1")
 | 
			
		||||
        >>> asyncio.run(bulb.update())
 | 
			
		||||
        >>> print(bulb.alias)
 | 
			
		||||
        KL130 office bulb
 | 
			
		||||
        Bulb2
 | 
			
		||||
 | 
			
		||||
        Bulbs, like any other supported devices, can be turned on and off:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								kasa/tests/fixtures/EP10(US)_1.0_1.0.2.json
									
									
									
									
										vendored
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										0
									
								
								kasa/tests/fixtures/EP10(US)_1.0_1.0.2.json
									
									
									
									
										vendored
									
									
										
										
										Executable file → Normal file
									
								
							
							
								
								
									
										47
									
								
								kasa/tests/fixtures/HS100(US)_1.0.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										47
									
								
								kasa/tests/fixtures/HS100(US)_1.0.json
									
									
									
									
										vendored
									
									
								
							@@ -1,47 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
    "emeter": {
 | 
			
		||||
        "get_realtime": {
 | 
			
		||||
            "err_code": -1,
 | 
			
		||||
            "err_msg": "module not support"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.common.emeter": {
 | 
			
		||||
        "err_code": -1,
 | 
			
		||||
        "err_msg": "module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.dimmer": {
 | 
			
		||||
        "err_code": -1,
 | 
			
		||||
        "err_msg": "module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.smartbulb.lightingservice": {
 | 
			
		||||
        "err_code": -1,
 | 
			
		||||
        "err_msg": "module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "system": {
 | 
			
		||||
        "get_sysinfo": {
 | 
			
		||||
            "active_mode": "schedule",
 | 
			
		||||
            "alias": "Mock hs100",
 | 
			
		||||
            "dev_name": "Wi-Fi Smart Plug",
 | 
			
		||||
            "deviceId": "048F069965D3230FD1382F0B78EAE68D42CAA2DE",
 | 
			
		||||
            "err_code": 0,
 | 
			
		||||
            "feature": "TIM",
 | 
			
		||||
            "hwId": "92688D028799C60F926049D1C9EFD9E8",
 | 
			
		||||
            "hw_ver": "1.0",
 | 
			
		||||
            "icon_hash": "",
 | 
			
		||||
            "latitude": 63.5442,
 | 
			
		||||
            "latitude_i": 63.5442,
 | 
			
		||||
            "led_off": 0,
 | 
			
		||||
            "longitude": -148.2817,
 | 
			
		||||
            "longitude_i": -148.2817,
 | 
			
		||||
            "mac": "50:c7:bf:a3:71:c0",
 | 
			
		||||
            "model": "HS100(US)",
 | 
			
		||||
            "oemId": "149C8A24AA3A1445DE84F00DFB210D60",
 | 
			
		||||
            "on_time": 0,
 | 
			
		||||
            "relay_state": 0,
 | 
			
		||||
            "rssi": -65,
 | 
			
		||||
            "sw_ver": "1.2.5 Build 171129 Rel.174814",
 | 
			
		||||
            "type": "IOT.SMARTPLUGSWITCH",
 | 
			
		||||
            "updating": 0
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										102
									
								
								kasa/tests/fixtures/HS300(US)_1.0.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										102
									
								
								kasa/tests/fixtures/HS300(US)_1.0.json
									
									
									
									
										vendored
									
									
								
							@@ -1,102 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
    "emeter": {
 | 
			
		||||
        "get_realtime": {
 | 
			
		||||
            "current_ma": 125,
 | 
			
		||||
            "err_code": 0,
 | 
			
		||||
            "power_mw": 3140,
 | 
			
		||||
            "total_wh": 51493,
 | 
			
		||||
            "voltage_mv": 122049
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.common.emeter": {
 | 
			
		||||
        "err_code": -1,
 | 
			
		||||
        "err_msg": "module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.dimmer": {
 | 
			
		||||
        "err_code": -1,
 | 
			
		||||
        "err_msg": "module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.smartbulb.lightingservice": {
 | 
			
		||||
        "err_code": -1,
 | 
			
		||||
        "err_msg": "module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "system": {
 | 
			
		||||
        "get_sysinfo": {
 | 
			
		||||
            "alias": "Mock hs300",
 | 
			
		||||
            "child_num": 6,
 | 
			
		||||
            "children": [
 | 
			
		||||
                {
 | 
			
		||||
                    "alias": "Mock One",
 | 
			
		||||
                    "id": "00",
 | 
			
		||||
                    "next_action": {
 | 
			
		||||
                        "type": -1
 | 
			
		||||
                    },
 | 
			
		||||
                    "on_time": 123,
 | 
			
		||||
                    "state": 1
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "alias": "Mock Two",
 | 
			
		||||
                    "id": "01",
 | 
			
		||||
                    "next_action": {
 | 
			
		||||
                        "type": -1
 | 
			
		||||
                    },
 | 
			
		||||
                    "on_time": 333,
 | 
			
		||||
                    "state": 1
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "alias": "Mock Three",
 | 
			
		||||
                    "id": "02",
 | 
			
		||||
                    "next_action": {
 | 
			
		||||
                        "type": -1
 | 
			
		||||
                    },
 | 
			
		||||
                    "on_time": 0,
 | 
			
		||||
                    "state": 0
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "alias": "Mock Four",
 | 
			
		||||
                    "id": "03",
 | 
			
		||||
                    "next_action": {
 | 
			
		||||
                        "type": -1
 | 
			
		||||
                    },
 | 
			
		||||
                    "on_time": 0,
 | 
			
		||||
                    "state": 0
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "alias": "Mock Five",
 | 
			
		||||
                    "id": "04",
 | 
			
		||||
                    "next_action": {
 | 
			
		||||
                        "type": -1
 | 
			
		||||
                    },
 | 
			
		||||
                    "on_time": 0,
 | 
			
		||||
                    "state": 0
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "alias": "Mock Six",
 | 
			
		||||
                    "id": "05",
 | 
			
		||||
                    "next_action": {
 | 
			
		||||
                        "type": -1
 | 
			
		||||
                    },
 | 
			
		||||
                    "on_time": 0,
 | 
			
		||||
                    "state": 0
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "deviceId": "4BFC2F2C8678FE623700FD3737EC4E245196F3CF",
 | 
			
		||||
            "err_code": 0,
 | 
			
		||||
            "feature": "TIM:ENE",
 | 
			
		||||
            "hwId": "1B63E5DF21B5AFB52F364DE66BFAAF8A",
 | 
			
		||||
            "hw_ver": "1.0",
 | 
			
		||||
            "latitude": -68.9980,
 | 
			
		||||
            "latitude_i": -68.9980,
 | 
			
		||||
            "led_off": 0,
 | 
			
		||||
            "longitude": -109.4400,
 | 
			
		||||
            "longitude_i": -109.4400,
 | 
			
		||||
            "mac": "50:c7:bf:c2:75:88",
 | 
			
		||||
            "mic_type": "IOT.SMARTPLUGSWITCH",
 | 
			
		||||
            "model": "HS300(US)",
 | 
			
		||||
            "oemId": "FC71DAAB004326F9369EDEF4353E4FE1",
 | 
			
		||||
            "rssi": -68,
 | 
			
		||||
            "sw_ver": "1.0.6 Build 180627 Rel.081000",
 | 
			
		||||
            "updating": 0
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										93
									
								
								kasa/tests/fixtures/KL130(US)_1.0.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										93
									
								
								kasa/tests/fixtures/KL130(US)_1.0.json
									
									
									
									
										vendored
									
									
								
							@@ -1,93 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
    "emeter": {
 | 
			
		||||
        "err_code": -2001,
 | 
			
		||||
        "err_msg": "Module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.common.emeter": {
 | 
			
		||||
        "get_realtime": {
 | 
			
		||||
            "err_code": 0,
 | 
			
		||||
            "power_mw": 800
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.dimmer": {
 | 
			
		||||
        "err_code": -2001,
 | 
			
		||||
        "err_msg": "Module not support"
 | 
			
		||||
    },
 | 
			
		||||
    "smartlife.iot.smartbulb.lightingservice": {
 | 
			
		||||
        "get_light_state": {
 | 
			
		||||
            "brightness": 0,
 | 
			
		||||
            "color_temp": 0,
 | 
			
		||||
            "err_code": 0,
 | 
			
		||||
            "hue": 15,
 | 
			
		||||
            "mode": "normal",
 | 
			
		||||
            "on_off": 1,
 | 
			
		||||
            "saturation": 100
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "system": {
 | 
			
		||||
        "get_sysinfo": {
 | 
			
		||||
            "active_mode": "none",
 | 
			
		||||
            "alias": "KL130 office bulb",
 | 
			
		||||
            "ctrl_protocols": {
 | 
			
		||||
                "name": "Linkie",
 | 
			
		||||
                "version": "1.0"
 | 
			
		||||
            },
 | 
			
		||||
            "description": "Smart Wi-Fi LED Bulb with Color Changing",
 | 
			
		||||
            "dev_state": "normal",
 | 
			
		||||
            "deviceId": "0000000000000000000000000000000000000000",
 | 
			
		||||
            "disco_ver": "1.0",
 | 
			
		||||
            "err_code": 0,
 | 
			
		||||
            "heapsize": 306332,
 | 
			
		||||
            "hwId": "00000000000000000000000000000000",
 | 
			
		||||
            "hw_ver": "1.0",
 | 
			
		||||
            "is_color": 1,
 | 
			
		||||
            "is_dimmable": 1,
 | 
			
		||||
            "is_factory": false,
 | 
			
		||||
            "is_variable_color_temp": 1,
 | 
			
		||||
            "light_state": {
 | 
			
		||||
                "brightness": 30,
 | 
			
		||||
                "color_temp": 0,
 | 
			
		||||
                "hue": 15,
 | 
			
		||||
                "mode": "normal",
 | 
			
		||||
                "on_off": 1,
 | 
			
		||||
                "saturation": 100
 | 
			
		||||
            },
 | 
			
		||||
            "mic_mac": "1C3BF373CA4E",
 | 
			
		||||
            "mic_type": "IOT.SMARTBULB",
 | 
			
		||||
            "model": "KL130(US)",
 | 
			
		||||
            "oemId": "00000000000000000000000000000000",
 | 
			
		||||
            "preferred_state": [
 | 
			
		||||
                {
 | 
			
		||||
                    "brightness": 50,
 | 
			
		||||
                    "color_temp": 2700,
 | 
			
		||||
                    "hue": 0,
 | 
			
		||||
                    "index": 0,
 | 
			
		||||
                    "saturation": 0
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "brightness": 100,
 | 
			
		||||
                    "color_temp": 0,
 | 
			
		||||
                    "hue": 0,
 | 
			
		||||
                    "index": 1,
 | 
			
		||||
                    "saturation": 75
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "brightness": 100,
 | 
			
		||||
                    "color_temp": 0,
 | 
			
		||||
                    "hue": 120,
 | 
			
		||||
                    "index": 2,
 | 
			
		||||
                    "saturation": 75
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "brightness": 100,
 | 
			
		||||
                    "color_temp": 0,
 | 
			
		||||
                    "hue": 240,
 | 
			
		||||
                    "index": 3,
 | 
			
		||||
                    "saturation": 75
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "rssi": -62,
 | 
			
		||||
            "sw_ver": "1.8.11 Build 191113 Rel.105336"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -9,7 +9,7 @@ from kasa.tests.conftest import get_device_for_file
 | 
			
		||||
 | 
			
		||||
def test_bulb_examples(mocker):
 | 
			
		||||
    """Use KL130 (bulb with all features) to test the doctests."""
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KL130(US)_1.0.json"))
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KL130(US)_1.0_1.8.11.json"))
 | 
			
		||||
    mocker.patch("kasa.smartbulb.SmartBulb", return_value=p)
 | 
			
		||||
    mocker.patch("kasa.smartbulb.SmartBulb.update")
 | 
			
		||||
    res = xdoctest.doctest_module("kasa.smartbulb", "all")
 | 
			
		||||
@@ -18,7 +18,7 @@ def test_bulb_examples(mocker):
 | 
			
		||||
 | 
			
		||||
def test_smartdevice_examples(mocker):
 | 
			
		||||
    """Use HS110 for emeter examples."""
 | 
			
		||||
    p = asyncio.run(get_device_for_file("HS110(EU)_1.0_real.json"))
 | 
			
		||||
    p = asyncio.run(get_device_for_file("HS110(EU)_1.0_1.2.5.json"))
 | 
			
		||||
    mocker.patch("kasa.smartdevice.SmartDevice", return_value=p)
 | 
			
		||||
    mocker.patch("kasa.smartdevice.SmartDevice.update")
 | 
			
		||||
    res = xdoctest.doctest_module("kasa.smartdevice", "all")
 | 
			
		||||
@@ -27,7 +27,7 @@ def test_smartdevice_examples(mocker):
 | 
			
		||||
 | 
			
		||||
def test_plug_examples(mocker):
 | 
			
		||||
    """Test plug examples."""
 | 
			
		||||
    p = asyncio.run(get_device_for_file("HS110(EU)_1.0_real.json"))
 | 
			
		||||
    p = asyncio.run(get_device_for_file("HS110(EU)_1.0_1.2.5.json"))
 | 
			
		||||
    mocker.patch("kasa.smartplug.SmartPlug", return_value=p)
 | 
			
		||||
    mocker.patch("kasa.smartplug.SmartPlug.update")
 | 
			
		||||
    res = xdoctest.doctest_module("kasa.smartplug", "all")
 | 
			
		||||
@@ -36,7 +36,7 @@ def test_plug_examples(mocker):
 | 
			
		||||
 | 
			
		||||
def test_strip_examples(mocker):
 | 
			
		||||
    """Test strip examples."""
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KP303(UK)_1.0.json"))
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KP303(UK)_1.0_1.0.3.json"))
 | 
			
		||||
    mocker.patch("kasa.smartstrip.SmartStrip", return_value=p)
 | 
			
		||||
    mocker.patch("kasa.smartstrip.SmartStrip.update")
 | 
			
		||||
    res = xdoctest.doctest_module("kasa.smartstrip", "all")
 | 
			
		||||
@@ -45,7 +45,7 @@ def test_strip_examples(mocker):
 | 
			
		||||
 | 
			
		||||
def test_dimmer_examples(mocker):
 | 
			
		||||
    """Test dimmer examples."""
 | 
			
		||||
    p = asyncio.run(get_device_for_file("HS220(US)_1.0_real.json"))
 | 
			
		||||
    p = asyncio.run(get_device_for_file("HS220(US)_1.0_1.5.7.json"))
 | 
			
		||||
    mocker.patch("kasa.smartdimmer.SmartDimmer", return_value=p)
 | 
			
		||||
    mocker.patch("kasa.smartdimmer.SmartDimmer.update")
 | 
			
		||||
    res = xdoctest.doctest_module("kasa.smartdimmer", "all")
 | 
			
		||||
@@ -54,7 +54,7 @@ def test_dimmer_examples(mocker):
 | 
			
		||||
 | 
			
		||||
def test_lightstrip_examples(mocker):
 | 
			
		||||
    """Test lightstrip examples."""
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KL430(US)_1.0.json"))
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KL430(US)_1.0_1.0.10.json"))
 | 
			
		||||
    mocker.patch("kasa.smartlightstrip.SmartLightStrip", return_value=p)
 | 
			
		||||
    mocker.patch("kasa.smartlightstrip.SmartLightStrip.update")
 | 
			
		||||
    res = xdoctest.doctest_module("kasa.smartlightstrip", "all")
 | 
			
		||||
@@ -66,7 +66,7 @@ def test_lightstrip_examples(mocker):
 | 
			
		||||
)
 | 
			
		||||
def test_discovery_examples(mocker):
 | 
			
		||||
    """Test discovery examples."""
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KP303(UK)_1.0.json"))
 | 
			
		||||
    p = asyncio.run(get_device_for_file("KP303(UK)_1.0_1.0.3.json"))
 | 
			
		||||
 | 
			
		||||
    # This succeeds on python 3.8 but fails on 3.7
 | 
			
		||||
    # ValueError: a coroutine was expected, got [<DeviceType.Strip model KP303(UK) ...
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user