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)
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'], [])
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'])
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])