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])
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'))
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'))
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'))
def test_update(self): print(Tag().update('etQKd-CgAAE6Zdmx89xoc_LYuIyLWwNw', 'wangwu'))
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_tag(self): print(Tag().update_tag("et2Gx3DAAAT3OXcTdfPIcnDGxfX7s17w", "亲戚"))
def test_delete_tag(self): print(Tag().delete_tag("et2Gx3DAAAg7mfAdQ0GTS_Wk-fi_ioPg"))
def setup_class(cls): cls.tag = Tag()
def setup(self): self.tag = Tag()
def test_delete(self): print(Tag().delete('etQKd-CgAAI70aMYm4j37aJyTo0EMRmw'))
def test_get(self): print(json.dumps(Tag().get(), indent=2))
def setup_class(cls): # 实例化对象 cls.tag = Tag()
def setup_class(cls): cls.tag = Tag() cls.reset()