Source

hydra / apps / all_docs / tests / test_views.py

Full commit
import unittest
ViewTestCase = require('lib/tests/helpers')['ViewTestCase']

class AllDocsTestCase(ViewTestCase):

    func_name = 'all_docs'

    def should_emit(self):
        doc = {'_id': 'foo', '_rev': 'bar'}
        result = self.mapfun(doc)
        self.assertEqual(result, [['foo', {'rev': 'bar'}]])

    def should_require_doc_id_and_rev(self):
        self.assertRaises(Exception, self.mapfun, {'_rev': 'bar'})
        self.assertRaises(Exception, self.mapfun, {'_id': 'foo'})
        self.assertRaises(Exception, self.mapfun, {'foo': 'bar'})



suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(AllDocsTestCase, prefix='should'))

exports['suite'] = suite