Example #1
0
    def test_save(self):
        from lumin.node import ContextById
        # Insert item directly into collection
        self.request.db['test'].insert(
            {'_id': 'frobnitz'}, {'title': 'Frobnitz'}
            )

        context = ContextById(self.request, 'frobnitz', 'test')
        context.data.update({'title': 'Frobbozz'})
        context.save()
        history = context.history()
        self.assertEquals(history.count(), 0)
        self.assertRaises(StopIteration, next, history)
        self.assertTrue(context.data['mtime'])
Example #2
0
    def test_update_history(self):
        # Insert item directly into collection
        self.request.db['test'].insert({'_id': 'frobnitz', 'title': ''})

        from lumin.node import ContextById
        context = ContextById(self.request, 'frobnitz', 'test')

        # Update 1
        context.update({'title': 'Frobnitz'})

        # Update 2
        context.update({'title': 'Frobbozz'})

        history = context.history()

        self.assertEqual(history.count(), 2)
        obj = next(history)
        self.assertEqual(obj['title'], 'Frobnitz')
        self.assertNotEqual(obj['mtime'], context.data['mtime'])
        #import pdb; pdb.set_trace()
        self.assertEqual(next(history)['title'], '')
        self.assertEqual(context.data['title'], 'Frobbozz')