summaryrefslogtreecommitdiff
path: root/sw/qa/python
diff options
context:
space:
mode:
authorkadertarlan <kadertarlan1@gmail.com>2016-01-28 15:24:49 +0200
committerjan iversen <jani@documentfoundation.org>2016-01-30 07:42:31 +0000
commitba1d44bec1f85f45a23e7b871e3344ee457e8eac (patch)
treef0cce107db772059997ab6f518c13c25613a662c /sw/qa/python
parent13d4398820ded5914f635757865e258db2db2b57 (diff)
tdf#97362: Convert Java unit test to Python (check_named_property_values.py)
Change-Id: Icb94cdf3601d6d985ea147e3c80eadba2999ccee Reviewed-on: https://gerrit.libreoffice.org/21877 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'sw/qa/python')
-rw-r--r--sw/qa/python/check_named_property_values.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/sw/qa/python/check_named_property_values.py b/sw/qa/python/check_named_property_values.py
index 9d7825b392e8..2859699744f6 100644
--- a/sw/qa/python/check_named_property_values.py
+++ b/sw/qa/python/check_named_property_values.py
@@ -24,6 +24,9 @@ from org.libreoffice.unotest import UnoInProcess
from com.sun.star.beans import PropertyValue
from com.sun.star.container import XNameContainer
from org.libreoffice.unotest import OfficeConnection
+from com.sun.star.container import ElementExistException
+from com.sun.star.lang import IllegalArgumentException
+from com.sun.star.container import NoSuchElementException
class CheckNamedPropertyValues(unittest.TestCase):
@@ -40,8 +43,8 @@ class CheckNamedPropertyValues(unittest.TestCase):
cls._uno.tearDown()
- def test_checkNamedPropertyValues(self):
-
+ def test_checkNamedPropertyValues(self):
+
xServiceManager = self.xContext.ServiceManager
xCont = xServiceManager.createInstanceWithContext('com.sun.star.document.NamedPropertyValues', self.xContext)
@@ -52,7 +55,7 @@ class CheckNamedPropertyValues(unittest.TestCase):
prop2 = uno.Any("[]com.sun.star.beans.PropertyValue", (p2,))
t = xCont.getElementType()
- self.assertFalse(xCont.hasElements()) #Initial container is not empty
+ self.assertFalse(xCont.hasElements(), "Initial container is not empty")
uno.invoke(xCont, "insertByName", ("prop1", prop1))
ret = xCont["prop1"]
@@ -65,23 +68,23 @@ class CheckNamedPropertyValues(unittest.TestCase):
self.assertEqual(p2.Value, ret[0].Value)
xCont.removeByName("prop1")
- self.assertFalse(xCont.hasElements()) #Could not remove PropertyValue.
+ self.assertFalse(xCont.hasElements(), "Could not remove PropertyValue.")
uno.invoke(xCont, "insertByName", ("prop1", prop1))
uno.invoke(xCont, "insertByName", ("prop2", prop2))
- self.assertTrue(xCont.hasElements()) #Did not insert PropertyValue
+ self.assertTrue(xCont.hasElements(), "Did not insert PropertyValue")
names = xCont.getElementNames()
- self.assertEqual(2, len(names)) #Not all element names were returned
+ self.assertEqual(2, len(names), "Not all element names were returned")
+
for i in range(len(names)):
- self.assertTrue( names[i]=="prop1" or names[i]=="prop2") #Got a wrong element name
+ self.assertIn(names[i], ["prop1", "prop2"], "Got a wrong element name")
- with self.assertRaises(Exception):
+ with self.assertRaises(ElementExistException):
uno.invoke(xCont, "insertByName", ("prop2", prop1))
- with self.assertRaises(Exception):
+ with self.assertRaises(IllegalArgumentException):
uno.invoke(xCont, "insertByName",("prop3", "Example String"))
- with self.assertRaises(Exception):
+ with self.assertRaises(NoSuchElementException):
xCont.removeByName("prop3")
-