예제 #1
0
	def test_CycleHandlerOther(self):
		# 周期ツイート制御のインスタンスを生成
		ct = CycleTweet(datetime.datetime(2012, 3, 4, 13, 00))

		# tweepyAPIのモックを作成
		apiMock = self.mocker.CreateMock(tweepy.API)

		# モックをテスト対象に設定
		ct.api = apiMock

		# スケジュール取得関数をモック化
		self.mocker.StubOutWithMock(ct, "nekorobiOpen")
		self.mocker.StubOutWithMock(ct, "nekorobiClose")
		self.mocker.StubOutWithMock(ct, "otherTweet")

		# 記録をリセット
		self.mocker.ResetAll()

		# 呼び出しの記録
		ct.otherTweet().AndReturn(u'Other')
		apiMock.update_status(u'Other')

		# 再現動作の開始
		self.mocker.ReplayAll()

		# 周期制御のハンドラ呼び出し
		ct.cycleHandler()

		# 実動作の検証
		self.mocker.VerifyAll()
예제 #2
0
	def test_OtherTweetChoice(self):

		# 周期ツイート制御のインスタンスを生成
		ct = CycleTweet(datetime.datetime(2011, 2, 23, 10, 0))

		# 呟きの取得
		s = ct.otherTweet()

		# 呟きの取得
		s = ct.otherTweet()

		# 呟きの取得
		s = ct.otherTweet()
예제 #3
0
	def test_PriorityTweet(self):

		# ダミーデータの設定
		ds = DataStore.DataStore()

		# 優先ツイートの設定
		ds.addStatus(DataStore.Type.priority, u'prio1')

		# 周期ツイート制御のインスタンスを生成
		ct = CycleTweet(datetime.datetime(2011, 2, 23, 8, 0))

		# 優先ツイートが取得できること
		s = ct.otherTweet()
		m = re.match(u'(.*)\(.*\)', s)
		if m: s = m.group(1)
		assert_equal(u'prio1', s)

		# 通常ツイートに戻ること
		s = ct.otherTweet()
		m = re.match(u'(.*)\(.*\)', s)
		if m: s = m.group(1)
		assert_not_equal(u'prio1', s)
예제 #4
0
	def test_OtherTweet(self):

		# 周期ツイート制御のインスタンスを生成
		ct = CycleTweet(datetime.datetime(2011, 2, 23, 10, 0))

		# 呟きの取得
		s = ct.otherTweet()

		# 何か呟きが取得できていること
		m = re.match(u'(.*)\d\(.*\)', s)
		if m: s = m.group(1)
		assert_equals(u'test', s)

		ds = DataStore.DataStore()
		detect = False
		lst = ds.getStatuses(DataStore.Type.normal)
		for st in lst:
			if st[3] != 0:
				detect = True
		assert_true(detect)