[glom] Added a test which makes sure adding fields in an existing table is working



commit 5167cd1368670717fbec2ad1fb08fa2360e2abec
Author: Armin Burgmeier <armin arbur net>
Date:   Tue Jun 30 23:00:50 2009 +0200

    Added a test which makes sure adding fields in an existing table is working
    
    	* ldtp/fields-edit/fields-edit.py: Added a new test which tests adding
    	a new field to an existing table. More operations to test, such as
    	changing and removing existing fields, can be added later.
    
    	* ldtp/fields-edit/postgres-central.xml:
    	* ldtp/fields-edit/postgres-self.xml:
    	* ldtp/fields-edit/sqlite.xml: XML Data files for the new test.
    
    	* ldtp/test.xml: Added it to the test suite, so that it can be run
    	with ldtprunner.

 ChangeLog                             |   13 +++++
 ldtp/.gitignore                       |    5 ++
 ldtp/fields-edit/fields-edit.py       |   94 +++++++++++++++++++++++++++++++++
 ldtp/fields-edit/postgres-central.xml |    3 +
 ldtp/fields-edit/postgres-self.xml    |    3 +
 ldtp/fields-edit/sqlite.xml           |    3 +
 ldtp/test.xml                         |   17 ++++++
 7 files changed, 138 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ae53c87..b6220d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-09-30  Armin Burgmeier  <armin openismus com>
+
+	* ldtp/fields-edit/fields-edit.py: Added a new test which tests adding
+	a new field to an existing table. More operations to test, such as
+	changing and removing existing fields, can be added later.
+
+	* ldtp/fields-edit/postgres-central.xml:
+	* ldtp/fields-edit/postgres-self.xml:
+	* ldtp/fields-edit/sqlite.xml: XML Data files for the new test.
+
+	* ldtp/test.xml: Added it to the test suite, so that it can be run
+	with ldtprunner.
+
 2009-06-28  Armin Burgmeier  <armin openismus com>
 
 	* ldtp/database-templates/SQLite:
diff --git a/ldtp/.gitignore b/ldtp/.gitignore
new file mode 100644
index 0000000..775dabc
--- /dev/null
+++ b/ldtp/.gitignore
@@ -0,0 +1,5 @@
+common.pyc
+central-info.xml
+core
+glom-test-log.xml
+TestDatabase
diff --git a/ldtp/fields-edit/fields-edit.py b/ldtp/fields-edit/fields-edit.py
new file mode 100755
index 0000000..ee279a5
--- /dev/null
+++ b/ldtp/fields-edit/fields-edit.py
@@ -0,0 +1,94 @@
+#!/usr/bin/python
+from ldtp import *
+from ldtputils import *
+
+sys.path = ['..'] + ['.'] + sys.path
+import common
+
+import os
+import shutil
+
+try:
+	# Load data XML from command line when called directly:
+	if sys.argv[0].find('ldtprunner') == -1 and len(sys.argv) > 1:
+		datafilename = sys.argv[1]
+
+	parser = LdtpDataFileParser(datafilename)
+	backend = parser.gettagvalue('backend')
+
+	if len(backend) == 0:
+		raise LdtpExecutionError('<backend> tag not set in "' + datafilename + '"')
+
+	backend = backend[0]
+
+	# Create a test database
+	common.create_test_database(backend)
+
+	# Launch Glom
+	common.launch_glom()
+
+	# Select the Test database file (TestDatabase/Test.glom)
+	selectrow(common.initial_dialog, 'ttblOpenExistingDocument', 'Select File')
+	click(common.initial_dialog, 'btnSelect')
+
+	filechooser = 'Choose a glom file to open'
+	if waittillguiexist(filechooser) == 0:
+		raise LdtpExceutionError('The file chooser did not appear.')
+
+	# Descend into the TestDatabase directory:
+	doubleclickrow(filechooser, 'tblFiles', 'TestDatabase')
+
+	# Select the .glom file:
+	selectrow(filechooser, 'tblFiles', 'Test.glom')
+
+	# Acknowledge the dialog
+	click(filechooser, 'btnOpen')
+	
+	# Enter the connection credentials for the centrally hosted database:
+	common.enter_connection_credentials(backend)
+
+	# Wait until the database has been created:
+	common.wait_for_database_open()
+
+	# Go in Developer mode:
+	selectmenuitem(common.main_window, 'mnuUserLevel;mnuDeveloper')
+
+	# Open the Fields dialog:
+	selectmenuitem(common.main_window, 'mnuFields')
+
+	field_definitions = 'Field Definitions'
+	if waittillguiexist(field_definitions) == 0:
+		raise LdtpExecutionError('Field Definitions dialog did not appear.')
+
+	# Add a new field:
+	click(field_definitions, 'btnAdd')
+
+	# Give it a name:
+	generatekeyevent('test_field<enter>')
+
+	# TODO: Check if an error dialog pops up
+
+	click(field_definitions, 'btnClose')
+
+	# TODO: Check that changing fields and removing fields works as well
+
+	# Exit the application.
+	common.exit_glom()
+
+	# Wait a few seconds to give Glom time to close the database connection
+	# before attempting to remove it:
+	wait(2)
+
+	# Delete the test database
+	common.delete_test_database(backend)
+
+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
+	common.delete_test_database(backend)
+
+	raise LdtpExecutionError (msg)
+	# TODO: Terminate the Glom application
+	# os.kill(whatpid?, signal.SIGTERM)
diff --git a/ldtp/fields-edit/postgres-central.xml b/ldtp/fields-edit/postgres-central.xml
new file mode 100644
index 0000000..97f2938
--- /dev/null
+++ b/ldtp/fields-edit/postgres-central.xml
@@ -0,0 +1,3 @@
+<data>
+	<backend>PostgresCentral</backend>
+</data>
diff --git a/ldtp/fields-edit/postgres-self.xml b/ldtp/fields-edit/postgres-self.xml
new file mode 100644
index 0000000..6d7c7e7
--- /dev/null
+++ b/ldtp/fields-edit/postgres-self.xml
@@ -0,0 +1,3 @@
+<data>
+	<backend>PostgresSelf</backend>
+</data>
diff --git a/ldtp/fields-edit/sqlite.xml b/ldtp/fields-edit/sqlite.xml
new file mode 100644
index 0000000..b241149
--- /dev/null
+++ b/ldtp/fields-edit/sqlite.xml
@@ -0,0 +1,3 @@
+<data>
+	<backend>SQLite</backend>
+</data>
diff --git a/ldtp/test.xml b/ldtp/test.xml
index fd189cf..8594225 100644
--- a/ldtp/test.xml
+++ b/ldtp/test.xml
@@ -3,6 +3,23 @@
 	<logfile>glom-test-log.xml</logfile>
 
 	<group>
+		<testcaseid>fields-edit</testcaseid>
+		<comment>Test whether table fields can be edited without problems for all available backends</comment>
+
+<!--		<script>
+			<name>fields-edit/fields-edit.py</name>
+			<data>fields-edit/postgres-self.xml</data>
+		</script> -->
+		<script>
+			<name>fields-edit/fields-edit.py</name>
+			<data>fields-edit/postgres-central.xml</data>
+		</script>
+		<script>
+			<name>fields-edit/fields-edit.py</name>
+			<data>fields-edit/sqlite.xml</data>
+		</script>
+	</group>
+	<group>
 		<testcaseid>database-creation</testcaseid>
 		<comment>Test whether creation of a new database work for all available backends</comment>
 



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