From 56afb5bca98c9dcd076aebf9839c83fd7094cc9a Mon Sep 17 00:00:00 2001 From: romjerome Date: Wed, 7 Aug 2019 20:47:09 +0200 Subject: [PATCH] Add missing 'get_number_of_citations' method (#859) * Add missing 'get_number_of_citations' method * update db test for bsddb * fix trailing whitespace * typo --- gramps/gen/db/dummydb.py | 10 +++++++++- gramps/plugins/db/bsddb/test/db_test.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gramps/gen/db/dummydb.py b/gramps/gen/db/dummydb.py index 89c93ab69..2efec5f93 100644 --- a/gramps/gen/db/dummydb.py +++ b/gramps/gen/db/dummydb.py @@ -32,7 +32,7 @@ database to fetch data from). Thus, dbstate.db cannot be left as 'None' because None has no 'is_open' attribute. Therefore this database class is provided so that it can be instantiated for dbstate.db. -FIXME: Ideally, only is_open() needs to be implemented here, bacause that is the +FIXME: Ideally, only is_open() needs to be implemented here, because that is the only method that should really be called, but the Gramps code is not perfect, and many other methods are called. Calls of other methods could be considered bugs, so when these are fixed, this class could be reduced. @@ -757,6 +757,14 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})): LOG.warning("database is closed") return 0 + def get_number_of_citations(self): + """ + Return the number of citations currently in the database. + """ + if not self.db_is_open: + LOG.warning("database is closed") + return 0 + def get_number_of_tags(self): """ Return the number of tags currently in the database. diff --git a/gramps/plugins/db/bsddb/test/db_test.py b/gramps/plugins/db/bsddb/test/db_test.py index 731fcd74a..c6f3139f2 100644 --- a/gramps/plugins/db/bsddb/test/db_test.py +++ b/gramps/plugins/db/bsddb/test/db_test.py @@ -81,6 +81,7 @@ class DbTest(unittest.TestCase): "get_number_of_places", "get_number_of_repositories", "get_number_of_sources", + "get_number_of_citations", "get_number_of_tags", "get_media_from_gramps_id", "get_media_from_handle",