Exemple #1
0
 def test_get_doc_count_by_domain_type(self):
     self.assertEqual(
         get_doc_count_by_domain_type(get_db(None), self.domain1,
                                      'Application'), 1)
     self.assertEqual(
         get_doc_count_by_domain_type(get_db(None), self.domain2,
                                      'Application'), 1)
     self.assertEqual(
         get_doc_count_by_domain_type(get_db(None), 'other', 'Application'),
         0)
     self.assertEqual(
         get_doc_count_by_domain_type(get_db('users'), self.domain1,
                                      'CommCareUser'), 1)
     self.assertEqual(
         get_doc_count_by_domain_type(get_db('users'), self.domain2,
                                      'CommCareUser'), 1)
     self.assertEqual(
         get_doc_count_by_domain_type(get_db('users'), 'other',
                                      'CommCareUser'), 0)
     self.assertEqual(
         get_doc_count_by_domain_type(get_db(None), self.domain1,
                                      'CommCareUser'), 0)
     self.assertEqual(
         get_doc_count_by_domain_type(get_db('users'), self.domain1,
                                      'Application'), 0)
Exemple #2
0
 def test_get_doc_count_by_domain_type(self):
     self.assertEqual(get_doc_count_by_domain_type(get_db(None), self.domain1, 'Application'), 1)
     self.assertEqual(get_doc_count_by_domain_type(get_db(None), self.domain2, 'Application'), 1)
     self.assertEqual(get_doc_count_by_domain_type(get_db(None), 'other', 'Application'), 0)
     self.assertEqual(get_doc_count_by_domain_type(get_db('users'), self.domain1, 'CommCareUser'), 1)
     self.assertEqual(get_doc_count_by_domain_type(get_db('users'), self.domain2, 'CommCareUser'), 1)
     self.assertEqual(get_doc_count_by_domain_type(get_db('users'), 'other', 'CommCareUser'), 0)
     self.assertEqual(get_doc_count_by_domain_type(get_db(None), self.domain1, 'CommCareUser'), 0)
     self.assertEqual(get_doc_count_by_domain_type(get_db('users'), self.domain1, 'Application'), 0)
Exemple #3
0
 def get_total_document_count(self):
     from corehq.dbaccessors.couchapps.all_docs import get_doc_count_by_type, get_doc_count_by_domain_type
     if self.domain:
         return sum(
             get_doc_count_by_domain_type(self.couchdb, self.domain,
                                          doc_type)
             for doc_type in self.doc_type_map)
     else:
         return sum(
             get_doc_count_by_type(self.couchdb, doc_type)
             for doc_type in self.doc_type_map)
Exemple #4
0
 def get_total_document_count(self):
     from corehq.dbaccessors.couchapps.all_docs import get_doc_count_by_type, get_doc_count_by_domain_type
     if self.domain:
         return sum(
             get_doc_count_by_domain_type(self.couchdb, self.domain, doc_type)
             for doc_type in self.doc_type_map
         )
     else:
         return sum(
             get_doc_count_by_type(self.couchdb, doc_type)
             for doc_type in self.doc_type_map
         )
 def _get_couch_doc_count_for_domains(self, domains):
     return sum(
         get_doc_count_by_domain_type(self.couch_db(), domain,
                                      self.couch_doc_type())
         for domain in domains)