def test_danmakumodel(): publisher = TEST_STRING content = TEST_STRING recieved_time = datetime.now().strftime(TIME_FORMAT) test_string = u"[{0}] 用户 {1} 说:{2}".format( recieved_time, publisher, content) danmaku = DanmakuModel(publisher, content, recieved_time) assert danmaku.to_string() == test_string
def setUp(self): self.publisher = STRING self.content = STRING self.recieved_time = DATE self.danmaku = DanmakuModel( self.publisher, self.content, self.recieved_time, DANMU_MSG)
class TestDanmakuModel(TestCase): def setUp(self): self.publisher = STRING self.content = STRING self.recieved_time = DATE self.danmaku = DanmakuModel( self.publisher, self.content, self.recieved_time, DANMU_MSG) def test_title(self): eq_(self.danmaku.title, DanmakuModel.USER) self.danmaku.is_vip = True eq_(self.danmaku.title, ''.join([DanmakuModel.VIP, DanmakuModel.USER])) self.danmaku.is_admin = True eq_(self.danmaku.title, ''.join([DanmakuModel.VIP, DanmakuModel.ADMIN])) self.danmaku.is_vip = False eq_(self.danmaku.title, DanmakuModel.ADMIN) def test_to_string(self): string = STRING_DICT.get(DANMU_MSG).format( self.recieved_time, self.danmaku.title, self.publisher, self.content) eq_(self.danmaku.to_string(), string) self.danmaku.danmaku_type = SEND_GIFT string = STRING_DICT.get(SEND_GIFT).format( self.recieved_time, self.danmaku.title, self.publisher, self.content) eq_(self.danmaku.to_string(), string) self.danmaku.danmaku_type = WELCOME string = STRING_DICT.get(WELCOME).format( self.recieved_time, self.danmaku.title, self.publisher) eq_(self.danmaku.to_string(), string) self.danmaku.danmaku_type = SEND_TOP string = STRING_DICT.get(SEND_TOP).format( self.recieved_time, self.publisher, self.content) eq_(self.danmaku.to_string(), string)
class TestDanmakuModel(TestCase): def setUp(self): self.publisher = STRING self.content = STRING self.recieved_time = DATE self.danmaku = DanmakuModel(self.publisher, self.content, self.recieved_time, DANMU_MSG) def test_title(self): eq_(self.danmaku.title, DanmakuModel.USER) self.danmaku.is_vip = True eq_(self.danmaku.title, ''.join([DanmakuModel.VIP, DanmakuModel.USER])) self.danmaku.is_admin = True eq_(self.danmaku.title, ''.join([DanmakuModel.VIP, DanmakuModel.ADMIN])) self.danmaku.is_vip = False eq_(self.danmaku.title, DanmakuModel.ADMIN) def test_to_string(self): string = STRING_DICT.get(DANMU_MSG).format(self.recieved_time, self.danmaku.title, self.publisher, self.content) eq_(self.danmaku.to_string(), string) self.danmaku.danmaku_type = SEND_GIFT string = STRING_DICT.get(SEND_GIFT).format(self.recieved_time, self.danmaku.title, self.publisher, self.content) eq_(self.danmaku.to_string(), string) self.danmaku.danmaku_type = WELCOME string = STRING_DICT.get(WELCOME).format(self.recieved_time, self.danmaku.title, self.publisher) eq_(self.danmaku.to_string(), string) self.danmaku.danmaku_type = SEND_TOP string = STRING_DICT.get(SEND_TOP).format(self.recieved_time, self.publisher, self.content) eq_(self.danmaku.to_string(), string)
def setUp(self): self.publisher = STRING self.content = STRING self.recieved_time = DATE self.danmaku = DanmakuModel(self.publisher, self.content, self.recieved_time, DANMU_MSG)