def test_openbdp_group_update_fields(self):
        openbdp = OpenbdpSdk.instance()
        # 配置分组自定义字段
        data = [{
            "name": "密级",
            "type": "text",
            "config": {
                "hint": "Please input..."
            }
        }, {
            "name": "手机品牌",
            "type": "select",
            "config": {
                "options": ["apple", "vivo", "huawei"]
            }
        }]

        openbdp.call_method_and_succ("openbdp_group_update_fields", data)
        res = openbdp.call_method_and_succ("openbdp_group_list_fields",
                                           ret_expr='["result"]')
        # print sorted(res)
        assert sorted(res)[0]['name'] == "密级"
        assert sorted(res)[0]['type'] == "text"
        assert sorted(res)[1]['name'] == "手机品牌"
        assert sorted(res)[1]['type'] == "select"
示例#2
0
 def test_nouser(self):
     openbdp = OpenbdpSdk.instance()
     with pytest.raises(AssertionError):
         openbdp.call_method_and_succ("openbdp_userInfo",
                                      "9yyy",
                                      ret_expr='')
     assert json.loads(openbdp.raw_data)["status"] == "1009"
示例#3
0
 def test_reset_password(self):
     openbdp = OpenbdpSdk.instance()
     username = "******" + str(time.time())
     name = "name" + str(time.time())
     mobile = self.createPhone()
     password = "******",
     role = 3
     uid = openbdp.call_method_and_succ("openbdp_userCreate",
                                        username,
                                        name,
                                        mobile,
                                        password,
                                        role,
                                        ret_expr='["result"]')
     result = openbdp.call_method_and_succ("openbdp_userInfo",
                                           uid,
                                           ret_expr='["result"]')
     assert result["username"] == username
     assert result["name"] == name
     assert result["mobile"] == mobile
     assert result["role"] == role
     # 冻结
     resp = openbdp.call_method_and_succ("openbdp_reset_password",
                                         uid,
                                         ret_expr='')
     assert resp["status"] == "0"
     # delete
     resp = openbdp.call_method_and_succ("openbdp_userdelete",
                                         uid,
                                         ret_expr='')
     assert resp["status"] == "0"
 def test_openbdp_noparen_id_name(self):
     openbdp = OpenbdpSdk.instance()
     name = ""
     name1 = "1"
     pid = ""
     pid1 = "1"
     with pytest.raises(AssertionError):
         openbdp.call_method_and_succ("openbdp_groupcreate",
                                      name,
                                      pid1,
                                      ret_expr='')
     assert json.loads(openbdp.raw_data)["status"] == "11"
 def quuutest_openbdp_chartdata(self):
     openbdp = OpenbdpSdk.instance()
     ct_id = "ct_f1388840b892b2929a23370ebcd77121"
     count = 0
     while (count < 10001):
         if count == 1000:
             with pytest.raises(AssertionError):
                 result = openbdp.call_method_and_succ("openbdp_chart_data",
                                                       ct_id,
                                                       ret_expr='')
             assert json.loads(openbdp.raw_data)["status"] == "140001"
         else:
             openbdp.call_method_and_succ("openbdp_chart_data",
                                          ct_id,
                                          ret_expr='')
         count = count + 1
示例#6
0
 def test_errchar(self):
     openbdp = OpenbdpSdk.instance()
     username = "******"
     name = "name" + str(time.time())
     mobile = "1"
     password = "******",
     role = 3
     with pytest.raises(AssertionError):
         result = openbdp.call_method_and_succ("openbdp_userCreate",
                                               username,
                                               name,
                                               mobile,
                                               password,
                                               role,
                                               ret_expr='')
     assert json.loads(openbdp.raw_data)["status"] == "1016"
