def test_view_class(self): """test various methods of instantiation and properties""" ddoc = DesignDocument(mock.Mock(), "_design/tests") view1 = View(ddoc, "view1", map_func=self.map_func, reduce_func=self.reduce_func) view2 = View(ddoc, "view2", map_func=self.map_func) view3 = View(ddoc, "view1", map_func=Code(self.map_func), reduce_func=Code(self.reduce_func)) view4 = View(ddoc, "view1", map_func=Code(self.map_func)) self.assertEqual(view1.map, Code(self.map_func)) self.assertEqual(view1.reduce, Code(self.reduce_func)) self.assertEqual(view2.map, Code(self.map_func)) self.assertEqual(view2.reduce, None) self.assertEqual(view3.map, Code(self.map_func)) self.assertEqual(view3.reduce, Code(self.reduce_func)) self.assertEqual(view4.map, Code(self.map_func)) self.assertEqual(view4.reduce, None) view5 = View(ddoc, "view5") self.assertEqual(view5.map, None) self.assertEqual(view5.reduce, None) view5.map = self.map_func self.assertEqual(view5.map, Code(self.map_func)) view5.reduce = self.reduce_func self.assertEqual(view5.reduce, Code(self.reduce_func))
def test_reduce_setter(self): """ Test that the reduce setter works """ ddoc = DesignDocument(self.db, 'ddoc001') view = View(ddoc, 'view001') self.assertIsNone(view.get('reduce')) view.reduce = '_count' self.assertEqual(view.get('reduce'), '_count')
def test_reduce_setter(self): """ Test that the reduce setter works """ ddoc = DesignDocument(self.db, "ddoc001") view = View(ddoc, "view001") self.assertIsNone(view.get("reduce")) view.reduce = "_count" self.assertEqual(view.get("reduce"), "_count")
def test_reduce_getter(self): """ Test that the reduce getter works """ ddoc = DesignDocument(self.db, 'ddoc001') view = View(ddoc, 'view001') self.assertIsNone(view.reduce) view.reduce = '_count' self.assertIsInstance(view.reduce, Code) self.assertEqual(view.reduce, '_count')
def test_reduce_getter(self): """ Test that the reduce getter works """ ddoc = DesignDocument(self.db, "ddoc001") view = View(ddoc, "view001") self.assertIsNone(view.reduce) view.reduce = "_count" self.assertIsInstance(view.reduce, Code) self.assertEqual(view.reduce, "_count")