def setup(self): print('setup 方法执行于本类中每条用例之前') self.user = MUser() self.reply = MReply() self.r2u = MReply2User() self.username = '******' self.password = '******' self.user_uid = '12345' self.reply_uid = '65412'
def zan(self, id_reply): ''' 先在外部表中更新,然后更新内部表字段的值。 有冗余,但是查看的时候避免了联合查询 :param id_reply: :return: ''' logger.info('zan: {0}'.format(id_reply)) MReply2User.create_reply(self.userinfo.uid, id_reply) cur_count = MReply2User.get_voter_count(id_reply) if cur_count: MReply.update_vote(id_reply, cur_count) output = {'text_zan': cur_count} else: output = {'text_zan': 0} logger.info('zan dic: {0}'.format(cur_count)) return json.dump(output, self)
def add_message(self, **kwargs): post_data = { 'user_name': self.username, 'user_pass': kwargs.get('user_pass', 'g131322'), 'user_email': kwargs.get('user_email', '*****@*****.**'), } MUser.create_user(post_data) aa = MUser.get_by_name(self.username) self.user_id = aa.uid 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', 'ngng'), '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), } MPost.create_post(self.post_id, p_d) post_reply={ 'post_id':self.post_id, 'user_name':self.username, 'user_id':self.user_id, 'cnt_reply':'daswrevwefgfgff' } self.reply_uid=MReply.create_reply(post_reply) MReplyid.create_replyid(self.post_id,self.reply_uid) aa=MReplyid.get_by_rid(self.post_id) for i in aa: if i.reply1==self.reply_uid: self.reply_id_uid=i.reply0 MReply2User.create_reply(self.user_id,self.reply_uid)
def setup(self): print('setup 方法执行于本类中每条用例之前') self.post = MPost() self.user = MUser() self.reply = MReply() self.r2u = MReply2User() self.post_title = 'fwwgccc' self.username = '******' self.user_uid = '' self.reply_uid = '' self.post_uid = '998h' self.password = '******'
def delete(self, del_id): if MReply2User.delete(del_id): output = {'del_zan': 1} else: output = {'del_zan': 0} return json.dump(output, self)
def tearDown(self): print("function teardown") MUser.delete_by_user_name(self.username) MPost.delete(self.post_id) MReply2User.delete(self.reply_uid) MReply.delete_by_uid(self.reply_uid)
def initialize(self): self.init() self.tab = MReply() self.mreply2user = MReply2User()
def initialize(self): self.init() self.mreply = MReply() self.mreply2user = MReply2User() self.mpost2reply = MPost2Reply()
def Test(): assert MReply2User()
def tearDown(self): print("function teardown") MReply2User.delete(self.reply_id)
def test_get_voter_count(self): MReply2User.get_voter_count(self.reply_id) assert True
def test_create_reply(self): MReply2User.create_reply(self.user_id, self.reply_id) assert True