[glom] Use data XML files to specify the backend to test



commit 8faca2badbf78280d7c8324655694af4c49a1c31
Author: Armin Burgmeier <armin arbur net>
Date:   Sat Jun 20 16:19:02 2009 +0200

    Use data XML files to specify the backend to test
    
    2009-06-20  Armin Burgmeier  <armin openismus com>
    
    	* ldtp/database-creation/create-db.py: Read the data what backend to
    	use from the a data XML file, instead of as a function's argument.
    
    	* ldtp/database-creation/self-hosted.py:
    	* ldtp/database-creation/sqlite.py: So we don't need these anymore.
    
    	* ldtp/database-creation/postgres-self.xml:
    	* ldtp/database-creation/sqlite.xml: Instead, the data is specified in
    	these data XML files.
    
    	* ldtp/test.xml: Adapt accordingly.

 ChangeLog                                |   14 +++
 ldtp/database-creation/create-db.py      |  134 ++++++++++++++++++++++++++++++
 ldtp/database-creation/create_db.py      |  128 ----------------------------
 ldtp/database-creation/postgres-self.xml |    5 +
 ldtp/database-creation/self-hosted.py    |   10 --
 ldtp/database-creation/sqlite.py         |   13 ---
 ldtp/database-creation/sqlite.xml        |    5 +
 ldtp/test.xml                            |    8 ++-
 po/Makefile.in.in                        |    4 +-
 9 files changed, 166 insertions(+), 155 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 55e9194..64173b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-06-20  Armin Burgmeier  <armin openismus com>
+
+	* ldtp/database-creation/create-db.py: Read the data what backend to
+	use from the a data XML file, instead of as a function's argument.
+
+	* ldtp/database-creation/self-hosted.py:
+	* ldtp/database-creation/sqlite.py: So we don't need these anymore.
+
+	* ldtp/database-creation/postgres-self.xml:
+	* ldtp/database-creation/sqlite.xml: Instead, the data is specified in
+	these data XML files.
+
+	* ldtp/test.xml: Adapt accordingly.
+
 2009-06-17  Armin Burgmeier  <armin openismus com>
 
 	* ldtp/README: Added a README file explaining how to run the tests.
