From 6dd16ba989437b3981b1c9683dc74105d36d1ccc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 10 Dec 2008 19:17:23 +0000 Subject: [PATCH] Wrong directory bzr-revno: 200 --- openlp/plugins/bibles/test/rt | 1 + .../plugins/bibles/test/test_bibleManager.py | 118 ++++++++++++++++++ .../bibles/test/test_bibleManagerAPI.py | 95 ++++++++++++++ .../bibles/test/test_bibleManagerCSV.py | 61 +++++++++ .../bibles/test/test_bibleManagerOSIS.py | 60 +++++++++ 5 files changed, 335 insertions(+) create mode 100755 openlp/plugins/bibles/test/rt create mode 100644 openlp/plugins/bibles/test/test_bibleManager.py create mode 100644 openlp/plugins/bibles/test/test_bibleManagerAPI.py create mode 100644 openlp/plugins/bibles/test/test_bibleManagerCSV.py create mode 100644 openlp/plugins/bibles/test/test_bibleManagerOSIS.py diff --git a/openlp/plugins/bibles/test/rt b/openlp/plugins/bibles/test/rt new file mode 100755 index 000000000..84998ec9b --- /dev/null +++ b/openlp/plugins/bibles/test/rt @@ -0,0 +1 @@ +py.test --nocapture test_bibleManager.py diff --git a/openlp/plugins/bibles/test/test_bibleManager.py b/openlp/plugins/bibles/test/test_bibleManager.py new file mode 100644 index 000000000..e530d8cac --- /dev/null +++ b/openlp/plugins/bibles/test/test_bibleManager.py @@ -0,0 +1,118 @@ +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008 Martin Thompson, Tim Bentley + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import random +import unittest + +import os, os.path +import sys +mypath=os.path.split(os.path.abspath(__file__))[0] +sys.path.insert(0,(os.path.join(mypath, '..', '..','..','..'))) + +from openlp.plugins.bibles.lib.biblemanager import BibleManager +from openlp.utils import ConfigHelper + +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', + datefmt='%m-%d %H:%M', + filename='plugins.log', + filemode='w') + +console=logging.StreamHandler() +# set a format which is simpler for console use +formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') +# tell the handler to use this format +console.setFormatter(formatter) +logging.getLogger('').addHandler(console) +log=logging.getLogger('') + +logging.info("\nLogging started") + +class TestBibleManager: + log=logging.getLogger("testBibleMgr") + def setup_class(self): + log.debug("\n.......Register BM") + self.bm = BibleManager() + + def testRegisterCSVBibleFiles(self): + # Register a bible from files + log.debug("\n.......testRegisterBibleFiles") + self.bm.registerFileBible("TheMessage",'biblebooks_msg_short.csv','bibleverses_msg_short.csv') + self.bm.registerFileBible("NIV",'biblebooks_niv_short.csv','bibleverses_niv_short.csv') + b = self.bm.getBibles() + for b1 in b: + log.debug( b1) + assert(b1 in b) + + def testRegisterHTTPBible(self): + # Register a bible from files + log.debug( "\n.......testRegisterBibleHTTP") + self.bm.registerHTTPBible("asv","Crosswalk", "", "", "") + self.bm.registerHTTPBible("nasb","Biblegateway", "", "", "") + self.bm.registerHTTPBible("nkj","Biblegateway", "http://tigger2:3128/", "", "") + b = self.bm.getBibles() + for b1 in b: + log.debug( b1) + assert(b1 in b) + + + def testGetBibles(self): + log.debug( "\n.......testGetBibles") + # make sure the shuffled sequence does not lose any elements + b = self.bm.getBibles() + for b1 in b: + log.debug( b1) + assert(b1 in b) + + def testGetBibleBooks(self): + log.debug( "\n.......testGetBibleBooks") + c = self.bm.getBibleBooks("NIV") + for c1 in c: + log.debug( c1) + assert(c1 in c) + + def testGetBookChapterCount(self): + log.debug( "\n.......testGetBookChapterCount") + assert(self.bm.getBookChapterCount("Matthew") == '28') + + def testGetBookVerseCount(self): + log.debug( "\n.......testGetBookVerseCount") + assert(self.bm.getBookVerseCount("Genesis", 1) == '31') + assert(self.bm.getBookVerseCount("Genesis", 2) == '25') + assert(self.bm.getBookVerseCount("Matthew", 1) == '25') + assert(self.bm.getBookVerseCount("Revelation", 1) == '20') + + def testGetVerseText(self): + log.debug( "\n.......testGetVerseText") + #c = self.bm.getVerseText("TheMessage",'Genesis',1,2,1) + #log.debug( c ) + #c = self.bm.getVerseText('NIV','Genesis',1,1,2) + #log.debug( c ) + c = self.bm.getVerseText('asv','Genesis',10,1,20) + log.debug( c ) + c = self.bm.getVerseText('nasb','Genesis',10,1,20) + log.debug( c ) + c = self.bm.getVerseText('nkj','Revelation',10,1,20) + log.debug( c ) + + def testLoadBible(self): + log.debug( "\n.......testLoadBible") + #self.bm.loadBible('asv') + #self.bm.loadBible('nasb') + #self.bm.loadBible('nkj') diff --git a/openlp/plugins/bibles/test/test_bibleManagerAPI.py b/openlp/plugins/bibles/test/test_bibleManagerAPI.py new file mode 100644 index 000000000..ccde98a1e --- /dev/null +++ b/openlp/plugins/bibles/test/test_bibleManagerAPI.py @@ -0,0 +1,95 @@ +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008 Martin Thompson, Tim Bentley + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import random +import unittest + +import os, os.path +import sys +mypath=os.path.split(os.path.abspath(__file__))[0] +sys.path.insert(0,(os.path.join(mypath, '..', '..','..','..'))) + +from openlp.plugins.biblemanager.bibleManager import BibleManager +from openlp.core.utils import ConfigHelper + +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', + datefmt='%m-%d %H:%M', + filename='plugins.log', + filemode='w') + +console=logging.StreamHandler() +# set a format which is simpler for console use +formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') +# tell the handler to use this format +console.setFormatter(formatter) +logging.getLogger('').addHandler(console) +log=logging.getLogger('') + +logging.info("\nLogging started") + +class TestBibleManager: + log=logging.getLogger("testBibleMgr") + def setup_class(self): + log.debug("\n.......Register BM") + self.bm = BibleManager() + + def testGetBibles(self): + log.debug( "\n.......testGetBibles") + # make sure the shuffled sequence does not lose any elements + b = self.bm.getBibles() + for b1 in b: + log.debug( b1) + assert(b1 in b) + + def testGetBibleBooks(self): + log.debug( "\n.......testGetBibleBooks") + c = self.bm.getBibleBooks("asv") + for c1 in c: + log.debug( c1) + assert(c1 in c) + + def testGetBookChapterCount(self): + log.debug( "\n.......testGetBookChapterCount") + assert(self.bm.getBookChapterCount("asv","Matthew")[0] == 28) + + def testGetBookVerseCount(self): + log.debug( "\n.......testGetBookVerseCount") + assert(self.bm.getBookVerseCount("asv","Genesis", 1)[0] == 31) + assert(self.bm.getBookVerseCount("TheMessage","Genesis", 2)[0] == 25) + assert(self.bm.getBookVerseCount("asv","Matthew", 1)[0] == 25) + assert(self.bm.getBookVerseCount("TheMessage","Revelation", 1)[0] == 20) + + def testGetVerseText(self): + log.debug( "\n.......testGetVerseText") + #c = self.bm.getVerseText("TheMessage",'Genesis',1,2,1) + #log.debug( c ) + #c = self.bm.getVerseText('NIV','Genesis',1,1,2) + #log.debug( c ) + c = self.bm.getVerseText('asv','Genesis',10,1,20) + log.debug( c ) + c = self.bm.getVerseText('TheMessage','Genesis',10,1,20) + log.debug( c ) + c = self.bm.getVerseText('asv','Revelation',10,1,20) + log.debug( c ) + c = self.bm.getVersesFromText("asv", "Jesus wept") + log.debug( c ) + c = self.bm.getVersesFromText("TheMessage", "Jesus wept") + log.debug( c ) + diff --git a/openlp/plugins/bibles/test/test_bibleManagerCSV.py b/openlp/plugins/bibles/test/test_bibleManagerCSV.py new file mode 100644 index 000000000..03d8ea7b7 --- /dev/null +++ b/openlp/plugins/bibles/test/test_bibleManagerCSV.py @@ -0,0 +1,61 @@ +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008 Martin Thompson, Tim Bentley + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import random +import unittest + +import os, os.path +import sys +mypath=os.path.split(os.path.abspath(__file__))[0] +sys.path.insert(0,(os.path.join(mypath, '..', '..','..','..'))) + +from openlp.plugins.bibles.lib.biblemanager import BibleManager +from openlp.utils import ConfigHelper + +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', + datefmt='%m-%d %H:%M', + filename='plugins.log', + filemode='w') + +console=logging.StreamHandler() +# set a format which is simpler for console use +formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') +# tell the handler to use this format +console.setFormatter(formatter) +logging.getLogger('').addHandler(console) +log=logging.getLogger('') + +logging.info("\nLogging started") + +class TestBibleManager: + log=logging.getLogger("testBibleMgr") + def setup_class(self): + log.debug("\n.......Register BM") + self.bm = BibleManager() + + def testRegisterCSVBibleFiles(self): + # Register a bible from files + log.debug("\n.......testRegisterBibleFiles") + self.bm.registerCSVFileBible("TheMessage",'biblebooks_msg_short.csv','bibleverses_msg_short.csv') + self.bm.registerCSVFileBible("NIV",'biblebooks_niv_short.csv','bibleverses_niv_short.csv') + b = self.bm.getBibles() + for b1 in b: + log.debug( b1) + assert(b1 in b) diff --git a/openlp/plugins/bibles/test/test_bibleManagerOSIS.py b/openlp/plugins/bibles/test/test_bibleManagerOSIS.py new file mode 100644 index 000000000..8689f9a76 --- /dev/null +++ b/openlp/plugins/bibles/test/test_bibleManagerOSIS.py @@ -0,0 +1,60 @@ +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008 Martin Thompson, Tim Bentley + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import random +import unittest + +import os, os.path +import sys +mypath=os.path.split(os.path.abspath(__file__))[0] +sys.path.insert(0,(os.path.join(mypath, '..', '..','..','..'))) + +from openlp.plugins.bibles.lib.biblemanager import BibleManager +from openlp.utils import ConfigHelper + +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', + datefmt='%m-%d %H:%M', + filename='plugins.log', + filemode='w') + +console=logging.StreamHandler() +# set a format which is simpler for console use +formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') +# tell the handler to use this format +console.setFormatter(formatter) +logging.getLogger('').addHandler(console) +log=logging.getLogger('') + +logging.info("\nLogging started") + +class TestBibleManager: + log=logging.getLogger("testBibleMgr") + def setup_class(self): + log.debug("\n.......Register BM") + self.bm = BibleManager() + + def testRegisterOSISBibleFiles(self): + # Register a bible from files + log.debug("\n.......testRegisterOSISBibleFiles") + self.bm.registerOSISFileBible("asv",'asv.osis') + b = self.bm.getBibles() + for b1 in b: + log.debug( b1) + assert(b1 in b)