class TestLabel(): def setup(self): print('setup 方法执行于本类中每条用例之前') self.uu = MLabel() self.name = 'name' self.tmpl_uid = '' self.uid = tools.get_uu4d() def test_insert(self): post_data = { 'name': 'titlesdf', } newid = MLabel.create_tag(post_data['name']) tt = MLabel.get_id_by_name(post_data['name']) # assert tt.uid == suid self.tmpl_uid = tt assert tt == newid def test_insert_2(self): '''Wiki insert: Test invalid title''' post_data = { 'name': self.name, } uu = self.uu.create_tag(post_data['name']) # assert uu == False post_data = { 'name': '', } uu = self.uu.create_tag(post_data['name']) # assert uu == False def test_create_tag_with_uid(self): '''Wiki insert: Test invalid title''' post_data = { 'name': self.name, } self.uu.create_tag_with_uid(self.uid, post_data['name']) assert True def test_get_id_by_name(self): MLabel.get_id_by_name(self.name) assert True def test_get_by_slug(self): MLabel.get_by_slug(self.name) assert True def test_delete(self): MLabel.delete(self.uid) assert True def tearDown(self): print("function teardown") tt = self.uu.get_id_by_name(self.name) self.uu.delete(self.tmpl_uid)
def add_mess(self, **kwargs): p_d = { 'title': kwargs.get('title', 'iiiii'), 'cnt_md': kwargs.get('cnt_md', 'grgr'), 'time_create': kwargs.get('time_create', '1992'), 'time_update': kwargs.get('time_update', '1996070600'), 'user_name': kwargs.get('user_name', 'fdsa'), 'view_count': kwargs.get('view_count', 1), 'logo': kwargs.get('logo', 'prprprprpr'), 'memo': kwargs.get('memo', ''), 'order': kwargs.get('order', '1'), 'keywords': kwargs.get('keywords', ''), 'extinfo': kwargs.get('extinfo', {}), 'kind': kwargs.get('kind2', '1'), 'valid': kwargs.get('valid', 1), } post_id = kwargs.get('post_id', self.post_id) MPost.create_post(post_id, p_d) MLabel.create_tag_with_uid(self.uid, self.name)
class TestMLabel(): def setup(self): print('setup 方法执行于本类中每条用例之前') self.uu = MLabel() self.name = 'name' self.tmpl_uid = '' self.uid = tools.get_uu4d() self.post_id = '2222' def test_create_tag(self): post_data = { 'name': self.name, } newid = MLabel.create_tag(post_data['name']) tt = MLabel.get_id_by_name(post_data['name']) self.tmpl_uid = tt assert tt == newid self.tearDown() def test_create_tag_with_uid(self): '''Wiki insert: Test invalid title''' post_data = { 'name': self.name, } self.uu.create_tag_with_uid(self.uid, post_data['name']) a = self.uu.get_id_by_name(post_data['name']) assert a == self.uid self.tearDown() def add_message(self, **kwargs): p_d = { 'title': kwargs.get('title', 'iiiii'), 'cnt_md': kwargs.get('cnt_md', 'grgr'), 'time_create': kwargs.get('time_create', '1992'), 'time_update': kwargs.get('time_update', '1996070600'), 'user_name': kwargs.get('user_name', 'yuanyuan'), 'view_count': kwargs.get('view_count', 1), 'logo': kwargs.get('logo', 'prprprprpr'), 'memo': kwargs.get('memo', ''), 'order': kwargs.get('order', '1'), 'keywords': kwargs.get('keywords', ''), 'extinfo': kwargs.get('extinfo', {}), 'kind': kwargs.get('kind2', '1'), 'valid': kwargs.get('valid', 1), } post_id = kwargs.get('post_id', self.post_id) MPost.create_post(post_id, p_d) self.uu.create_tag_with_uid(self.uid, self.name) MPost2Label.add_record(self.post_id, self.name) def test_get_id_by_name(self): self.add_message() a = self.uu.get_id_by_name(self.name) print(a) print(self.uid) assert a == self.uid self.tearDown() def test_get_by_slug(self): self.add_message() a = self.uu.get_by_slug(self.uid) assert a.name == self.name self.tearDown() def test_delete(self): self.add_message() a = self.uu.get_by_slug(self.uid) assert a.name == self.name self.uu.delete(self.uid) a = self.uu.get_by_slug(self.uid) print(a) assert a == False self.tearDown() def tearDown(self): print("function teardown") tt = self.uu.get_by_slug(self.tmpl_uid) if tt: print('99999999') self.uu.delete(self.tmpl_uid) tt = self.uu.get_by_slug(self.uid) if tt: print('444444444') self.uu.delete(self.uid) tt = MPost.get_by_uid(self.post_id) if tt: print('0000000000') MPost.delete(self.post_id)