Ejemplo n.º 1
0
 def test_get_field_meta(self):
     """Metadata is always empty for the default implementation."""
     adapter = ItemAdapter(self.item_class())
     self.assertEqual(adapter.get_field_meta("_undefined_"),
                      MappingProxyType({}))
     self.assertEqual(adapter.get_field_meta("name"), MappingProxyType({}))
     self.assertEqual(adapter.get_field_meta("value"), MappingProxyType({}))
Ejemplo n.º 2
0
 def test_metadata_common(self):
     adapter = ItemAdapter(self.item_class())
     self.assertIsInstance(adapter.get_field_meta("name"), MappingProxyType)
     self.assertIsInstance(adapter.get_field_meta("value"),
                           MappingProxyType)
     with self.assertRaises(KeyError):
         adapter.get_field_meta("undefined_field")
Ejemplo n.º 3
0
 def test_get_field_meta(self):
     adapter = ItemAdapter(self.item_class())
     self.assertEqual(adapter.get_field_meta("_undefined_"),
                      MappingProxyType({}))
     self.assertEqual(adapter.get_field_meta("name"),
                      MappingProxyType({"serializer": str}))
     self.assertEqual(adapter.get_field_meta("value"),
                      MappingProxyType({"serializer": int}))
Ejemplo n.º 4
0
 def test_empty_metadata(self):
     adapter = ItemAdapter(self.item_class(name="foo", value=5))
     for field_name in ("name", "value", "undefined_field"):
         self.assertEqual(adapter.get_field_meta(field_name), MappingProxyType({}))