import os
import time
import uuid
from tests.functional import PmxbotHarness


class TestPmxbotLog(PmxbotHarness):
	def test_no_op(self):
		"""
		Test that the harness is working.
		"""

	def test_not_logged_channel(self):
		"""
		Test that a basic message in an unlogged room is unlogged.
		"""
		id = str(uuid.uuid4())
		msg = 'Unlogged msg from test_not_logged_channel. %s' % id
		self.client.send_message('#inane', msg)
		assert not self.check_logs(channel="#inane", message=msg)

	def test_logged_channel(self):
		"""
		Test whether a basic message in a logged room is logged.
		"""
		id = str(uuid.uuid4())
		msg = 'Logged msg from test_logged_channel. %s' % id
		self.client.send_message('#logged', msg)
		assert self.check_logs(channel="#logged", message=msg)
		
	def test_logged_channel_again(self):
		"""
		Test whether a second basic message in a logged room is logged.
		"""
		id = str(uuid.uuid4())
		msg = 'Logged msg number 2 from test_logged_channel_again. %s' % id
		self.client.send_message('#logged', msg)
		assert self.check_logs(channel="#logged", message=msg)

	def test_strike_1(self):
		"""
		Test the strike function for a single line.
		
		Send a single line that will remain, test that it was logged, then send
		one line that will be deleted, check it was logged, strike it, and check
		that it was deleted and the single line remains.
		"""
		id = str(uuid.uuid4())
		pre_text = 'Strike pre-text msg from test_strike_1. %s' % id
		self.client.send_message('#logged', pre_text)
		assert self.check_logs(channel="#logged", message=pre_text)
		
		msg = 'Strike ME msg from test_strike_1. %s' % id
		self.client.send_message('#logged', msg)
		assert self.check_logs(channel="#logged", message=msg)

		self.client.send_message('#logged', "!strike")
		assert not self.check_logs(channel="#logged", message=msg)
		assert self.check_logs(channel="#logged", message=pre_text)
		

	def test_strike_3(self):
		"""
		Test the strike function for multiple lines.
		
		Send a single line that will remain, test that it was logged, then send
		3 lines, test they were logged, send a strike 3, test the 3 lines were
		removed, and the pre-text still remains.
		"""
		id = str(uuid.uuid4())
		pre_text = "Strike test pre-text from test_strike_3 %s" % id
		self.client.send_message("#logged", pre_text)
		assert self.check_logs(channel="#logged", message=pre_text)
		
		base = "Strike ME msg %s from test_strike_3. " + id
		for i in xrange(1, 4):
			self.client.send_message('#logged', base % i)
		for i in xrange(1, 4):
			assert self.check_logs(channel="#logged", message=(base % i))
		self.client.send_message('#logged', "!strike 3")
		for i in xrange(1, 4):
			assert not self.check_logs(channel="#logged", message=(base % i))
		assert self.check_logs(channel="#logged", message=pre_text)
		
	def test_blank_input_logged(self):
		self.client.send_message("#logged", '')
		time.sleep(1)
		assert self.bot.poll() == None
		
	def test_blank_input_notlogged(self):
		self.client.send_message("#inane", '')
		time.sleep(1)
		assert self.bot.poll() == None
		

	def test_onespace_input_logged(self):
		self.client.send_message("#logged", '  ')
		time.sleep(1)
		assert self.bot.poll() == None

	def test_onespace_input_notlogged(self):
		self.client.send_message("#inane", '  ')
		time.sleep(1)
		assert self.bot.poll() == None
@@ -761,19 +761,17 @@
 ge=msg)%0A
-%09%09
 %0A
+
 %09def tes
@@ -1152,19 +1152,17 @@
 e line.%0A
-%09%09
 %0A
+
 %09%09Send a
@@ -1557,19 +1557,17 @@
 e_text)%0A
-%09%09
 %0A
+
 %09%09msg = 
@@ -1883,19 +1883,17 @@
 e_text)%0A
-%09%09
 %0A
+
 %0A%09def te
@@ -1964,19 +1964,17 @@
  lines.%0A
-%09%09
 %0A
+
 %09%09Send a
@@ -2359,19 +2359,17 @@
 e_text)%0A
-%09%09
 %0A
+
 %09%09base =
@@ -2785,19 +2785,17 @@
 e_text)%0A
-%09%09
 %0A
+
 %09def tes
@@ -2913,19 +2913,17 @@
 == None%0A
-%09%09
 %0A
+
 %09def tes
@@ -3047,11 +3047,9 @@
 one%0A
-%09%09
 %0A
+
 %0A%09de
@@ -3271,32 +3271,32 @@
 %09%09time.sleep(1)%0A
-
 %09%09assert self.bo
@@ -3291,28 +3291,29 @@
 sert self.bot.poll() == None
+%0A

Cleaned up whitespace