Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] r57834 - in /branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite: t4-bad-params t5-params
  • From: mvidner@xxxxxxxxxxxxxxxx
  • Date: Thu, 02 Jul 2009 07:52:10 -0000
  • Message-id: <E1MMH5W-0005LY-Vq@xxxxxxxxxxxxxxxx>
Author: mvidner
Date: Thu Jul 2 09:52:10 2009
New Revision: 57834

URL: http://svn.opensuse.org/viewcvs/yast?rev=57834&view=rev
Log:
more test cases

Added:

branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params
(with props)

branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t5-params
(with props)

Added:
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params?rev=57834&view=auto
==============================================================================
---
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params
(added)
+++
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params
Thu Jul 2 09:52:10 2009
@@ -0,0 +1,44 @@
+#! /usr/bin/python
+# test various kinds of parameter errors
+# -bad param type
+#TODO for other cases:
+# - unknown namespace
+# object not found
+# etc, check y2errors
+import dbus
+import unittest
+
+class BadParams(unittest.TestCase):
+ def setUp(self):
+ T_o = dbus.SessionBus().get_object('org.opensuse.YaST.modules',
+ '/org/opensuse/YaST/modules/TEST')
+ self.T = dbus.Interface(T_o, 'org.opensuse.YaST.Values')
+ self.YT = dbus.Interface(T_o, 'org.opensuse.YaST.YCPValues')
+
+ def testRawMissingParam(self):
+ self.assertRaises(Exception, self.T.ParamMap)
+
+ def testRawTypeMismatch(self):
+ self.assertRaises(Exception, self.T.ParamMap, "I am a string, not a map")
+
+ def testRawSuperfluousParam(self):
+ self.assertRaises(Exception, self.T.ParamMap, {"foo":"bar"}, "I am
superfluous")
+
+ def testBsvNil(self):
+ "type is required even for nil, dubious"
+ self.assertRaises(Exception, self.YT.ParamMap, (True, "", 0))
+
+ def testBsvTypeRequired(self):
+ self.assertRaises(Exception, self.YT.ParamMap, (False, "", 0))
+
+ def testBsvUnknownType(self):
+ self.assertRaises(Exception, self.YT.ParamMap, (False, "ufo", 0))
+
+ def testBsvUnimplementedType(self):
+ self.assertRaises(Exception, self.YT.ParamMap, (False, "byteblock", 0))
+
+ def testBsvTypeMismatch(self):
+ self.assertRaises(Exception, self.YT.ParamMap, (False, "string", 42))
+
+if __name__ == '__main__':
+ unittest.main()

Added:
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t5-params
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t5-params?rev=57834&view=auto
==============================================================================
---
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t5-params
(added)
+++
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t5-params
Thu Jul 2 09:52:10 2009
@@ -0,0 +1,74 @@
+#! /usr/bin/python
+import dbus
+import unittest
+
+# define representative values of various types, named after their signatures
+b42 = True
+y42 = 42
+n42 = 4200
+q42 = 42000
+i42 = 2100000000
+u42 = 4200000000
+x42 = 4200000000000000000
+t42 = 18000000000000000000
+# ^ E P T G M K
+d42 = 4.2
+s42 = "fortytwo"
+o42 = "/Forty/Two"
+g42 = "tatastavi"
+
+b = True
+y = dbus.Byte(y42)
+n = dbus.Int16(n42)
+q = dbus.UInt16(q42)
+i = dbus.Int32(i42)
+# TODO make them big enough
+u = dbus.UInt32(u42)
+x = dbus.Int64(x42)
+t = dbus.UInt64(t42) # too big for YCP
+d = dbus.Double(d42)
+s = dbus.String(s42)
+o = dbus.ObjectPath(o42)
+g = dbus.Signature(g42)
+#v, a
+
+class ParamPassing(unittest.TestCase):
+
+ def setUp(self):
+ T_o = dbus.SessionBus().get_object('org.opensuse.YaST.modules',
+ '/org/opensuse/YaST/modules/TEST')
+ self.T = dbus.Interface(T_o, 'org.opensuse.YaST.Values')
+# self.YT = dbus.Interface(T_o, 'org.opensuse.YaST.YCPValues')
+
+ def testByte(self):
+ self.assertEqual(self.T.ParamInteger(y), y42)
+
+ def testInt16(self):
+ self.assertEqual(self.T.ParamInteger(n), n42)
+
+ def testUInt16(self):
+ self.assertEqual(self.T.ParamInteger(q), q42)
+
+ def testInt32(self):
+ self.assertEqual(self.T.ParamInteger(i), i42)
+
+ def testUInt32(self):
+ self.assertEqual(self.T.ParamInteger(u), u42)
+
+ def testInt64(self):
+ self.assertEqual(self.T.ParamInteger(x), x42)
+
+# python says: OverflowError: long too big to convert
+# def testUInt64(self):
+# self.assertEqual(self.T.ParamInteger(t), t42)
+
+ def testDouble(self):
+ self.assertEqual(self.T.ParamFloat(d), d42)
+
+ def testString(self):
+ self.assertEqual(self.T.ParamString(s), s42)
+
+
+
+if __name__ == '__main__':
+ unittest.main()

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages