Permalink
Browse files

More tests for Node

Filling out more tests for Collection class of node.py
  • Loading branch information...
1 parent 4ef4100 commit cb3e73d47c0d14129d541908faeb4622f96f2367 Josh Finnie committed Nov 20, 2012
Showing with 36 additions and 1 deletion.
  1. +36 −1 lumin/tests/test_node.py
@@ -56,6 +56,10 @@ def _call_fut(self, request=None, name=None):
from lumin.node import Collection
return Collection(request=request, name=name)
+ def _create_collection_by_id(self, _id=0, name="test_name"):
+ from lumin.node import ContextById
+ return ContextById(request=self.request, _id=_id, name=name)
+
def test_ctor_default(self):
result = self._call_fut(request=self.request)
self.assertEquals(result.__name__, None)
@@ -68,7 +72,38 @@ def test_ctor_with_name(self):
self.assertEquals(result._collection.count(), 0)
self.assertEquals(result._collection_history.count(), 0)
- # def test__name__property(self):
+ def test_collection_find(self):
+ result = self._call_fut(request=self.request)
+ self.assertEquals(result.find().count(), 0)
+
+ def test_collection_get(self):
+ data = self._create_collection_by_id()
+
+ result = self._call_fut(request=self.request)
+ self.assertEquals(result.get(_id=0).__name__, data.__name__)
+
+ # TODO - Need to work out MongoMock's handeling of safe...
+ # def test_collection_insert(self):
+ # result = self._call_fut(request=self.request)
+ # result.insert({u'name': u'Foo'}, u'first user')
+ # self.assertEquals(result._collection.count(), 1)
+
+ # TODO - Need to work out MongoMock's handeling of safe...
+ # def test_collection_insert_duplicate_key(self):
+ # result = self._call_fut(request=self.request)
+ # result.insert({u'name': u'Foo'}, u'first user')
+ # result.insert({u'name': u'Bar'}, u'first user')
+ # self.assertRaises(AssertionError)
+
+ # TODO - Need to work out MongoMock's handeling of safe...
+ # def test_collection_delete(self):
+ # result = self._call_fut(request=self.request)
+ # result.insert({u'name': u'Foo'}, u'first user')
+ # result.delete(_id=u'first-user')
+ # self.assertEquals(result._collection.count(), 0)
+
+ def test_collection_save(self): # TODO
+ pass
class TestContextById(unittest.TestCase):

0 comments on commit cb3e73d

Please sign in to comment.