Skip to content

Commit

Permalink
Add Collection.keys() method to get all available book keys
Browse files Browse the repository at this point in the history
  • Loading branch information
letuananh committed Feb 5, 2018
1 parent 2e911e4 commit 0e34339
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions freebible/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def add_book(self, book):
self.books.append(book)
return book

def keys(self):
''' Get a list of all available book keys (short names ) '''
return [b.short_name for b in self]

def summarise(self):
cc = sum(len(b) for b in self)
cv = sum(b.verse_count() for b in self.books)
Expand Down
2 changes: 2 additions & 0 deletions test/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_parse_kougo(self):
self.assertEqual(len(bible), 66)
self.assertEqual(cc, 1189)
self.assertEqual(cv, 31105)
self.assertEqual(len(bible.keys()), 66)


class TestWEBParser(unittest.TestCase):
Expand All @@ -88,6 +89,7 @@ def test_read_web(self):
self.assertEqual(len(bible), 66)
self.assertEqual(cc, 1189)
self.assertEqual(cv, 31102)
self.assertEqual(len(bible.keys()), 66)


class TestCrossCheck(unittest.TestCase):
Expand Down

0 comments on commit 0e34339

Please sign in to comment.