示例#7
0
 def test_nomanage_groups(self):
     openbdp = OpenbdpSdk.instance()
     username = "******" + str(time.time())
     name = "1"
     mobile = "1"
     password = "",
     # 2:管理员,3:普通账号 | int | 必填 |
     role = 2
     with pytest.raises(AssertionError):
         result = openbdp.call_method_and_succ("openbdp_userCreate",
                                               username,
                                               name,
                                               mobile,
                                               password,
                                               role,
                                               ret_expr='')
     assert json.loads(openbdp.raw_data)["status"] == "11"
 def test_openbdp_groupcreate(self):
     openbdp = OpenbdpSdk.instance()
     name = "groupname" + str(time.time())
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     gid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                        name,
                                        pid,
                                        ret_expr='["result"]')
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == name
     assert result["group_id"] == gid
     assert result["parent_id"] == pid
     # 清除测试数据
     resp = openbdp.call_method_and_succ("openbdp_groupdel",
                                         gid,
                                         ret_expr='')
     assert resp["status"] == "0"
 def test_openbdp_group_10create(self):
     openbdp = OpenbdpSdk.instance()
     name = "openbdpwuxianjino"
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     gid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                        name,
                                        pid,
                                        ret_expr='["result"]')
     T = gid
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == name
     assert result["group_id"] == gid
     count = 1
     while (count < 11):
         name = "obwuxianjin" + str(count)
         if count == 10:
             with pytest.raises(AssertionError):
                 openbdp.call_method_and_succ("openbdp_groupcreate",
                                              name,
                                              gid,
                                              ret_expr='["result"]')
             assert json.loads(openbdp.raw_data)["status"] == "12012"
         else:
             ggid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                                 name,
                                                 gid,
                                                 ret_expr='["result"]')
             result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                                   ggid,
                                                   ret_expr='["result"]')
             assert result["name"] == name
             assert result["group_id"] == ggid
             gid = ggid
         count = count + 1
     # 清除测试数据
     resp = openbdp.call_method_and_succ("openbdp_groupdel", T, ret_expr='')
     assert resp["status"] == "0"
示例#10
0
    def test_openbdp_tb_down(self):
        openbdp = OpenbdpSdk.instance()
        t = Table.from_lines([
            "date,name,value,key",
            "2012-12-29 23:59:59, A1, 1, key1",
            "2012-12-30 00:00:00, A2, 2, key2",
            "2012-12-31 00:00:00, A1, 3, key3",
            "2013-01-01 00:00:00, A2, 4, key4",
            "2013-01-02 00:00:00, A1, 5, key5",
        ])

        task_id = openbdp.call_method_and_succ("openbdp_tb_export",
                                               t.tb_id(),
                                               ret_expr='["result"]')
        time.sleep(3)
        export_status = openbdp.call_method_and_succ(
            "openbdp_tb_status",
            task_id,
            ret_expr='["result"]["export_status"]')
        # 可下载状态
        assert export_status == 0
        r = openbdp.openbdp_tb_down(task_id)
        fname = apiconf.DOWNLOAD_DIR + "openbdptbdown.csv.gz"
        with open(fname, "wb") as file:
            file.write(r.content)

        # 解压
        self.un_gz(fname)
        fcsv = fname.replace(".gz", "")
        with open(fcsv, 'rb') as f:
            reader = csv.reader(f)
            list = []
            for row in reader:
                list.append(row)

        assert len(list) == 6
        assert list[0] == ['date', 'name', 'value', 'key']
        assert list[5] == ['2013-01-02 00:00:00', 'A1', '5', 'key5']
        os.remove(fname)
        os.remove(fcsv)
示例#11
0
 def test_openbdp_groupmodify(self):
     openbdp = OpenbdpSdk.instance()
     name = "groupname" + str(time.time())
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     count = 0
     while (count < 2):
         gid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                            name,
                                            pid,
                                            ret_expr='["result"]')
         if count == 0:
             T = gid
         result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                               gid,
                                               ret_expr='["result"]')
         assert result["name"] == name
         assert result["group_id"] == gid
         assert result["parent_id"] == pid
         count = count + 1
         name = "1groupname" + str(time.time())
     # # 修改分组1
     name1 = "openbdpmodifygroupname" + str(time.time())
     resp = openbdp.call_method_and_succ("openbdp_groupmodify",
                                         gid,
                                         name1,
                                         T,
                                         ret_expr='')
     assert resp["status"] == "0"
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == name1
     assert result["group_id"] == gid
     assert result["parent_id"] == T
     # #清除测试数据
     resp = openbdp.call_method_and_succ("openbdp_groupdel", T, ret_expr='')
     assert resp["status"] == "0"
