hedera-hackers team mailing list archive
-
hedera-hackers team
-
Mailing list archive
-
Message #00000
[Merge] lp:~jamestait/hedera/start-adding-tests into lp:hedera
James Tait has proposed merging lp:~jamestait/hedera/start-adding-tests into lp:hedera.
Requested reviews:
Hedera Hackers (hedera-hackers)
For more details, see:
https://code.launchpad.net/~jamestait/hedera/start-adding-tests/+merge/64243
Start adding the framework for Mozmill tests, in preparation for some heavy refactoring.
--
https://code.launchpad.net/~jamestait/hedera/start-adding-tests/+merge/64243
Your team Hedera Hackers is requested to review the proposed merge of lp:~jamestait/hedera/start-adding-tests into lp:hedera.
=== modified file 'README'
--- README 2011-01-06 22:57:00 +0000
+++ README 2011-06-10 19:43:23 +0000
@@ -1,5 +1,12 @@
This is a Thunderbird extension that syncs contacts with a desktop CouchDB
-instance. To build it, run ./build.sh.
-
-In order to see debug output, start Thunderbird with the environment variable
-HEDERA_DEBUG=1 and open the Error Console.
+instance. To build it, run ./build.sh or use debuild to create a Debian
+package.
+
+In order to see debug output, start Thunderbird, click the Hedera statusbar
+icon, select Preferences and check Enable Debug, then open the Error Console.
+
+To run the tests you will need Mozmill. See the section Installing Mozmill here:
+
+ https://developer.mozilla.org/en/Thunderbird/Thunderbird_MozMill_Testing
+
+Then just run ./run_tests.py from your branch directory.
=== modified file 'content/sync.js'
--- content/sync.js 2011-05-11 23:39:04 +0000
+++ content/sync.js 2011-06-10 19:43:23 +0000
@@ -230,7 +230,11 @@
}
};
- Hedera.couch = new CouchDB('contacts');
+ let db_name = 'contacts';
+ if (Hedera.envService.exists('HEDERA_DB')) {
+ db_name = Hedera.envService.get('HEDERA_DB');
+ }
+ Hedera.couch = new CouchDB(db_name);
try {
Hedera.pushCards();
=== added directory 'mozmill'
=== added directory 'mozmill/tests'
=== added file 'mozmill/tests/test_test.js'
--- mozmill/tests/test_test.js 1970-01-01 00:00:00 +0000
+++ mozmill/tests/test_test.js 2011-06-10 19:43:23 +0000
@@ -0,0 +1,15 @@
+const TIMEOUT = 5000;
+
+var setupModule = function(module) {
+ module.controller = mozmill.getMail3PaneController();
+ module.jum = {};
+ Components.utils.import("resource://mozmill/modules/jum.js", module.jum);
+};
+
+var test_pass = function() {
+ jum.assertEquals(TIMEOUT, 5000);
+};
+
+var test_fail = function() {
+ jum.assertEquals(TIMEOUT, 9000);
+};
=== added file 'run_tests.py'
--- run_tests.py 1970-01-01 00:00:00 +0000
+++ run_tests.py 2011-06-10 19:43:23 +0000
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+
+import copy, optparse, os, sys
+
+from desktopcouch.application.server import DesktopDatabase
+
+def parse_cmd_line(parser, all_args):
+ """
+ Parse the command line.
+ """
+ parser.set_usage('Usage: %s [-d db_name]' % all_args[0])
+ parser.add_option('-d', '--db_name', dest='db_name',
+ default='test_contacts', help='The couchdb database name')
+ parser.add_option('-k', '--keep_db', dest='keep_db', default=False,
+ action='store_true')
+ all_args = all_args[1:]
+ return parser.parse_args(all_args)
+
+def check_cmd_line(options, args, error_func):
+ """
+ Check the validity of the command line.
+ Return (db_name, keep_db).
+ """
+ if args:
+ error_func('No args are required.')
+ if options.db_name.strip() == '':
+ error_func('Invalid database name.')
+ return options.db_name, options.keep_db
+
+def main(all_args=None):
+ """The main"""
+ # parse the command line
+ parser = optparse.OptionParser()
+ options, args = parse_cmd_line(parser, all_args)
+ # check it
+ db_name, keep_db = check_cmd_line(options, args, parser.error)
+ # run the tests
+ newenv = os.environ.copy()
+ newenv['HEDERA_DB'] = db_name
+ os.spawnvpe(os.P_WAIT, 'mozmill-thunderbird', ['--show-errors',
+ '--app-arg=-no-remote', '--addons=%s' % os.curdir,
+ '--test=mozmill/tests'], newenv)
+ # now delete the test database, unless asked not to
+ if not keep_db:
+ db = DesktopDatabase(db_name)
+ del db.server[db_name]
+
+if __name__=='__main__':
+ main(all_args=copy.copy(sys.argv))
+