test_add_Attribute.py 4.04 KB
from atdd.PcPost import PcPost
import random

# 新增员工属性

class AddAttribute(PcPost):

    interfaceUrl = "/contact/Apicp/Attribute/Save"

    # 0~10000的随机整数
    x = random.randint(0, 10000)

    def setUp(self):
        self.do_login(self.host, self.mobile, self.psw, self.domain)

    # 新增单行文本属性
    def test_add_text(self):
        data = {
            "attr_name": "单行文本"+str(self.x),
            "position": 0,
            "type": 1,  #类型为单行文本
            "order": 0,
            "is_system": 0,
            "is_open_cp": 1,
            "is_open_cp_edit": 0,
            "is_open": 1,
            "is_open_edit": 0,
            "is_required_cp": 0,
            "is_required_cp_edit": 0,
            "is_required": 0,
            "is_required_edit": 0,
            "is_show": 1,
            "is_show_edit": 0
        }
        result = self.PcPost(self.interfaceUrl,data)
        return result

    # 新增多行文本
    def test_add_MultilineText(self):
        data = {
            "attr_name": "多行文本" + str(self.x),
            "position": 0,
            "type": 2, #类型为多行文本
            "order": 0,
            "is_system": 0,
            "is_open_cp": 1,
            "is_open_cp_edit": 0,
            "is_open": 1,
            "is_open_edit": 0,
            "is_required_cp": 0,
            "is_required_cp_edit": 0,
            "is_required": 0,
            "is_required_edit": 0,
            "is_show": 1,
            "is_show_edit": 0
        }
        result = self.PcPost(self.interfaceUrl, data)
        return result

    # 新增日期
    def test_add_Date(self):
        data = {
            "attr_name": "日期" + str(self.x),
            "position": 0,
            "type": 4,  # 类型为日期
            "order": 0,
            "is_system": 0,
            "is_open_cp": 1,
            "is_open_cp_edit": 0,
            "is_open": 1,
            "is_open_edit": 0,
            "is_required_cp": 0,
            "is_required_cp_edit": 0,
            "is_required": 0,
            "is_required_edit": 0,
            "is_show": 1,
            "is_show_edit": 0
        }
        result = self.PcPost(self.interfaceUrl, data)
        return result

    # 新建单选
    def test_add_singleSelect(self):
        data = {
            "option[0][name]": "漂亮",
            "option[0][value]": 0,
            "option[1][name]": "可爱",
            "option[1][value]": 1,
            "option[2][name]": "任性",
            "option[2][value]": 2,
            "option[3][name]": "有钱",
            "option[3][value]": 3,
            "attr_name": "单选" + str(self.x),
            "position": 0,
            "type": 7,  # 类型为单选
            "order": 0,
            "is_system": 0,
            "is_open_cp": 1,
            "is_open_cp_edit": 0,
            "is_open": 1,
            "is_open_edit": 0,
            "is_required_cp": 0,
            "is_required_cp_edit": 0,
            "is_required": 0,
            "is_required_edit": 0,
            "is_show": 1,
            "is_show_edit": 0
        }
        result = self.PcPost(self.interfaceUrl, data)
        return result

    # 新建多选
    def test_add_multiSelect(self):
        data = {
            "option[0][name]": "漂亮",
            "option[0][value]": 0,
            "option[1][name]": "可爱",
            "option[1][value]": 1,
            "option[2][name]": "任性",
            "option[2][value]": 2,
            "option[3][name]": "有钱",
            "option[3][value]": 3,
            "attr_name": "多选" + str(self.x),
            "position": 0,
            "type": 8,  # 类型为多选
            "order": 0,
            "is_system": 0,
            "is_open_cp": 1,
            "is_open_cp_edit": 0,
            "is_open": 1,
            "is_open_edit": 0,
            "is_required_cp": 0,
            "is_required_cp_edit": 0,
            "is_required": 0,
            "is_required_edit": 0,
            "is_show": 1,
            "is_show_edit": 0
        }
        result = self.PcPost(self.interfaceUrl, data)
        return result