示例#12
0
    def test_already_have_Phone_email(self):
        openbdp = OpenbdpSdk.instance()
        username = "******" + str(time.time())
        name = "name" + str(time.time())
        mobile = self.createPhone()
        password = "******",
        role = 3
        uid = openbdp.call_method_and_succ("openbdp_userCreate",
                                           username,
                                           name,
                                           mobile,
                                           password,
                                           role,
                                           ret_expr='["result"]')
        result = openbdp.call_method_and_succ("openbdp_userInfo",
                                              uid,
                                              ret_expr='["result"]')
        assert result["username"] == username
        assert result["name"] == name
        assert result["mobile"] == mobile
        assert result["role"] == role

        username = "******" + str(time.time())
        with pytest.raises(AssertionError):
            result = openbdp.call_method_and_succ("openbdp_userCreate",
                                                  username,
                                                  name,
                                                  mobile,
                                                  password,
                                                  role,
                                                  ret_expr='')
        assert json.loads(openbdp.raw_data)["status"] == "1023"
        # delete
        resp = openbdp.call_method_and_succ("openbdp_userdelete",
                                            uid,
                                            ret_expr='')
        assert resp["status"] == "0"
示例#13
0
 def test_openbdp_groupname_repeat(self):
     openbdp = OpenbdpSdk.instance()
     name = "groupname" + str(time.time())
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     gid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                        name,
                                        pid,
                                        ret_expr='["result"]')
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == name
     with pytest.raises(AssertionError):
         openbdp.call_method_and_succ("openbdp_groupcreate",
                                      name,
                                      pid,
                                      ret_expr='')
     assert json.loads(openbdp.raw_data)["status"] == "12002"
     # 清除测试数据
     resp = openbdp.call_method_and_succ("openbdp_groupdel",
                                         gid,
                                         ret_expr='')
     assert resp["status"] == "0"
示例#14
0
 def test_ufunmodify(self):
     openbdp = OpenbdpSdk.instance()
     username = "******" + str(time.time())
     name = "xianjinname" + str(random.randint(0, 20))
     mobile = self.createPhone()
     password = "******",
     email = mobile + "@qq.com"
     # 2:管理员,3:普通账号 | int | 必填 |
     role = 2
     position = "position"
     # 分组信息
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     manage_groups = [pid]
     sex = 0
     openbdp.openbdp_userCreate(username,
                                name,
                                mobile,
                                password,
                                role,
                                email=email,
                                position=position,
                                sex=sex,
                                manage_groups=manage_groups,
                                account_manage=1,
                                tml_manage=1,
                                function_manage=1,
                                tb_manage=1,
                                data_source_manage=1)
     uid = json.loads(openbdp.raw_data)["result"]
     result = openbdp.call_method_and_succ("openbdp_userInfo",
                                           uid,
                                           ret_expr='["result"]')
     assert result["username"] == username
     assert result["name"] == name
     assert result["mobile"] == mobile
     assert result["role"] == role
     assert result["position"] == position
     assert result["account_manage"] == 1
     assert result["sex"] == "男"
     assert result["function_manage"] == 1
     assert result["tb_manage"] == 1
     assert result["data_source_manage"] == 1
     assert result["tml_manage"] == 1
     # openbdp_ufunmodify
     openbdp.openbdp_ufunmodify(uid,
                                account_manage=0,
                                tml_manage=0,
                                function_manage=0,
                                tb_manage=0,
                                data_source_manage=0)
     result = openbdp.call_method_and_succ("openbdp_userInfo",
                                           uid,
                                           ret_expr='["result"]')
     assert result["username"] == username
     assert result["account_manage"] == 0
     assert result["function_manage"] == 0
     assert result["tb_manage"] == 0
     assert result["data_source_manage"] == 0
     assert result["tml_manage"] == 0
     # delete
     resp = openbdp.call_method_and_succ("openbdp_userdelete",
                                         uid,
                                         ret_expr='')
     assert resp["status"] == "0"
示例#15
0
 def groupdel(cls, gid):
     openbdp = OpenbdpSdk.instance()
     openbdp.call_method_and_succ("openbdp_groupdel", gid)
     with pytest.raises(AssertionError):
         cls.groupinfo(gid)
     assert json.loads(BdpSDK.instance().raw_data)["status"] == "4"
