def test_ignore_underscore_values(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.assertFalse( '__name__' in serialize_to_json(self.portal.doc1) ) self.assertFalse( 'manage_options' in serialize_to_json(self.portal.doc1) )
def test_serialize_title(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.assertEqual( serialize_to_json(self.portal.doc1).get('title'), 'Doc 1' )
def test_serialize_datetime(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.portal.doc1.setEffectiveDate(DateTime('2014/04/04')) self.assertEqual( serialize_to_json(self.portal.doc1).get('effective'), '2014-04-04T00:00:00' )
def test_serialize_description(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.portal.doc1.description = u'Lorem Ipsum' self.assertEqual( serialize_to_json(self.portal.doc1).get('description'), 'Lorem Ipsum')
def test_serialize_description(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.portal.doc1.description = u'Lorem Ipsum' self.assertEqual( serialize_to_json(self.portal.doc1).get('description'), 'Lorem Ipsum' )
def test_serialize_rich_text(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.portal.doc1.text = RichTextValue(u"Lorem ipsum.", 'text/plain', 'text/html') self.assertEqual( serialize_to_json(self.portal.doc1).get('text'), u'<p>Lorem ipsum.</p>')
def test_serialize_rich_text(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.portal.doc1.text = RichTextValue( u"Lorem ipsum.", 'text/plain', 'text/html' ) self.assertEqual( serialize_to_json(self.portal.doc1).get('text'), u'<p>Lorem ipsum.</p>' )
def __call__(self): portal = getSite() path = self.request.get('path') if not path: return { 'code': '404', 'message': "No path has been provided.", } path = '/'.join(portal.getPhysicalPath()) + '/' + path try: obj = portal.restrictedTraverse(path) except KeyError: return { 'code': '404', 'message': "No object found for path '%s'." % path, } result = serialize_to_json(obj) result['route'] = path return result
def test_ignore_underscore_values(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.assertFalse('__name__' in serialize_to_json(self.portal.doc1)) self.assertFalse( 'manage_options' in serialize_to_json(self.portal.doc1))
def test_serialize_datetime(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.portal.doc1.setEffectiveDate(DateTime('2014/04/04')) self.assertEqual( serialize_to_json(self.portal.doc1).get('effective'), '2014-04-04T00:00:00')
def test_serialize_title(self): self.portal.invokeFactory('Document', id='doc1', title='Doc 1') self.assertEqual( serialize_to_json(self.portal.doc1).get('title'), 'Doc 1')