Ejemplo n.º 1
0
class TestUpdateSettingAllowNotifySuccessfully(HttpRunner):

    config = (
        Config("P-修改配置 allowNotify 后,响应中包含此字段的接口返回内容正确")
        .variables(**{
            "account_id": None,
            "token": None,
            "client": None,
            "cid": None,
            "sku": None,
            "home_id": None,
            "allow_notify": None,  # type: str
        })
    )

    teststeps = [
        Step(
            RunApi("updateDevice")
            .request()
            .with_json({
                "cid": "$cid",
                "configModule": "${getattr($sku, config_model)}",
                "allowNotify": "$allow_notify",
            })
            .validate()
            .assert_equal("body.code", 0)
        ),
        Step(
            RunTestCase("获取设备配置,查看配置信息")
            .with_variables(expected={"allowNotify": "$allow_notify"})
            .call(AssertDeviceInfoCorrectInConfigurations)
        ),
    ]
Ejemplo n.º 2
0
class WaitUntilAppVersionUpdated(HttpRunner):
    """
    Call api 'checkUserAppVersion' until version was updated to latest.

    Config Variables:
        - client (Client): required
        - account_id (int): required
        - token (str): required
        - expected_app_version (str): optional, default to "${getattr($client, client_version)}"
    """

    config = (
        Config("调用 /testSupport/v1/account/checkUserAppVersion 接口查看 app 版本"
               ).variables(
                   **{
                       "expected_app_version":
                       "${getattr($client, client_version)}"  # type: str
                   }))

    teststeps = [
        Step(
            RunApi("checkUserAppVersion").retry_on_failure(
                polling_settings.times,
                polling_settings.interval).request().validate().assert_equal(
                    "body.result.appVersion", "$expected_app_version")),
    ]
class TestUpdateDeviceNameSuccessfully(HttpRunner):

    config = (
        Config("P-修改设备名称后,响应中包含设备名称字段的接口返回内容正确").variables(
            **{
                "account_id": None,
                "token": None,
                "client": None,
                "cid": None,
                "sku": None,
                "home_id": None,
                "new_device_name": None,  # type: str
            }))

    teststeps = [
        Step(
            RunApi("updateDevice").request().with_json({
                "cid":
                "$cid",
                "configModule":
                "${getattr($sku, config_model)}",
                "deviceName":
                "$new_device_name",
            }).validate().assert_equal("body.code", 0)),
        Step(
            RunTestCase("获取设备列表,查看设备状态").with_variables(
                expected={
                    "deviceName": "$new_device_name"
                }).call(AssertDeviceInfoCorrectInHome)),
        Step(
            RunTestCase("获取设备配置,查看配置信息").with_variables(
                expected={
                    "deviceName": "$new_device_name"
                }).call(AssertDeviceInfoCorrectInConfigurations)),
    ]
Ejemplo n.º 4
0
class UpdateUserAppVersion(HttpRunner):
    """
    Call api 'updateUserAppVersion'.

    Config Variables:
        - client (Client): required
        - account_id (int): required
        - token (str): required
        - new_app_version (str): optional, default to "${getattr($client, client_version)}"
    """

    config = (
        Config("调用 /testSupport/v1/account/updateUserAppVersion 接口更新 app 版本"
               ).variables(**{
                   "new_app_version":
                   "${getattr($client, client_version)}"  # type: str
               }))

    teststeps = [
        Step(
            RunApi("updateUserAppVersion").request().with_json({
                "newAppVersion":
                "$new_app_version"
            }).validate().assert_equal("body.code", 0)),
    ]
Ejemplo n.º 5
0
class ClearLinkageLog(HttpRunner):
    """
    Call api 'clearLinkageLog' to clear linkage history log
    """

    config = (Config("清空历史联动执行日志"))

    teststeps = [
        Step(
            RunApi("clearLinkageLog").request().validate().assert_equal(
                "body.code", 0))
    ]
Ejemplo n.º 6
0
class TestUpdateDeviceImageSuccessfully(HttpRunner):

    config = (Config("P-修改设备图片地址后,响应中包含设备图片地址字段的接口返回内容正确").variables(
        **{
            "account_id":
            None,
            "token":
            None,
            "client":
            None,
            "cid":
            None,
            "sku":
            None,
            "home_id":
            None,
            "new_device_img":
            "https://smartapi.vesync.com/v1/app/imgs/iconLightSwitch/iconLightSwitch1.jpg"
        }))

    teststeps = [
        Step(
            RunApi("updateDevice").request().with_json({
                "cid":
                "$cid",
                "deviceImg":
                "$new_device_img",
                "configModule":
                "${getattr($sku, config_model)}"
            }).validate().assert_equal("body.code", 0)),
        Step(
            RunTestCase("获取设备列表,查看设备状态").with_variables(
                expected={
                    "deviceImg": "$new_device_img"
                }).call(AssertDeviceInfoCorrectInHome)),
        Step(
            RunTestCase("获取设备配置,查看配置信息").with_variables(
                expected={
                    "deviceImg": "$new_device_img"
                }).call(AssertDeviceInfoCorrectInConfigurations)),
    ]
