Exemplo n.º 1
0
	def format_recipients_string(self):
		# String to list
		self.assertEqual(utils.csv_to_list("1, 2"), ["1", "2"])
		self.assertEqual(utils.csv_to_list("1"), ["1",])
		self.assertEqual(utils.csv_to_list("1, 2,,,"), ["1", "2", "", "", ""])
		
		self.assertEqual(utils.format_recipients_string("1, 2, 3 3, 444, , ,,,"), ["1", "33", '2', '444'])
		self.assertEqual(utils.format_recipients_string("1, 2, 33, ,4 4,5"), ['1', '33', '44', '2', '5'])
		self.assertEqual(utils.format_recipients_string(""), [])
		self.assertEqual(utils.format_recipients_string("1"), ["1"])
		self.assertEqual(utils.format_recipients_string("1,1,  1,, 1"), ["1"])
Exemplo n.º 2
0
	def __init__(self, message, recipients):
		if not isinstance(message, str):
			raise AttributeError("The message must be a string")
		else:
			if len(message) is 0:
				raise AttributeError("The message string provided was empty")	
		self.message = utils.make_string_safe(message)
		if not isinstance(recipients, list):
			try:
				recipients = utils.csv_to_list(recipients)
			except:
				raise AttributeError("Provided recipients were not in a list and could not be converted.")
		recipients = utils.clean_list(recipients)
		if len(recipients) is 0:
			raise AttributeError("No recipients in the list")
		self.recipients = recipients