コード例 #1
0
    def test_create_new_member4(self):

        member_managment = MemberManagermentApi()
        json_obj=member_managment.get_json_obj_from_file_with_reqres('../testdata/member4.json',"testcase2","req")

        # 定义新用户名加时间戳的方法 这样每次保证用户名不一样
        new_userid = toolskit.append_time_stamp_string(json_obj.get("userid"))
        new_mobile = toolskit.get_random_mobile()

        # 获取随机生成的邮箱前缀
        email_prefix = toolskit.get_random_string()
        # 邮箱后缀json文件中email格式的固定后缀 一般企业微信邮箱后缀是固定的
        email_postfix =json_obj.get("email").split("@")[1]
        new_email= email_prefix + "@" + email_postfix

        # 字典值用户名对应更新
        toolskit.update_json_value_by_key(json_obj,"userid",new_userid)
        toolskit.update_json_value_by_key(json_obj, "mobile", new_mobile)
        toolskit.update_json_value_by_key(json_obj, "email", new_email)

        member_managment.create_member_by_json_obj(json_obj)

        # 当前返回的json串  与 预先定义好的member.json数据中res中的数据值 做比较
        live_create_res = member_managment.get_response()
        std_json_obj_res = member_managment.get_json_obj_from_file_with_reqres('../testdata/member4.json', "testcase2",
                                                                          "res")
        json_comparator = comparator.JsonComparator()

        # 断言两个json中的res中的值是否相等
        assert json_comparator.equal(live_create_res,std_json_obj_res)
コード例 #2
0
    def test_testcase2(self):

        # 如果类中只有一个方法,则可以用类名,获取类名
        class_name = self.__class__.__name__

        case_name = sys._getframe().f_code.co_name.split("_")[1]

        member_managment = MemberManagermentApi()
        json_obj=member_managment.get_json_obj_from_file_with_reqres('../testdata/'+ class_name +'.json',case_name,"req")

        new_userid = toolskit.append_time_stamp_string(json_obj.get("userid"))
        new_mobile = toolskit.get_random_mobile()
        email_prefix = toolskit.get_random_string()
        email_postfix =json_obj.get("email").split("@")[1]
        new_email= email_prefix + "@" + email_postfix

        toolskit.update_json_value_by_key(json_obj,"userid",new_userid)
        toolskit.update_json_value_by_key(json_obj, "mobile", new_mobile)
        toolskit.update_json_value_by_key(json_obj, "email", new_email)

        member_managment.create_member_by_json_obj(json_obj)

        live_create_res = member_managment.get_response()
        std_json_obj_res = member_managment.get_json_obj_from_file_with_reqres('../testdata/'+ class_name +'.json', case_name,
                                                                          "res")
        json_comparator = comparator.JsonComparator()

        # 断言两个json中的res中的值是否相等
        assert json_comparator.equal(live_create_res,std_json_obj_res)
コード例 #3
0
 def test_create_member3(self):
     member_obj = MemberManagermentApi()
     json_obj = member_obj.get_json_obj_from_file(
         '../testdata/member3.json', "testcase1")
     member_obj.create_member_by_json_obj(json_obj)
     create_res = member_obj.get_response()
     assert create_res.get('errmsg') == 'created'
コード例 #4
0
 def test_get_member_list(self):
     member_obj = MemberManagermentApi()
     res = member_obj.get_member_list(userid="zhangsan")
     print(res.json())
     assert res.json().get("errmsg") == "ok"
コード例 #5
0
 def test_create_member2(self, datafiles):
     for member_file in datafiles.listdir():
         member_obj = MemberManagermentApi()
         member_obj.create_member(member_file)
         create_res = member_obj.get_response()
         assert create_res.get('errmsg') == 'created'