class TestFilterReportUseGetUnReadMessagesByUserV2Check(HttpRunner):
    timestamp = int(datetime.now().timestamp() * 1000)
    config = (Config("P-首次上报滤网等于 5% 后,用户可以收到推送消息且消息内容正确").variables(
        **{
            "client":
            "${get_client_from_orm_by_id(1)}",
            "email":
            "${generate_email()}",
            "password":
            "******",
            "start_timestamp":
            timestamp,
            "change_reason":
            "Device",
            "unchanged_status": {
                "mode": "sleep",
                "fanSpeedLevel": 1,
                "displayPower": "on",
                "displayForever": "off",
                "displayConfig": "on",
                "switch1": "on",
                "childLock": "off",
                "airQualityLevel": 1
            },
            "firmwares":
            "${init_device_firmwares($sku)}",
            "main_firmware_version":
            "${get_device_firmware_version($firmwares, mainFw)}",
        }))

    teststeps = [
        Step(
            RunTestCase("获取设备配置页信息,设备消息允许推送").with_variables(
                expected={
                    "allowNotify": "on"
                }).call(AssertDeviceInfoCorrectInConfigurations)),
        Step(
            RunTestCase("设备上报滤网状态6%").with_variables(**{
                "changed_status": {
                    "filterLife": 6
                }
            }).call(ReportChangeToVesync)),
        Step(
            RunTestCase("调用getUnReadMessagesByUserV2接口获取inbox消息,消息列表为空").call(
                AssertNoUnreadInboxMessagesV2)),
        Step(
            RunTestCase("设备首次上报滤网状态5%").with_variables(**{
                "changed_status": {
                    "filterLife": 5
                }
            }).call(ReportChangeToVesync)),
        Step(
            RunTestCase("获取用户inbox消息V2-滤网小于等于5%时收到滤网通知").with_variables(
                jmespath=
                "body.result.deviceNotificationArr[?deviceId=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_v2_device_message_assertion(
                        "PushFilterResetNotify", "$device_name", "$device_img",
                        "$cid")
                ]).call(WaitUntilUnreadInboxMessagesV2Correct)),
        Step(
            RunTestCase("设备再次上报滤网状态低于5%").with_variables(**{
                "changed_status": {
                    "filterLife": 4
                }
            }).call(ReportChangeToVesync)),
        Step(
            RunTestCase("获取用户inbox消息V2-重复上报滤网小于等于5%时收不到滤网通知").call(
                AssertNoUnreadInboxMessagesV2)),
        Step(RunTestCase("设备上报滤网重置信息").call(ResetFilterNty)),
        Step(
            RunTestCase("获取用户inbox消息V2-inbox中包含滤网重置成功消息").with_variables(
                jmespath=
                "body.result.deviceNotificationArr[?deviceId=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_v2_device_message_assertion(
                        "PushFilterResetSuccess", "$device_name",
                        "$device_img", "$cid")
                ]).call(WaitUntilUnreadInboxMessagesV2Correct)),
        Step(
            RunApi("updateDevicePushSettingsV2",
                   "修改设备通知状态为不允许通知,不会影响inbox消息").request().with_json({
                       "opType":
                       "selfDevice",
                       "homeId":
                       "$home_id",
                       "deviceId":
                       "$cid",
                       "notifEnabled":
                       True,
                       "type":
                       "wifi"
                   }).validate().assert_equal("body.code", 0)),
        Step(
            RunApi("getDevicePushSettingsV2",
                   "获取设备开关设置,设备消息不允许推送,不会影响inbox消息").request().validate().
            assert_equal(
                "body.result.selfHomeDevices[?deviceId=='$cid'].deviceNotifEnabled",
                [True])),
        Step(RunTestCase("设备上报滤网重置信息").call(ResetFilterNty)),
        Step(
            RunTestCase("获取用户inbox消息V2-inbox中包含滤网重置成功消息").with_variables(
                jmespath=
                "body.result.deviceNotificationArr[?deviceId=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_v2_device_message_assertion(
                        "PushFilterResetSuccess", "$device_name",
                        "$device_img", "$cid")
                ]).call(WaitUntilUnreadInboxMessagesV2Correct)),
        Step(
            RunTestCase("设备重置滤网后再次上报滤网状态低于5%").with_variables(**{
                "changed_status": {
                    "filterLife": 4
                }
            }).call(ReportChangeToVesync)),
        Step(
            RunTestCase("获取用户inbox消息V2-滤网小于等于5%时收到滤网通知").with_variables(
                jmespath=
                "body.result.deviceNotificationArr[?deviceId=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_v2_device_message_assertion(
                        "PushFilterResetNotify", "$device_name", "$device_img",
                        "$cid")
                ]).call(WaitUntilUnreadInboxMessagesV2Correct)),
    ]
