From 536888019ce4b4209730b2e8432d418804494813 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 27 Jun 2007 13:06:46 +0000
Subject: [PATCH] test Telephone|Fax.asText add test for Telephone as Urls
 (commented out)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15012 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testERP5HR.py | 36 ++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/product/ERP5/tests/testERP5HR.py b/product/ERP5/tests/testERP5HR.py
index e274730f73..06e86fe5f3 100644
--- a/product/ERP5/tests/testERP5HR.py
+++ b/product/ERP5/tests/testERP5HR.py
@@ -50,6 +50,9 @@ os.environ['EVENT_LOG_SEVERITY'] = '-300'
 class TestHR(ERP5TypeTestCase):
   """
     ERP5 Human Ressources related tests. 
+
+  XXX actually this test suite tests person and organisation subcontent,
+  properties and acquisition, but not really HR.
   """
 
   # pseudo constants
@@ -803,6 +806,7 @@ class TestHR(ERP5TypeTestCase):
     sequence_list.addSequenceString(sequence_string)
     sequence_list.play(self, quiet=quiet)
 
+  # Dates
   def test_05_DatesOnPerson(self, quiet=QUIET, run=RUN_ALL_TEST):
     """Tests dates on Person objects.
     """
@@ -832,6 +836,38 @@ class TestHR(ERP5TypeTestCase):
                         getattr(org.getCreationDate(), slot)(),
                         'Wrong creation date %s' % org.getCreationDate())
 
+
+  def test_TelephoneAsText(self):
+    # Test asText method
+    pers = self.getPersonModule().newContent(portal_type='Person')
+    tel = pers.newContent(portal_type='Telephone')
+    tel.setTelephoneCountry(33)
+    tel.setTelephoneNumber(123456789)
+    self.assertEquals('+33(0)-123456789', tel.asText())
+
+## TODO: Telephone must be a subclass of Url
+##
+##  def test_TelephoneUrl(self):
+##    # http://www.rfc-editor.org/rfc/rfc3966.txt
+##    pers = self.getPersonModule().newContent(portal_type='Person')
+##    tel = pers.newContent(portal_type='Telephone')
+##    tel.setTelephoneCountry(33)
+##    tel.setTelephoneNumber(123456789)
+##    self.assertEquals('tel:+33-123456789', tel.asURL())
+##
+
+  def test_EmptyTelephoneAsText(self):
+    # asText method returns an empty string for empty telephones
+    pers = self.getPersonModule().newContent(portal_type='Person')
+    self.assertEquals('', pers.newContent(portal_type='Telephone').asText())
+
+
+  def test_EmptyFaxAsText(self):
+    # asText method returns an empty string for empty faxes
+    pers = self.getPersonModule().newContent(portal_type='Person')
+    self.assertEquals('', pers.newContent(portal_type='Fax').asText())
+
+
 if __name__ == '__main__':
   framework()
 else:
-- 
2.30.9