# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: testcases/mubu.login.yml
from httprunner import HttpRunner, TConfig, TStep


class TestCaseMubuLogin(HttpRunner):
    config = TConfig(
        **{
            "name": "testcase description",
            "variables": {
                "user_phone": "18613143458",
                "password": "moFrwx$!kz3DTRm@@*aV",
            },
            "verify": False,
            "base_url": "https://mubu.com",
            "export": ["user_persistence", "jwt_token"],
            "path": "testcases/mubu_login_test.py",
        }
    )

    teststeps = [
        TStep(
            **{
                "name": "/",
                "request": {
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "sec-fetch-dest": "document",
                        "sec-fetch-mode": "navigate",
                        "sec-fetch-site": "same-origin",
                        "sec-fetch-user": "?1",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                    },
                    "method": "GET",
                    "url": "/",
                },
                "validate": [
                    {"eq": ["status_code", "${get_expected_status_code(100, 100)}"]}
                ],
            }
        ),
        TStep(
            **{
                "name": "/login",
                "request": {
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "referer": "https://mubu.com/",
                        "sec-fetch-dest": "document",
                        "sec-fetch-mode": "navigate",
                        "sec-fetch-site": "same-origin",
                        "sec-fetch-user": "?1",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                    },
                    "method": "GET",
                    "url": "/login",
                },
                "validate": [{"eq": ["status_code", 200]}],
            }
        ),
        TStep(
            **{
                "name": "/login/password",
                "request": {
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "referer": "https://mubu.com/login",
                        "sec-fetch-dest": "document",
                        "sec-fetch-mode": "navigate",
                        "sec-fetch-site": "same-origin",
                        "sec-fetch-user": "?1",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                    },
                    "method": "GET",
                    "url": "/login/password",
                },
                "validate": [{"eq": ["status_code", 200]}],
            }
        ),
        TStep(
            **{
                "name": "/api/login/submit",
                "request": {
                    "data": {
                        "password": "$password",
                        "phone": "$user_phone",
                        "remember": "true",
                    },
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                        "referer": "https://mubu.com/login/password",
                        "sec-fetch-dest": "empty",
                        "sec-fetch-mode": "cors",
                        "sec-fetch-site": "same-origin",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                        "x-requested-with": "XMLHttpRequest",
                    },
                    "method": "POST",
                    "url": "/api/login/submit",
                },
                "extract": {
                    "user_persistence": "cookies.user_persistence",
                    "jwt_token": 'cookies."Jwt-Token"',
                },
                "teardown_hooks": ["${sleep(1)}"],
                "validate": [
                    {"eq": ["status_code", 200]},
                    {"eq": ["body.code", 0]},
                    {"eq": ["body.msg", None]},
                ],
            }
        ),
        TStep(
            **{
                "name": "/list",
                "request": {
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "referer": "https://mubu.com/login/password",
                        "sec-fetch-dest": "document",
                        "sec-fetch-mode": "navigate",
                        "sec-fetch-site": "same-origin",
                        "sec-fetch-user": "?1",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                    },
                    "method": "GET",
                    "url": "/list",
                },
                "validate": [{"eq": ["status_code", 200]}],
            }
        ),
        TStep(
            **{
                "name": "/api/list/tip_new_update",
                "request": {
                    "data": "",
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "referer": "https://mubu.com/list",
                        "sec-fetch-dest": "empty",
                        "sec-fetch-mode": "cors",
                        "sec-fetch-site": "same-origin",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                        "x-requested-with": "XMLHttpRequest",
                    },
                    "method": "POST",
                    "url": "/api/list/tip_new_update",
                },
                "validate": [
                    {"eq": ["status_code", 200]},
                    {"eq": ["body.code", 0]},
                    {"eq": ["body.msg", None]},
                ],
            }
        ),
        TStep(
            **{
                "name": "/api/list/get",
                "request": {
                    "data": {
                        "folderId": "0",
                        "keywords": "",
                        "sort": "name",
                        "source": "",
                    },
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                        "referer": "https://mubu.com/list",
                        "sec-fetch-dest": "empty",
                        "sec-fetch-mode": "cors",
                        "sec-fetch-site": "same-origin",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                        "x-requested-with": "XMLHttpRequest",
                    },
                    "method": "POST",
                    "url": "/api/list/get",
                },
                "validate": [
                    {"eq": ["status_code", 200]},
                    {"eq": ["body.code", 0]},
                    {"eq": ["body.msg", None]},
                ],
            }
        ),
        TStep(
            **{
                "name": "/api/message/get_message_unread",
                "request": {
                    "data": "",
                    "headers": {
                        "X-Request-ID": "${gen_request_id()}",
                        "referer": "https://mubu.com/list",
                        "sec-fetch-dest": "empty",
                        "sec-fetch-mode": "cors",
                        "sec-fetch-site": "same-origin",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 HttpRunner/${get_httprunner_version()}",
                        "x-requested-with": "XMLHttpRequest",
                    },
                    "method": "POST",
                    "url": "/api/message/get_message_unread",
                },
                "validate": [
                    {"eq": ["status_code", 200]},
                    {"eq": ["body.code", 0]},
                    {"eq": ["body.msg", None]},
                ],
            }
        ),
    ]


if __name__ == "__main__":
    TestCaseMubuLogin().test_start()