示例#16
0
 def test_user2admin(self):
     openbdp = OpenbdpSdk.instance()
     username = "******" + str(time.time())
     name = "xianjinname" + str(random.randint(0, 20))
     mobile = self.createPhone()
     password = "******",
     email = mobile + "@qq.com"
     # 2:管理员,3:普通账号 | int | 必填 |
     role = 3
     position = "position"
     sex = 0
     openbdp.openbdp_userCreate(username,
                                name,
                                mobile,
                                password,
                                role,
                                email=email,
                                position=position,
                                sex=sex)
     uid = json.loads(openbdp.raw_data)["result"]
     result = openbdp.call_method_and_succ("openbdp_userInfo",
                                           uid,
                                           ret_expr='["result"]')
     assert result["username"] == username
     assert result["name"] == name
     assert result["mobile"] == mobile
     assert result["role"] == role
     assert result["position"] == position
     assert result["sex"] == "男"
     assert result["account_manage"] == 0
     # modify 字段
     name = "modifyname" + str(random.randint(0, 20))
     mobile = self.createPhone()
     email = mobile + "@163.com"
     # 2:管理员,3:普通账号 | int | 必填 |
     role = 2
     sex = 1
     # 分组信息
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     manage_groups = [pid]
     account_manage = 1
     position = "modifposition"
     # userdmodify
     openbdp.openbdp_userdmodify(uid,
                                 name=name,
                                 mobile=mobile,
                                 email=email,
                                 position=position,
                                 role=role,
                                 sex=sex,
                                 manage_groups=manage_groups,
                                 account_manage=account_manage)
     result = openbdp.call_method_and_succ("openbdp_userInfo",
                                           uid,
                                           ret_expr='["result"]')
     assert result["name"] == name
     assert result["mobile"] == mobile
     assert result["role"] == role
     assert result["position"] == position
     assert result["sex"] == "女"
     # assert result["account_manage"] == 1
     assert result["manage_groups"] != None
     # delete
     resp = openbdp.call_method_and_succ("openbdp_userdelete",
                                         uid,
                                         ret_expr='')
     assert resp["status"] == "0"
示例#17
0
 def test_openbdp_manageCreate(self):
     openbdp = OpenbdpSdk.instance()
     username = "******" + str(time.time())
     name = "openbdpxianjin" + str(random.randint(0, 20))
     mobile = self.createPhone()
     password = "******",
     email = mobile + "@qq.com"
     # 2:管理员,3:普通账号 | int | 必填 |
     role = 2
     position = "position"
     # 分组信息
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     gid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                        name,
                                        pid,
                                        ret_expr='["result"]')
     belong_groups = [gid]
     manage_groups = [pid]
     tml_manage = 1
     function_manage = 1
     tb_manage = 1
     data_source_manage = 1
     account_manage = 1
     openbdp.openbdp_userCreate(username,
                                name,
                                mobile,
                                password,
                                role,
                                email=email,
                                position=position,
                                belong_groups=belong_groups,
                                manage_groups=manage_groups,
                                account_manage=account_manage,
                                tml_manage=tml_manage,
                                function_manage=function_manage,
                                tb_manage=tb_manage,
                                data_source_manage=data_source_manage)
     uid = json.loads(openbdp.raw_data)["result"]
     result = openbdp.call_method_and_succ("openbdp_userInfo",
                                           uid,
                                           ret_expr='["result"]')
     assert result["username"] == username
     assert result["name"] == name
     assert result["mobile"] == mobile
     assert result["role"] == role
     assert result["position"] == position
     assert result["account_manage"] == account_manage
     assert result["function_manage"] == 1
     assert result["tb_manage"] == 1
     assert result["data_source_manage"] == 1
     assert result["tml_manage"] == 1
     assert result["manage_groups"][0]["group_id"] == pid
     # assert result["has_tb_permission"] == 1
     # assert result["has_data_permission"] == 1
     assert result["has_dsh_permission"] == 1
     # delete
     resp = openbdp.call_method_and_succ("openbdp_userdelete",
                                         uid,
                                         ret_expr='')
     assert resp["status"] == "0"
     # 清除测试数据
     resp = openbdp.call_method_and_succ("openbdp_groupdel",
                                         gid,
                                         ret_expr='')
     assert resp["status"] == "0"
