Exemplo n.º 1
0
 def create(self, formatName):
     if formatName == 'json':
         return JsonFormat(self.dependencies)
     if formatName == 'xml':
         return XmlFormat(self.dependencies)
     if formatName == 'narrated':
         return NarratedFormat()
     if formatName == 'simple':
         return SimpleFormat()
     if formatName == 'dict':
         return DictFormat()
     if formatName == 'object':
         return ObjectFormat()
     if formatName == 'picture':
         return PictureCache(self.dependencies)
     raise ValueError('Unknown format: ' + str(formatName))
Exemplo n.º 2
0
 def test_serialize_item_returns_its_prov(self):
     from niprov.formatdict import DictFormat
     form = DictFormat(self.dependencies)
     out = form.serializeSingle(self.aFile())
     self.assertEqual({'a': 'b'}, out)
Exemplo n.º 3
0
 def test_serialize_item_returns_its_prov(self):
     from niprov.formatdict import DictFormat
     form = DictFormat(self.dependencies)
     out = form.serializeSingle(self.aFile())
     self.assertEqual({'a':'b'}, out)
Exemplo n.º 4
0
 def test_serialize_list_returns_its_provs(self):
     from niprov.formatdict import DictFormat
     form = DictFormat(self.dependencies)
     out = form.serializeList([self.aFile(), self.aFile(), self.aFile()])
     self.assertEqual([{'a': 'b'}, {'a': 'b'}, {'a': 'b'}], out)
Exemplo n.º 5
0
 def test_serialize_list_returns_its_provs(self):
     from niprov.formatdict import DictFormat
     form = DictFormat(self.dependencies)
     out = form.serializeList([self.aFile(), self.aFile(), self.aFile()])
     self.assertEqual([{'a':'b'},{'a':'b'},{'a':'b'}], out)