def test_delete(self): aa = MPostHist.get_by_uid(self.uid) assert aa == None self.addHis() aa = MPostHist.get_by_uid(self.uid) assert aa.post_id == self.post_id aa = MPostHist.delete(self.post_id) assert aa == False self.tearDown()
def test_update_cnt(self): self.addHis() post_data = {'user_name': 'giser', 'cnt_md': 'gisersdfsdfsdf'} MPostHist.update_cnt(self.uid, post_data) pp = MPostHist.get_by_uid(self.uid) assert pp.cnt_md == post_data['cnt_md'] self.tearDown()
def restore(self, hist_uid): if self.check_post_role()['ADMIN']: pass else: return False histinfo = MPostHist.get_by_uid(hist_uid) if histinfo: pass else: return False postinfo = MPost.get_by_uid(histinfo.post_id) cur_cnt = tornado.escape.xhtml_unescape(postinfo.cnt_md) old_cnt = tornado.escape.xhtml_unescape(histinfo.cnt_md) MPost.update_cnt(histinfo.post_id, { 'cnt_md': old_cnt, 'user_name': self.userinfo.user_name }) MPostHist.update_cnt(histinfo.uid, { 'cnt_md': cur_cnt, 'user_name': postinfo.user_name }) self.redirect('/{0}/{1}'.format(router_post[postinfo.kind], postinfo.uid))
def tearDown(self): print("function teardown") tt = MPostHist.get_by_uid(self.uid) if tt: MPostHist.delete(tt.uid) tt = MPost.get_by_uid(self.post_id) if tt: MPost.delete(tt.uid)
def delete(self, uid): if self.check_post_role()['DELETE']: pass else: return False histinfo = MPostHist.get_by_uid(uid) if histinfo: pass else: return False postinfo = MPost.get_by_uid(histinfo.post_id) MPostHist.delete(uid) self.redirect('/post_man/view/{0}'.format(postinfo.uid))
def test_get_by_uid(self): p_t = {'cnt_md': 'bbrreedd'} self.addHis(**p_t) pp = MPostHist.get_by_uid(self.uid) assert pp.cnt_md == p_t['cnt_md'] self.tearDown()
def test_get_by_uid(self): MPostHist.get_by_uid(self.uid) assert True