示例#18
0
    def test_openbdp_userCreate(self):
        openbdp = OpenbdpSdk.instance()
        username = "******" + str(time.time())
        gname = "openbdp" + str(time.time())
        name = "name" + str(time.time())
        mobile = self.createPhone()
        password = "******",
        email = mobile + "@qq.com"
        # 2:管理员,3:普通账号 | int | 必填 |
        role = 3
        position = "position"
        # 分组数据准备
        pid = openbdp.call_method_and_succ(
            "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
        count = 0
        while (count < 2):
            gid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                               gname,
                                               pid,
                                               ret_expr='["result"]')
            if count == 0:
                T = gid
            result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                                  gid,
                                                  ret_expr='["result"]')
            assert result["name"] == gname
            assert result["group_id"] == gid
            assert result["parent_id"] == pid
            count = count + 1
            gname = "openbdp1groupname" + str(time.time())

        belong_groups = [gid, T]
        openbdp.openbdp_userCreate(username,
                                   name,
                                   mobile,
                                   password,
                                   role,
                                   email=email,
                                   position=position,
                                   belong_groups=belong_groups,
                                   has_dsh_permission=1,
                                   has_tb_permission=1,
                                   has_data_permission=1,
                                   has_dsh_manage_permission=1,
                                   has_date_filter_permission=1)
        uid = json.loads(openbdp.raw_data)["result"]
        result = openbdp.call_method_and_succ("openbdp_userInfo",
                                              uid,
                                              ret_expr='["result"]')
        assert result["username"] == username
        assert result["name"] == name
        assert result["mobile"] == mobile
        assert result["role"] == role
        assert result["position"] == position
        assert result["email"] == email
        assert len(result["groups"]) == 3
        assert result["function_manage"] == 0
        assert result["tb_manage"] == 0
        assert result["data_source_manage"] == 0
        assert result["tml_manage"] == 0
        assert result["account_manage"] == 0
        assert result["has_dsh_permission"] == 1
        assert result["has_tb_permission"] == 1
        assert result["has_data_permission"] == 1
        assert result["has_dsh_manage_permission"] == 1
        assert result["has_date_filter_permission"] == 1
        # delete
        resp = openbdp.call_method_and_succ("openbdp_userdelete",
                                            uid,
                                            ret_expr='')
        assert resp["status"] == "0"
        # #清除测试数据
        resp = openbdp.call_method_and_succ("openbdp_groupdel", T, ret_expr='')
        assert resp["status"] == "0"
示例#19
0
 def test_openbdp_group_user_manager(self):
     openbdp = OpenbdpSdk.instance()
     gname = "groupname" + str(time.time())
     pid = openbdp.call_method_and_succ(
         "openbdp_grouplist", ret_expr='["result"][0]["group_id"]')
     gid = openbdp.call_method_and_succ("openbdp_groupcreate",
                                        gname,
                                        pid,
                                        ret_expr='["result"]')
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == gname
     assert result["group_id"] == gid
     assert result["parent_id"] == pid
     # add user
     username = "******" + str(time.time())
     name = "name" + str(time.time())
     mobile = self.createPhone()
     password = "******",
     role = 3
     uid = openbdp.call_method_and_succ("openbdp_userCreate",
                                        username,
                                        name,
                                        mobile,
                                        password,
                                        role,
                                        ret_expr='["result"]')
     result = openbdp.call_method_and_succ("openbdp_userInfo",
                                           uid,
                                           ret_expr='["result"]')
     assert result["username"] == username
     assert result["name"] == name
     assert result["mobile"] == mobile
     assert result["role"] == role
     user_ids = [uid]
     # 添加组员
     openbdp.call_method_and_succ("openbdp_group_adduser",
                                  gid,
                                  user_ids,
                                  ret_expr='["result"]')
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == gname
     assert result["group_users"][0]["user_id"] == uid
     # 删除组员
     resp = openbdp.call_method_and_succ("openbdp_group_deluser",
                                         gid,
                                         user_ids,
                                         ret_expr='')
     assert resp["status"] == "0"
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == gname
     assert len(result["group_users"]) == 0
     # 添加管理员
     openbdp.call_method_and_succ("openbdp_group_addmanager",
                                  gid,
                                  user_ids,
                                  ret_expr='["result"]')
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == gname
     assert result["group_managers"][0]["user_id"] == uid
     # 删除管理员
     resp = openbdp.call_method_and_succ("openbdp_group_delmanager",
                                         gid,
                                         user_ids,
                                         ret_expr='')
     assert resp["status"] == "0"
     result = openbdp.call_method_and_succ("openbdp_groupinfo",
                                           gid,
                                           ret_expr='["result"]')
     assert result["name"] == gname
     assert len(result["group_managers"]) == 0
     # 清除测试数据
     resp = openbdp.call_method_and_succ("openbdp_groupdel",
                                         gid,
                                         ret_expr='')
     assert resp["status"] == "0"
     resp = openbdp.call_method_and_succ("openbdp_userdelete",
                                         uid,
                                         ret_expr='')
     assert resp["status"] == "0"
示例#20
0
 def user_del(cls, sub_id):
     openbdp = OpenbdpSdk.instance()
     openbdp.call_method_and_succ("openbdp_userdelete", sub_id)
     with pytest.raises(AssertionError):
         cls.subinfo(sub_id)
     assert json.loads(BdpSDK.instance().raw_data)["status"] == "1009"