Example #1
0
	def test_prepare_message_returns_cr_lf(self):
		email = get_email_queue(
			recipients=['*****@*****.**'],
			sender='*****@*****.**',
			subject='Test Subject',
			content='<h1>\n this is a test of newlines\n' + '</h1>',
			formatted='<h1>\n this is a test of newlines\n' + '</h1>',
			text_content='whatever')
		result = safe_decode(prepare_message(email=email,
						recipient='*****@*****.**', recipients_list=[]))
		if PY3:
			self.assertTrue(result.count('\n') == result.count("\r"))
		else:
			self.assertTrue(True)
Example #2
0
	def test_prepare_message_returns_cr_lf(self):
		email = get_email_queue(
			recipients=["*****@*****.**"],
			sender="*****@*****.**",
			subject="Test Subject",
			content="<h1>\n this is a test of newlines\n" + "</h1>",
			formatted="<h1>\n this is a test of newlines\n" + "</h1>",
			text_content="whatever",
		)
		result = safe_decode(prepare_message(email=email, recipient="*****@*****.**", recipients_list=[]))
		if PY3:
			self.assertTrue(result.count("\n") == result.count("\r"))
		else:
			self.assertTrue(True)
Example #3
0
	def test_rfc_5322_header_is_wrapped_at_998_chars(self):
		# unfortunately the db can only hold 140 chars so this can't be tested properly. test at max chars anyway.
		email = get_email_queue(
			recipients=['*****@*****.**'],
			sender='*****@*****.**',
			subject='Test Subject',
			content='<h1>Whatever</h1>',
			text_content='whatever',
			message_id="a.really.long.message.id.that.should.not.wrap.until.998.if.it.does.then.exchange.will.break" +
			".really.long.message.id.that.should.not.wrap.unti")
		result = safe_decode(prepare_message(email=email, recipient='*****@*****.**',
					recipients_list=[]))
		self.assertTrue(
			"a.really.long.message.id.that.should.not.wrap.until.998.if.it.does.then.exchange.will.break" +
			".really.long.message.id.that.should.not.wrap.unti" in result)
Example #4
0
	def test_prepare_message_returns_already_encoded_string(self):

		if PY3:
			uni_chr1 = chr(40960)
			uni_chr2 = chr(1972)
		else:
			uni_chr1 = unichr(40960)
			uni_chr2 = unichr(1972)

		email = get_email_queue(
			recipients=['*****@*****.**'],
			sender='*****@*****.**',
			subject='Test Subject',
			content='<h1>' + uni_chr1 + 'abcd' + uni_chr2 + '</h1>',
			formatted='<h1>' + uni_chr1 + 'abcd' + uni_chr2 + '</h1>',
			text_content='whatever')
		result = prepare_message(email=email, recipient='*****@*****.**', recipients_list=[])
		self.assertTrue(b"<h1>=EA=80=80abcd=DE=B4</h1>" in result)
Example #5
0
	def test_prepare_message_returns_already_encoded_string(self):

		if PY3:
			uni_chr1 = chr(40960)
			uni_chr2 = chr(1972)
		else:
			uni_chr1 = unichr(40960)
			uni_chr2 = unichr(1972)

		email = get_email_queue(
			recipients=["*****@*****.**"],
			sender="*****@*****.**",
			subject="Test Subject",
			content="<h1>" + uni_chr1 + "abcd" + uni_chr2 + "</h1>",
			formatted="<h1>" + uni_chr1 + "abcd" + uni_chr2 + "</h1>",
			text_content="whatever",
		)
		result = prepare_message(email=email, recipient="*****@*****.**", recipients_list=[])
		self.assertTrue(b"<h1>=EA=80=80abcd=DE=B4</h1>" in result)