class TestFilterReportUseGetMessagesByGroupCheck(HttpRunner):
    timestamp = int(datetime.now().timestamp() * 1000)
    config = (
        Config("P-首次上报滤网等于 5% 后,用户可以收到推送消息且消息内容正确")
        .variables(
            **{
                "client": "${get_client_from_orm_by_id(1)}",
                "email": "${generate_email()}",
                "password": "******",
                "start_timestamp": timestamp,
                "unchanged_status": {
                    "mode": "sleep",
                    "fanSpeedLevel": 1,
                    "displayPower": "on",
                    "displayForever": "off",
                    "displayConfig": "on",
                    "switch1": "on",
                    "childLock": "off",
                    "airQualityLevel": 1
                },
                "firmwares": "${init_device_firmwares($sku)}",
                "main_firmware_version": "${get_device_firmware_version($firmwares, mainFw)}",
            }
        )
    )

    teststeps = [
        Step(
            RunTestCase("获取设备配置页信息,设备消息允许推送")
            .with_variables(expected={"allowNotify": "on"})
            .call(AssertDeviceInfoCorrectInConfigurations)
        ),
        Step(
            RunTestCase("设备上报滤网状态6%")
            .with_variables(**{
                    "changed_status": {"filterLife": 6}
            })
            .call(ReportChangeToVesync)
        ),
        Step(
            RunTestCase("获取用户inbox消息V1-滤网高于5%不收到滤网通知")
            .call(AssertNoUnreadInboxMessages)
        ),
        Step(
            RunTestCase("设备首次上报滤网状态5%")
            .with_variables(**{
                    "changed_status": {"filterLife": 5}
            })
            .call(ReportChangeToVesync)
        ),
        Step(
            RunTestCase("设备首次上报滤网状态小于等于5时,用户收到inbox消息")
            .with_variables(
                jmespath="body.result.deviceNotificationArr[?cid=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_device_message_assertion("PushFilterResetNotify", "$device_name", "$device_img", "$cid")
                ]
            )
            .call(WaitUntilUnreadInboxMessagesCorrect)
        ),
        Step(
            RunTestCase("设备再次上报滤网状态低于5%")
            .with_variables(**{
                "changed_status": {"filterLife": 4}
            })
            .call(ReportChangeToVesync)
        ),
        Step(
            RunTestCase("获取用户inbox消息V1-设备多次上报滤网低于5%不收到滤网通知")
            .call(AssertNoUnreadInboxMessages)
        ),
        Step(
            RunTestCase("设备上报滤网重置信息")
            .call(ResetFilterNty)
        ),
        Step(
            RunTestCase("设备上报滤网重置,用户收到inbox消息")
            .with_variables(
                jmespath="body.result.deviceNotificationArr[?cid=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_device_message_assertion("PushFilterResetSuccess", "$device_name", "$device_img", "$cid")
                ]
            )
            .call(WaitUntilUnreadInboxMessagesCorrect)
        ),
        Step(
            RunApi("updateDevice", "修改设备通知状态为不可通知,不会影响inbox消息")
            .request()
            .with_json({
                "cid": "$cid",
                "allowNotify": "off",
                "configModule": "${getattr($sku, config_model)}"
            })
            .validate()
            .assert_equal("body.code", 0)
        ),
        Step(
            RunTestCase("获取设备配置页信息,设备消息不允许推送,,不会影响inbox消息")
            .with_variables(expected={"allowNotify": "off"})
            .call(AssertDeviceInfoCorrectInConfigurations)
        ),
        Step(
            RunTestCase("设备上报滤网重置信息")
            .call(ResetFilterNty)
        ),
        Step(
            RunTestCase("设备上报滤网重置,用户收到inbox消息")
            .with_variables(
                jmespath="body.result.deviceNotificationArr[?cid=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_device_message_assertion("PushFilterResetSuccess", "$device_name", "$device_img", "$cid")
                ]
            )
            .call(WaitUntilUnreadInboxMessagesCorrect)
        ),
        Step(
            RunTestCase("设备重置滤网后上报滤网状态低于5%")
            .with_variables(**{
                "changed_status": {"filterLife": 4}
            })
            .call(ReportChangeToVesync)
        ),
        Step(
            RunTestCase("重置滤网后,设备上报滤网状态首次小于等于5,用户收到inbox消息")
            .with_variables(
                jmespath="body.result.deviceNotificationArr[?cid=='$cid'].messageArr[0]",
                expected_message=[
                    get_inbox_device_message_assertion("PushFilterResetNotify", "$device_name", "$device_img", "$cid")
                ]
            )
            .call(WaitUntilUnreadInboxMessagesCorrect)
        ),
    ]