diff --git a/ldtp/database-creation/create-db.py b/ldtp/database-creation/create-db.py
new file mode 100755
index 0000000..0a7dcc6
--- /dev/null
+++ b/ldtp/database-creation/create-db.py
@@ -0,0 +1,134 @@
+#!/usr/bin/python
+from ldtp import *
+from ldtputils import *
+
+sys.path = ['..'] + sys.path
+import common
+
+import os
+import shutil
+import threading
+
+#class BackendUnavailableError (Exception):
+#	def __str__ (self):
+#		return 'Backend not available'
+
+# TODO: Avoid these being global variables:
+errorMessage = ''
+errorHappened = threading.Event()
+errorHappened.clear()
+
+def error_cb():
+	global errorMessage
+	# We already stop at the first error that occurs
+	if not errorHappened.isSet():
+		# TODO: Read the actual error message from the error
+		# dialog window:
+		errorMessage = 'Failed to create new database'
+		errorHappened.set()
+
+try:
+	xml = LdtpDataFileParser(datafilename)
+	backend = xml.gettagvalue('backend')[0]
+	button_texts = xml.gettagvalue('button_text')
+
+	common.launch_glom()
+
+	# Create a new document from the Small Business Example:
+	# The notebook and treeview widgets are accessed via their
+	# "accessible name". It can be set in Glade on the Accessibility tab,
+	# or in code via widget->get_accessible()->set_name("").
+	# It is meant to be a human-readable, translatable string describing
+	# the widget. To access the widget in LDTP, all spaces are removed
+	# from that string, so "Create New Document" becomes
+	# "CreateNewDocument". Each widget type also has an (optional, I
+	# believe) prefix, for example notebooks are prefixed by 'ptl' and
+	# treeviews are prefixed by 'ttbl'.
+	selecttab(common.initial_dialog, 'ptlOpenorcreateDocument', 'Create New Document')
+	selectrow(common.initial_dialog, 'ttblCreateNewDocument', 'Small Business Example')
+
+	# Buttons (prefix: 'btn') are addressed via their label text:
+	click(common.initial_dialog, 'btnSelect')
+
+	# Create a directory into which to create the new Glom document:
+	if not os.path.exists('TestDatabase'):
+		os.mkdir('TestDatabase')
+
+	# Wait for the file chooser dialog to appear:
+	if waittillguiexist('Creating From Example File') == 0:
+		raise LdtpExecutionError('File chooser does not show up')
+
+	# Navigate into the newly created folder:
+	doubleclickrow('Creating From Example File', 'tblFiles', 'TestDatabase')
+
+	# Call the new document 'Test':
+	settextvalue('Creating From Example File', 'txtName', 'Test');
+
+	# Make sure we use the self-hosted postgresql backend:
+	for text in button_texts:
+		if objectexist('Creating From Example File', 'rbtn' + text):
+			click('Creating From Example File', 'rbtn' + text)
+			break
+	else:
+		raise LdtpExecutionError('Backend ' + backend + ' not supported')
+
+	# Make sure the Glom main window still exists
+	if not guiexist(common.main_window):
+		raise LdtpExecutionError('The Glom main window does not exist anymore')
+
+	# Be notified when error dialogs pop up during database creation
+	onwindowcreate('Warning', error_cb)
+	onwindowcreate('Error', error_cb)
+
+	# Acknowledge the dialog:
+	click('Creating From Example File', 'btnSave')
+
+	# Wait for the list view to pop up in the main Glom window:
+	# Note that the Window title of the Glom Window changes when the file
+	# has loaded. If we use wildcards for the Window title (*Glom*) here,
+	# then objectexist does not find the notebook_data
+	# (ptlListOrDetailsView) widget, even when it has actually appeared.
+	# TODO: Maybe we can use setcontext(), to avoid this.
+	# TODO: Or maybe this has been fixed in LDTP in the meanwhile,
+	# see bug #583021.
+	while not guiexist('Glom-SmallBusinessExample') or not objectexist('Glom-SmallBusinessExample', 'ptlListOrDetailsView'):
+		if errorHappened.isSet():
+			raise LdtpExecutionError(errorMessage)
+		# Wait a bit and then try again:
+		wait()
+
+	# Everything finished, so check the created database for consistency.
+	if(getrowcount(common.main_window, 'tblTableContent') != 9):
+		raise LdtpExecutionError("Newly created database does not contain all 8 rows"); # Note there is one placeholder row
+
+	selecttab(common.main_window, 'ptlListOrDetailsView', 'Details')
+
+	# TODO: Check that there is an image present.
+	# Accerciser shows the Image Size for the widget which we may use to
+	# check this. However, LDTP does not implement this yet.
+
+	# Exit the application. Here, the wildcard *Glom* works again. I
+	# suppose this is because the menu already existed when we used the
+	# Wildcard for the first time, in contrast to the notebook_data.
+	selectmenuitem(common.main_window, 'mnuFile;mnuClose')
+
+	if waittillguinotexist('Glom-SmallBusinessExample') == 0:
+		raise LdtpExecutionError('The Glom Window does not disappear after closing the application')
+
+	# Wait until Glom has cleaned up everything, so that removing the 
+	# test database is going to work.
+	wait(2)
+
+	# Remove the test database again
+       	shutil.rmtree('TestDatabase')
+
+except LdtpExecutionError, msg:
+	log(msg, 'fail')
+
+	# Remove the created directory also on error, so that the test
+	# does not fail because of the database already existing next time
+	shutil.rmtree('TestDatabase')
+
+        raise LdtpExecutionError (msg)
+        # TODO: Terminate the Glom application
+	# os.kill(whatpid?, signal.SIGTERM)
diff --git a/ldtp/database-creation/postgres-self.xml b/ldtp/database-creation/postgres-self.xml
new file mode 100644
index 0000000..6598191
--- /dev/null
+++ b/ldtp/database-creation/postgres-self.xml
@@ -0,0 +1,5 @@
+<data>
+	<backend>Postgres Self-Hosted</backend>
+	<button_text>CreatePostgreSQLdatabaseinitsownfolder,tobehostedbythiscomputer.</button_text>
+	<button_text>Createdatabaseinitsownfolder,tobehostedbythiscomputer.</button_text>
+</data>
diff --git a/ldtp/database-creation/sqlite.xml b/ldtp/database-creation/sqlite.xml
new file mode 100644
index 0000000..83a0b4c
--- /dev/null
+++ b/ldtp/database-creation/sqlite.xml
@@ -0,0 +1,5 @@
+<data>
+	<backend>SQLite</backend>
+	<button_text>CreateSQLitedatabaseinitsownfolder,tobehostedbythiscomputer.</button_text>
+	<button_text>Createdatabaseinitsownfolder,tobehostedbythiscomputer,usingSQLite.</button_text>
+</data>
diff --git a/ldtp/test.xml b/ldtp/test.xml
index 9edfa18..44d12b0 100644
--- a/ldtp/test.xml
+++ b/ldtp/test.xml
@@ -6,8 +6,12 @@
 		<testcaseid>database-creation</testcaseid>
 		<comment>Test whether creation of a new database work for all available backends</comment>
 		<script>
-			<name>database-creation/self-hosted.py</name>
-			<name>database-creation/sqlite.py</name>
+			<name>database-creation/create-db.py</name>
+			<data>database-creation/postgres-self.xml</data>
+		</script>
+		<script>
+			<name>database-creation/create-db.py</name>
+			<data>database-creation/sqlite.xml</data>
 		</script>
 	</group>
 
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index 57ef267..c7e8302 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -21,7 +21,7 @@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
 PACKAGE = @PACKAGE@
 VERSION = @VERSION@
 
-SHELL = /bin/sh
+SHELL = @SHELL@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
@@ -56,7 +56,7 @@ ALL_LINGUAS = @ALL_LINGUAS@
 
 PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; else echo "$(ALL_LINGUAS)"; fi)
 
-USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep ^$$lang$$ $(srcdir)/LINGUAS 2>/dev/null`" -o -n "`echo $$ALINGUAS|tr ' ' '\n'|grep ^$$lang$$`"; then printf "$$lang "; fi; done; fi)
+USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep '^$$lang$$' $(srcdir)/LINGUAS 2>/dev/null`" -o -n "`echo $$ALINGUAS|tr ' ' '\n'|grep '^$$lang$$'`"; then printf "$$lang "; fi; done; fi)
 
 USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)" -o -n "$(LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done)
 



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