예제 #1
0
    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)
        )
예제 #2
0
    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'
        )
예제 #3
0
 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'
     )
예제 #4
0
    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')
예제 #5
0
    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'
        )
예제 #6
0
    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>')
예제 #7
0
    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>'
        )
예제 #8
0
    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
예제 #9
0
    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
예제 #10
0
    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))
예제 #11
0
 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')
예제 #12
0
    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')