Commit 8e357f61 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

update to unittest2 api

--HG--
branch : stable
parent 247336e0d0d5
......@@ -19,13 +19,13 @@ CRM : http://www.pimentech.fr/solutions/crm
--
Alexandre Fayolle
''')
self.assertTextEquals(parsedmsg.actual_content, '''Des gens qui se sont mis sur le secteur erp avec du zope, du php, de postgresql et du debian : pimentech.
self.assertMultiLineEqual(parsedmsg.actual_content, '''Des gens qui se sont mis sur le secteur erp avec du zope, du php, de postgresql et du debian : pimentech.
jpl/crm/compta/paie intégré : http://www.pimentech.fr/solutions/pimenstud
gestion/compta : http://www.pimentech.fr/solutions/pimengest
travail collaboratif : http://www.pimentech.fr/solutions/notesgroup
CRM : http://www.pimentech.fr/solutions/crm''')
self.assertTextEquals(parsedmsg.cited_content, '')
self.assertMultiLineEqual(parsedmsg.cited_content, '')
def test_remove_cites(self):
......@@ -46,8 +46,8 @@ Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
Python et calcul scientifique: http://www.logilab.fr/science
''')
self.assertTextEquals(parsedmsg.actual_content, '''leur solution CRM est même basé sur Zope...''')
self.assertTextEquals(parsedmsg.cited_content, '''On Tue, Jan 08, 2008 at 10:08:46AM +0100, Alexandre Fayolle wrote:
self.assertMultiLineEqual(parsedmsg.actual_content, '''leur solution CRM est même basé sur Zope...''')
self.assertMultiLineEqual(parsedmsg.cited_content, '''On Tue, Jan 08, 2008 at 10:08:46AM +0100, Alexandre Fayolle wrote:
Des gens qui se sont mis sur le secteur erp avec du zope, du php, de postgresql et du debian : pimentech.
jpl/crm/compta/paie intégré : http://www.pimentech.fr/solutions/pimenstud
gestion/compta : http://www.pimentech.fr/solutions/pimengest
......@@ -88,14 +88,14 @@ Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects
''')
self.assertTextEquals(parsedmsg.actual_content, '''Hi Marteen,
self.assertMultiLineEqual(parsedmsg.actual_content, '''Hi Marteen,
did you actually execute that code ?
_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects''')
self.assertTextEquals(parsedmsg.cited_content, '''On Wed, Jan 23, 2008 at 06:48:22PM +0100, Maarten ter Huurne wrote:
self.assertMultiLineEqual(parsedmsg.cited_content, '''On Wed, Jan 23, 2008 at 06:48:22PM +0100, Maarten ter Huurne wrote:
I wrote on 2008-01-23 06:27:07 PM:
[Lotus Notes ate my whitespace, here is the proper code layout, I hope]
===
......
......@@ -58,8 +58,8 @@ class ChangeStateHooksTC(CubicWebTC):
self.commit()
userstate = self.execute('Any SN WHERE X in_state S, S name SN, X eid %(x)s',
{'x': u.eid}, 'x')[0][0]
self.assertEquals(userstate, 'deactivated')
self.assertEquals(u.cw_adapt_to('IWorkflowable').latest_trinfo().creator.login, 'admin')
self.assertEqual(userstate, 'deactivated')
self.assertEqual(u.cw_adapt_to('IWorkflowable').latest_trinfo().creator.login, 'admin')
def test_email_change_state_trinfo_owner(self):
self.execute('SET U use_email E WHERE U login "anon"')
......@@ -73,8 +73,8 @@ class ChangeStateHooksTC(CubicWebTC):
self.commit()
userstate = self.execute('Any SN WHERE X in_state S, S name SN, X eid %(x)s',
{'x': u.eid}, 'x')[0][0]
self.assertEquals(userstate, 'deactivated')
self.assertEquals(u.cw_adapt_to('IWorkflowable').latest_trinfo().creator.login, 'anon')
self.assertEqual(userstate, 'deactivated')
self.assertEqual(u.cw_adapt_to('IWorkflowable').latest_trinfo().creator.login, 'anon')
def test_email_change_state_wrong_eid(self):
ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G '
......@@ -87,7 +87,7 @@ class ChangeStateHooksTC(CubicWebTC):
self.commit()
userstate = self.execute('Any SN WHERE X in_state S, S name SN, X eid %(x)s',
{'x': ueid}, 'x')[0][0]
self.assertEquals(userstate, 'activated')
self.assertEqual(userstate, 'activated')
def test_email_change_state_unexistant_eid(self):
ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G '
......@@ -100,7 +100,7 @@ class ChangeStateHooksTC(CubicWebTC):
self.commit()
userstate = self.execute('Any SN WHERE X in_state S, S name SN, X eid %(x)s',
{'x': ueid}, 'x')[0][0]
self.assertEquals(userstate, 'activated')
self.assertEqual(userstate, 'activated')
def test_email_change_state_unexistant_transition(self):
ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G '
......@@ -113,7 +113,7 @@ class ChangeStateHooksTC(CubicWebTC):
self.commit()
userstate = self.execute('Any SN WHERE X in_state S, S name SN, X eid %(x)s',
{'x': ueid}, 'x')[0][0]
self.assertEquals(userstate, 'activated')
self.assertEqual(userstate, 'activated')
......
......@@ -14,52 +14,52 @@ class MBOXImporterTC(CubicWebTC):
def test_all(self):
mi = MBOXImporter(self.cnx)
mi.import_mbox_stream(open('data/mbox'))
self.assertEquals(sorted([(x, len(y)) for x, y in mi.created.items()]),
self.assertEqual(sorted([(x, len(y)) for x, y in mi.created.items()]),
[('email', 2), ('emailaddress', 4),
('emailpart', 5), ('emailthread', 2), ('file', 2)])
self.assertEquals(mi.skipped, [])
self.assertEqual(mi.skipped, [])
rset = self.execute('Any X ORDERBY S WHERE X is Email, X subject S')
self.assertEquals(len(rset), 2)
self.assertEqual(len(rset), 2)
email = rset.get_entity(0, 0)
self.assertEquals(email.subject, 'Re: [Python-projects] Pylint: Disable-msg for a block or statement?')
self.assertEquals(email.sender[0].address, 'pink@odahoda.de')
self.assertEquals(email.sender[0].alias, 'Benjamin Niemann')
self.assertEquals([r.address for r in email.recipients], ['python-projects@logilab.org'])
self.assertEquals([r.address for r in email.cc], [])
self.assertEquals(email.in_thread[0].title, '[Python-projects] Pylint: Disable-msg for a block or statement?')
self.assertEquals(sorted([(f.data_name, f.data_format) for f in email.attachment]),
self.assertEqual(email.subject, 'Re: [Python-projects] Pylint: Disable-msg for a block or statement?')
self.assertEqual(email.sender[0].address, 'pink@odahoda.de')
self.assertEqual(email.sender[0].alias, 'Benjamin Niemann')
self.assertEqual([r.address for r in email.recipients], ['python-projects@logilab.org'])
self.assertEqual([r.address for r in email.cc], [])
self.assertEqual(email.in_thread[0].title, '[Python-projects] Pylint: Disable-msg for a block or statement?')
self.assertEqual(sorted([(f.data_name, f.data_format) for f in email.attachment]),
[(u'astng.patch', u'text/x-diff'), (u'pylint.patch', u'text/x-diff')])
assert not self.vreg.schema['parts'].inlined
self.assertEquals(len(self.execute('Any P WHERE E parts P, E eid %s'%email.eid)), 2)
self.assertEquals(len(email.parts), 2)
self.assertEqual(len(self.execute('Any P WHERE E parts P, E eid %s'%email.eid)), 2)
self.assertEqual(len(email.parts), 2)
part1, part2 = email.parts_in_order()
self.assertEquals(part1.content_format,'text/plain')
self.assertEquals(part2.content_format,'text/plain')
self.assertEquals(part2.content, '''_______________________________________________
self.assertEqual(part1.content_format,'text/plain')
self.assertEqual(part2.content_format,'text/plain')
self.assertEqual(part2.content, '''_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects''')
email = rset.get_entity(1, 0)
self.assertEquals(email.subject, '[Python-projects] pylint: False positive about field initialisation')
self.assertEquals(email.sender[0].address, 'maarten.ter.huurne@philips.com')
self.assertEquals(email.sender[0].alias, 'Maarten ter Huurne')
self.assertEquals([r.address for r in email.recipients], ['python-projects@lists.logilab.org'])
self.assertEquals([r.address for r in email.cc], [])
self.assertEquals(email.in_thread[0].title, '[Python-projects] pylint: False positive about field initialisation')
self.assertEquals([(f.data_name, f.data_format) for f in email.attachment], [])
self.assertEquals(len(email.parts), 3)
self.assertEquals(sorted([r.content_format for r in email.parts]), [u'text/html', u'text/plain', u'text/plain'])
self.assertEqual(email.subject, '[Python-projects] pylint: False positive about field initialisation')
self.assertEqual(email.sender[0].address, 'maarten.ter.huurne@philips.com')
self.assertEqual(email.sender[0].alias, 'Maarten ter Huurne')
self.assertEqual([r.address for r in email.recipients], ['python-projects@lists.logilab.org'])
self.assertEqual([r.address for r in email.cc], [])
self.assertEqual(email.in_thread[0].title, '[Python-projects] pylint: False positive about field initialisation')
self.assertEqual([(f.data_name, f.data_format) for f in email.attachment], [])
self.assertEqual(len(email.parts), 3)
self.assertEqual(sorted([r.content_format for r in email.parts]), [u'text/html', u'text/plain', u'text/plain'])
part1, part2 = email.parts_in_order()
self.assertEquals(part1.content_format,'text/html')
self.assertEquals(part2.content_format,'text/plain')
self.assertEquals(part2.content, '''_______________________________________________
self.assertEqual(part1.content_format,'text/html')
self.assertEqual(part2.content_format,'text/plain')
self.assertEqual(part2.content, '''_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects''')
part1, part2 = email.parts_in_order('text/plain')
self.assertEquals(part1.content_format,'text/plain')
self.assertEquals(part2.content_format,'text/plain')
self.assertEqual(part1.content_format,'text/plain')
self.assertEqual(part2.content_format,'text/plain')
NOSUBJECT = """
......@@ -177,38 +177,38 @@ http://lists.logilab.org/mailman/listinfo/python-projects
mi = MBOXImporter(self.cnx)
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
rset = self.execute('Any X ORDERBY S WHERE X is Email, X subject S')
self.assertEquals(len(rset), 1)
self.assertEqual(len(rset), 1)
email = rset.get_entity(0, 0)
self.assertEquals(email.subject, '(no subject)')
self.assertEquals(email.references(), set(('<xxx@blabla>',)))
self.assertEqual(email.subject, '(no subject)')
self.assertEqual(email.references(), set(('<xxx@blabla>',)))
def test_double_import(self):
mi = MBOXImporter(self.cnx)
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
rset = self.execute('Any X ORDERBY S WHERE X is Email, X subject S')
self.assertEquals(len(rset), 1)
self.assertEqual(len(rset), 1)
def test_address_detection(self):
# test both case normalization and canonicalization of email address
eid1 = self.execute('INSERT EmailAddress X: X address "maarten.ter.huurne@philips.com"')[0][0]
eid2 = self.execute('INSERT EmailAddress X: X address "maarten@philips.com"')[0][0]
self.execute('SET X prefered_form Y WHERE X eid %s, Y eid %s' % (eid1, eid2))
#self.assertEquals(env.vreg.schema['identical_to'].symetric, True)
#self.assertEqual(env.vreg.schema['identical_to'].symetric, True)
#ea1 = cursor.execute('Any X WHERE X eid %s' % eid2).get_entity(0, None)
#self.assertEquals(ea1.canonical, True)
#self.assertEqual(ea1.canonical, True)
#testrset = cursor.execute('Any X WHERE X canonical FALSE')
#self.assertEquals(testrset[0][0], eid1)
#self.assertEqual(testrset[0][0], eid1)
#testrset = cursor.execute('Any X WHERE X canonical TRUE')
#self.assertEquals(testrset[0][0], eid2)
#self.assertEqual(testrset[0][0], eid2)
#testrset = cursor.execute('Any X WHERE X identical_to Y, X canonical TRUE, Y eid %(y)s', {'y': eid1})
#self.assertEquals(testrset[0][0], eid2)
#self.assertEqual(testrset[0][0], eid2)
mi = MBOXImporter(self.cnx)
mi.import_mbox_stream(StringIO(self.NOSUBJECT))
rset = self.execute('Any X ORDERBY S WHERE X is Email, X subject S')
self.assertEquals(len(rset), 1)
self.assertEqual(len(rset), 1)
email = rset.get_entity(0, 0)
self.assertEquals(email.sender[0].address, 'maarten@philips.com')
self.assertEqual(email.sender[0].address, 'maarten@philips.com')
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment