commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7268 - trunk/gnue-common/tests


From: jamest
Subject: [gnue] r7268 - trunk/gnue-common/tests
Date: Sun, 27 Mar 2005 21:25:34 -0600 (CST)

Author: jamest
Date: 2005-03-27 21:25:32 -0600 (Sun, 27 Mar 2005)
New Revision: 7268

Added:
   trunk/gnue-common/tests/apps_checktype.py
   trunk/gnue-common/tests/formatting_masks.py
   trunk/gnue-common/tests/utils_TextUtils.py
Removed:
   trunk/gnue-common/tests/common_apps_checktype.py
   trunk/gnue-common/tests/common_utils_TextUtils.py
Log:
remove common_ from the test names
added start of the format mask unittest


Copied: trunk/gnue-common/tests/apps_checktype.py (from rev 7264, 
trunk/gnue-common/tests/common_apps_checktype.py)

Deleted: trunk/gnue-common/tests/common_apps_checktype.py
===================================================================
--- trunk/gnue-common/tests/common_apps_checktype.py    2005-03-28 00:27:06 UTC 
(rev 7267)
+++ trunk/gnue-common/tests/common_apps_checktype.py    2005-03-28 03:25:32 UTC 
(rev 7268)
@@ -1,130 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# FILE:
-# TextUtils.py
-#
-# DESCRIPTION:
-# Test cases for TextUtils.py module
-#
-# NOTES:
-#
-
-import unittest
-from gnue.common.apps.checktype import *
-
-class ChecktypeTestCase(unittest.TestCase):
-  def setUp(self):
-    self.n = None
-    self.s = 'this is a string'
-    self.u = u'this is a unicode string'
-    self.i = 100
-    self.f = 17.85
-    class p:
-      pass
-    class c (p):
-      pass
-    self.p = p
-    self.c = c
-    self.o = c ()
-
-  def testSingleTypesSuccess(self):
-    """Check single types works properly"""
-    checktype (self.n, NoneType)
-    checktype (self.s, StringType)
-    checktype (self.u, UnicodeType)
-    checktype (self.i, IntType)
-    checktype (self.f, FloatType)
-    checktype (self.c, ClassType)
-    checktype (self.o, InstanceType)
-    checktype (self.o, self.c)
-    checktype (self.o, self.p)
-  
-  def testMultipleTypesSuccess(self):
-    """Check multiple types works properly"""
-    checktype (self.n, [StringType, NoneType])
-    checktype (self.s, [StringType, UnicodeType])
-    checktype (self.u, [StringType, UnicodeType])
-    checktype (self.o, [NoneType, self.c])
-
-  def testSingleTypeFailure(self):
-    try:
-      checktype (self.n, StringType)
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-      
-    try:
-      checktype (self.s, UnicodeType)
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-    
-    try:
-      checktype (self.u, StringType)
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-    
-    try:
-      checktype (self.i, FloatType)
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-    
-    try:
-      checktype (self.o, IntType)
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-    
-    try:
-      checktype (self.c, self.c)
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-
-      
-  def testMultipleTypeFailure(self):
-    try:
-     checktype (self.n, [StringType, UnicodeType])
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-      
-    try:
-      checktype (self.s, [IntType, FloatType])
-    except TypeError:
-      pass
-    else:
-      self.fail('expected a TypeError')
-    
-def suite():
-  suite = unittest.makeSuite(ChecktypeTestCase,'test')
-  
-if __name__ == "__main__":
-  unittest.main()
\ No newline at end of file

Deleted: trunk/gnue-common/tests/common_utils_TextUtils.py
===================================================================
--- trunk/gnue-common/tests/common_utils_TextUtils.py   2005-03-28 00:27:06 UTC 
(rev 7267)
+++ trunk/gnue-common/tests/common_utils_TextUtils.py   2005-03-28 03:25:32 UTC 
(rev 7268)
@@ -1,56 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# FILE:
-# TextUtils.py
-#
-# DESCRIPTION:
-# Test cases for TextUtils.py module
-#
-# NOTES:
-#
-
-import unittest
-from gnue.common.utils.TextUtils import *
-
-class TextTestCase(unittest.TestCase):
-  def setUp(self):
-    self.shortText="Hello"
-    self.longText="This is a longer line used to test the line wrap.  This is 
only a test"
-
-  def testLineWrap(self):
-    """Check that the basic line wrap function properly wraps lines"""
-    output = lineWrap(self.longText,27)
-    expectedResult = 'This is a longer line \nused to test the line \nwrap.  
This is only a test\n'
-    assert output == expectedResult, 'line wrapped incorrectly'
-    
-  def testLineWrapAlignment(self):
-    """Check that line wrap function properly deals with alignment requests"""
-    expectedResultRight = '     This is a longer line \n     used to test the 
line \n wrap.  This is only a test\n'
-    expectedResultCenter = '  This is a longer line \n  used to test the line 
\nwrap.  This is only a test\n'
-    
-    assert lineWrap(self.longText, 27, alignment=ALIGN_RIGHT) == 
expectedResultRight, 'right alignment incorrect'
-    assert lineWrap(self.longText, 27, alignment=ALIGN_CENTER) == 
expectedResultCenter, 'center alignment incorrect'
-    
-def suite():
-  suite = unittest.makeSuite(TextTestCase,'test')
-
-if __name__ == "__main__":
-  unittest.main()
\ No newline at end of file

Added: trunk/gnue-common/tests/formatting_masks.py
===================================================================
--- trunk/gnue-common/tests/formatting_masks.py 2005-03-28 00:27:06 UTC (rev 
7267)
+++ trunk/gnue-common/tests/formatting_masks.py 2005-03-28 03:25:32 UTC (rev 
7268)
@@ -0,0 +1,114 @@
+import locale, unittest
+locale.setlocale(locale.LC_ALL,'')
+
+from gnue.common.formatting.masks.Masks import InputMask
+
+class TextTestCase(unittest.TestCase):
+
+  def testCharacterMasks(self):
+    """Check that character mask properpy formats text input"""
+    
+    # List of tuples containing ('mask', result, input)    
+    testInputs = [ ['A\-AAAAA\-AAA', '_-_____-___', ''],
+                   ['A\-AAAAA\-AAA', '1-_____-___', '1'],
+                   ['A\-AAAAA\-AAA', '1-2____-___', '12'],
+                   ['A\-AAAAA\-AAA', '1-23___-___', '123'],
+                   ['A\-AAAAA\-AAA', '1-234__-___', '1234'],
+                   ['A\-AAAAA\-AAA', '1-23456-789', '123456789'],
+                 ]
+
+    for test in testInputs:
+      maskText, result, input = test
+      mask = InputMask(maskText)
+      mask.begin()      
+      output, cursor = mask._parseInput(newtext = '%s' % input)
+      assert output == result, 'text mask failure for input %s' % input
+
+  def testDateMasks(self):
+    """Check that character mask properpy formats date input"""
+    
+    # List of tuples containing ('mask', result, input)    
+    testInputs = [ ['"Date:" M/D/y', 'Date: __/__/__', ''],
+                   ['"Date:" M/D/y', 'Date: 1_/__/__', '1'],
+                   ['"Date:" M/D/y', 'Date: 12/__/__', '12'],
+                   ['"Date:" M/D/y', 'Date: 12/3_/__', '123'],
+                   ['"Date:" M/D/y', 'Date: 12/03/4_', '1234'],
+                   ['"Date:" M/D/y', 'Date: 12/03/45', '12345'],
+                   ['"Date:" M/D/y', 'Date: 09/09/99', '9999'],
+                 ]
+
+    for test in testInputs:
+      maskText, result, input = test
+      mask = InputMask(maskText)
+      mask.begin()      
+      output, cursor = mask._parseInput(newtext = '%s' % input)
+      assert output == result, 'date mask failure.\nINPUT: %s\nOUTPUT: 
%s\nEXPECTED: %s' % (input,output,result)
+
+# =============================================================================
+# Test numeric mask
+# =============================================================================
+#m='\\$###,##0!.00'
+#mask = InputMask(m)
+#print "Mask: %s" % m
+#
+#for f in ('','1','12','123','1234','12345','9999'):
+#  mask.begin()
+#  print string.ljust("Input: '%s'" % f, 18),
+#  output, cursor = mask._parseInput(newtext='%s'%f)
+#  print "Output: " + formatOutput(output, cursor)
+
+def suite():
+  suite = unittest.makeSuite(TextTestCase,'test')
+
+if __name__ == "__main__":
+  unittest.main()
+  
+
+
+
+exit
+# =============================================================================
+# Test cursor positioning
+# =============================================================================
+
+# Commands:
+#  < Left arrow
+#  > right arrow
+#  { delete left
+#  } delete right
+#  ^ Home
+#  v End
+#    Anything else: As is
+##t = "9311<<^v"
+##
+##output, cursor = mask.begin()
+##print "Init: " + formatOutput(output, cursor)
+##
+##for c in t:
+##  print "-----------"
+##  if c == "<":
+##    print string.ljust("Left.", 18),
+##    output, cursor = mask.moveLeft()
+##  elif c == '>':
+##    print string.ljust("Right.", 18),
+##    output, cursor = mask.moveRight()
+##  elif c == '^':
+##    print string.ljust("Home.", 18),
+##    output, cursor = mask.moveHome()
+##  elif c == 'v':
+##    print string.ljust("End.", 18),
+##    output, cursor = mask.moveEnd()
+##  elif c == '{':
+##    print string.ljust("Backspace.", 18),
+##    output, cursor = mask.backspace()
+##  elif c == '}':
+##    print string.ljust("Delete.", 18),
+##    output, cursor = mask.delete()
+##  else:
+##    print string.ljust("Type char %s" % c, 18),
+##    output, cursor = mask.add(c)
+##
+##  print "Output: " + formatOutput(output, cursor)
+##
+##
+

Copied: trunk/gnue-common/tests/utils_TextUtils.py (from rev 7264, 
trunk/gnue-common/tests/common_utils_TextUtils.py)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]