Пример #1
0
 def testDataToData(self):
     raw_data = "something"
     s = ExpandedDataNodeSerializer(data={'contents': raw_data},
                                    context={
                                        'type': 'string',
                                        'request': get_mock_request()
                                    })
     s.is_valid(raise_exception=True)
     s.save()
     self.assertEqual(s.data['contents']['value'], raw_data)
Пример #2
0
 def testCreateEmptyList(self):
     s = ExpandedDataNodeSerializer(data={'contents': []},
                                    context={'type': 'string'})
     s.is_valid(raise_exception=True)
     m = s.save()
     data = ExpandedDataNodeSerializer(m, context=get_mock_context()).data
     self.assertEqual(data['contents'], [])
Пример #3
0
 def testCreateDict(self):
     raw_data = {'type': 'integer', 'value': 3}
     s = ExpandedDataNodeSerializer(data={'contents': raw_data},
                                    context={'type': 'integer'})
     s.is_valid(raise_exception=True)
     m = s.save()
     data = ExpandedDataNodeSerializer(m, context=get_mock_context()).data
     self.assertEqual(data['contents']['value'], raw_data['value'])
Пример #4
0
 def testCreateList(self):
     raw_data = ['word', 'draw']
     s = ExpandedDataNodeSerializer(data={'contents': raw_data},
                                    context={'type': 'string'})
     s.is_valid(raise_exception=True)
     m = s.save()
     data = ExpandedDataNodeSerializer(m, context=get_mock_context()).data
     self.assertEqual(data['contents'][0]['value'], raw_data[0])