Пример #1
0
 def setup_class(cls):
     cls.tag = Tag()
     for name in ['add demo']:
         tag_id = cls.tag.jsonpath(cls.tag.get(),
                                   f'$..tag[?(@.name=="{name}")].id')
         if tag_id:
             cls.tag.delete(tag_id=tag_id[0])
Пример #2
0
class TestTag:
    tag = Tag()
    test_data = tag.load('test_tag.data.yaml')

    @classmethod
    def setup_class(cls):
        data = cls.tag.get()
        for name in ["add demo"]:
            tag_id = cls.tag.jsonpath(data, f'$..tag[?(@.name=="{name}")].id')
            if tag_id:
                print(name)
                cls.tag.delete(tag_id=tag_id[0])

    def setup(self):
        pass

    @pytest.mark.parametrize("name_old, name_new", test_data)
    def test_all(self, name_old, name_new):

        data = self.tag.get()
        for name in [name_old, name_new]:
            tag_id = self.tag.jsonpath(data, f'$..tag[?(@.name=="{name}")].id')
            if tag_id:
                print(name)
                self.tag.delete(tag_id[0])

        assert self.tag.add(name_old)['errcode'] == 0
        tag_id = self.tag.jsonpath(self.tag.get(),
                                   f'$..tag[?(@.name=="{name_old}")].id')[0]
        assert self.tag.update(tag_id, name_new)['errcode'] == 0

    def test_get(self):
        assert self.tag.get()['errcode'] == 0

    def test_add(self):
        assert self.tag.add(tag_name="add demo")['errcode'] == 0

    def test_delete(self):
        name = "add demo"
        assert self.tag.add(tag_name=name)['errcode'] == 0
        tag_id = self.tag.jsonpath(self.tag.get(),
                                   f'$..tag[?(@.name=="{name}")].id')[0]
        print(Tag().delete(tag_id=tag_id))

    def test_update(self):
        print(Tag().update('etQKd-CgAAE6Zdmx89xoc_LYuIyLWwNw', 'wangwu'))
Пример #3
0
class TestTag:
    def setup(self):
        self.tag = Tag()

    def test_all(self):
        tag_id = jsonpath(self.tag.get(), '$..tag[?(@.name=="wangwu")].id')
        if tag_id:
            self.tag.delete(tag_id[0])
        self.tag.add("wangwu")
        tag_id = jsonpath(self.tag.get(), '$..tag[?(@.name=="wangwu")].id')[0]
        self.tag.update(tag_id, "hahaha")

    def test_get(self):
        print(json.dumps(Tag().get(), indent=2))

    def test_delete(self):
        print(Tag().delete('etQKd-CgAAI70aMYm4j37aJyTo0EMRmw'))

    def test_update(self):
        print(Tag().update('etQKd-CgAAE6Zdmx89xoc_LYuIyLWwNw', 'wangwu'))
Пример #4
0
class Test_Tag:
    tag = Tag()
    test_data = BaseApi.load('./test_requests/test_case/test_tag_data.yaml')

    @classmethod
    def setup_class(cls):
        data = cls.tag.get()
        for name in ["add demo"]:
            # 找到包含zhangsan 属性的tag节点,再通过.id查找到所属id
            tag_id = cls.tag.jsonpath(data, f'$..tag[?(@.name=="{name}")].id')
            if tag_id:
                cls.tag.delete(tag_id[0])

    def setup(self):
        pass

    @pytest.mark.parametrize("name_old,name_new", test_data)
    def test_all(self, name_old, name_new):
        # data = self.tag.get()
        # for name in [name_old, name_new]:
        #     # 找到包含zhangsan 属性的tag节点,再通过.id查找到所属id
        #     tag_id = self.tag.jsonpath(data, f'$..tag[?(@.name=="{name}")].id')
        #     if tag_id:
        #         self.tag.delete(tag_id[0])
        assert self.tag.add(name_old)['errcode'] == 0
        tag_id = self.tag.jsonpath(self.tag.get(), f'$..tag[?(@.name=="{name_old}")].id')[0]
        assert self.tag.update(tag_id, name_new)['errcode'] == 0

    def test_add(self):
        assert self.tag.add("add demo")["errcode"] == 0

    def test_get(self):
        # 格式美化
        assert self.tag.get()['errcode'] == 0
        # print(json.dumps(self.tag.get(), indent=2))

    def test_delete(self):
        print(self.tag.delete("etQKd-CgAAI70aMYm4j37aJyTo0EMRmw"))

    def test_update(self):
        print(Tag().update('etQKd-CgAAE6Zdmx89xoc_LYuIyLWwNw', 'wangwu'))
Пример #5
0
 def test_update(self):
     print(Tag().update('etQKd-CgAAE6Zdmx89xoc_LYuIyLWwNw', 'wangwu'))
Пример #6
0
 def test_delete(self):
     name = "add demo"
     assert self.tag.add(tag_name=name)['errcode'] == 0
     tag_id = self.tag.jsonpath(self.tag.get(),
                                f'$..tag[?(@.name=="{name}")].id')[0]
     print(Tag().delete(tag_id=tag_id))
Пример #7
0
 def test_update_tag(self):
     print(Tag().update_tag("et2Gx3DAAAT3OXcTdfPIcnDGxfX7s17w", "亲戚"))
Пример #8
0
 def test_delete_tag(self):
     print(Tag().delete_tag("et2Gx3DAAAg7mfAdQ0GTS_Wk-fi_ioPg"))
Пример #9
0
 def setup_class(cls):
     cls.tag = Tag()
Пример #10
0
 def setup(self):
     self.tag = Tag()
Пример #11
0
 def test_delete(self):
     print(Tag().delete('etQKd-CgAAI70aMYm4j37aJyTo0EMRmw'))
Пример #12
0
 def test_get(self):
     print(json.dumps(Tag().get(), indent=2))
Пример #13
0
 def setup_class(cls):
     # 实例化对象
     cls.tag = Tag()
Пример #14
0
 def setup_class(cls):
     cls.tag = Tag()
     cls.reset()