From 681aa1d1413faa49bcaa9c943d14a9ff81e31bbe Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 23 Oct 2008 17:07:53 +0000 Subject: [PATCH] Proper Unitest this time bzr-revno: 33 --- openlp/database/test/testBibleManager.py | 47 ++++++++++++++++-------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/openlp/database/test/testBibleManager.py b/openlp/database/test/testBibleManager.py index 091f4e30b..0822f476f 100644 --- a/openlp/database/test/testBibleManager.py +++ b/openlp/database/test/testBibleManager.py @@ -1,3 +1,6 @@ +import random +import unittest + import os, os.path import sys mypath=os.path.split(os.path.abspath(__file__))[0] @@ -5,18 +8,32 @@ sys.path.insert(0,(os.path.join(mypath, '..', '..','..'))) from openlp.database.BibleManager import * -bm = BibleManager() -print bm -print bm.getBibles() -b = bm.getBibles() -for b1 in b: - print b1 -print bm.getBibleBooks("NIV") -c = bm.getBibleBooks("NIV") -for c1 in c: - print c1 -print bm.getBookVerseCount("NIV", "GEN", 1) -print bm.getVerseText("NIV", "GEN",1,1,1) -c = bm.getVerseText("NIV","GEN",1,2,1) -for c1 in c: - print c1 +class TestBibleManager(unittest.TestCase): + + def setUp(self): + self.bm = BibleManager() + + def testGetBibles(self): + # make sure the shuffled sequence does not lose any elements + b = self.bm.getBibles() + for b1 in b: + print b1 + self.assert_(b1 in b) + + def testGetBooks(self): + c = self.bm.getBibleBooks("NIV") + for c1 in c: + print c1 + self.assert_(c1 in c) + + def testGetBooks(self): + self.failUnless(self.bm.getBookVerseCount("NIV", "GEN", 1) == 28, "Wrong Book Count") + + def testGetVerseText(self): + c = self.bm.getVerseText("NIV","GEN",1,2,1) + for c1 in c: + print c1 + self.assert_(c1 in c) + +if __name__ == '__main__': + unittest.main()