def test_count(self): # The 'count' property of a collection is the number of elements in # the collection. collection = GenericGitCollection(self.store) self.assertEqual(0, collection.count()) for i in range(3): self.factory.makeGitRepository() self.assertEqual(3, collection.count())
def test_count_respects_filter(self): # If a collection is a subset of all possible repositories, then the # count will be the size of that subset. That is, 'count' respects # any filters that are applied. repository = self.factory.makeGitRepository() self.factory.makeGitRepository() collection = GenericGitCollection( self.store, [GitRepository.project == repository.target]) self.assertEqual(1, collection.count())