|
|
@ -6,18 +6,18 @@ class MailTagsTest(TestCase): |
|
|
|
"""Testuje template tagy ohledně mailů.""" |
|
|
|
def test_maillink(self): |
|
|
|
# Tohle nedává smysl dělit do víc funkcí, bylo by v nich víc boilerplatu než užitečného kódu. |
|
|
|
self.assertEquals(maillink('Hello', to='some@body.test'), r'<a href="mailto:some@body.test">Hello</a>') |
|
|
|
self.assertEquals(maillink('Hello', to=['some@body.test']), r'<a href="mailto:some@body.test">Hello</a>') |
|
|
|
self.assertEquals( |
|
|
|
self.assertEqual(maillink('Hello', to='some@body.test'), r'<a href="mailto:some@body.test">Hello</a>') |
|
|
|
self.assertEqual(maillink('Hello', to=['some@body.test']), r'<a href="mailto:some@body.test">Hello</a>') |
|
|
|
self.assertEqual( |
|
|
|
maillink('Hello', to=['alice@test.test', 'bob@jinde.test']), |
|
|
|
r'<a href="mailto:alice@test.test,bob@jinde.test">Hello</a>', |
|
|
|
) |
|
|
|
self.assertEquals( |
|
|
|
self.assertEqual( |
|
|
|
maillink('Hello', to='some@body.test', attrs='class="trida" id="id"'), |
|
|
|
r'<a href="mailto:some@body.test" class="trida" id="id">Hello</a>', |
|
|
|
) |
|
|
|
# Následující test toho testuje moc zároveň, měly by předcházet dedikované testy… (kašlu na ně :-P) |
|
|
|
self.assertEquals( |
|
|
|
self.assertEqual( |
|
|
|
maillink('Text odkazu', to='prijemce@wtf.test', subject="Předmět", body="Čau"), |
|
|
|
r'<a href="mailto:prijemce@wtf.test?subject=P%C5%99edm%C4%9Bt&body=%C4%8Cau">Text odkazu</a>', |
|
|
|
) |
|
|
@ -25,10 +25,10 @@ class MailTagsTest(TestCase): |
|
|
|
self.assertRaises(TypeError, lambda: maillink()) # Nemá text, takže to shodí python |
|
|
|
|
|
|
|
def test_mailurl(self): |
|
|
|
self.assertEquals(mailurl(to='some@body.test'), r'mailto:some@body.test') |
|
|
|
self.assertEquals(mailurl(to=['some@body.test']), r'mailto:some@body.test') |
|
|
|
self.assertEquals(mailurl(to=['alice@test.test', 'bob@jinde.test']), r'mailto:alice@test.test,bob@jinde.test') |
|
|
|
self.assertEquals( |
|
|
|
self.assertEqual(mailurl(to='some@body.test'), r'mailto:some@body.test') |
|
|
|
self.assertEqual(mailurl(to=['some@body.test']), r'mailto:some@body.test') |
|
|
|
self.assertEqual(mailurl(to=['alice@test.test', 'bob@jinde.test']), r'mailto:alice@test.test,bob@jinde.test') |
|
|
|
self.assertEqual( |
|
|
|
mailurl(to='some@body.test', body='Tělo', subject='Předmět'), |
|
|
|
r'mailto:some@body.test?subject=P%C5%99edm%C4%9Bt&body=T%C4%9Blo', |
|
|
|
) |
|
|
@ -48,7 +48,7 @@ class MailTagsTest(TestCase): |
|
|
|
# TODO: Vyzkoušet i víc adresátů. (Nepamatuji si z hlavy syntaxi…) |
|
|
|
r'{% maillink "Text" to="alice@test.test" subject="Oprava řešení" %}' |
|
|
|
) |
|
|
|
self.assertEquals( |
|
|
|
self.assertEqual( |
|
|
|
render_template(template), |
|
|
|
r'<a href="mailto:alice@test.test?subject=Oprava%20%C5%99e%C5%A1en%C3%AD">Text</a>', |
|
|
|
) |
|
|
@ -57,4 +57,4 @@ class MailTagsTest(TestCase): |
|
|
|
r'{% load mail %}' |
|
|
|
r'{% mailurl to="alice@test.test" subject="Čau Alice" %}' |
|
|
|
) |
|
|
|
self.assertEquals(render_template(mailurltemplate), r'mailto:alice@test.test?subject=%C4%8Cau%20Alice') |
|
|
|
self.assertEqual(render_template(mailurltemplate), r'mailto:alice@test.test?subject=%C4%8Cau%20Alice') |
|
|
|