예제 #1
0
 def test_unicode_serialize(self):
     """
     UnicodeAttribute.serialize
     """
     attr = UnicodeAttribute()
     assert attr.serialize('foo') == 'foo'
     assert attr.serialize('') is None
     assert attr.serialize(None) is None
예제 #2
0
 def test_unicode_serialize(self):
     """
     UnicodeAttribute.serialize
     """
     attr = UnicodeAttribute()
     self.assertEqual(attr.serialize('foo'), six.u('foo'))
     self.assertEqual(attr.serialize(u'foo'), six.u('foo'))
     self.assertEqual(attr.serialize(u''), None)
     self.assertEqual(attr.serialize(None), None)
예제 #3
0
 def test_unicode_serialize(self):
     """
     UnicodeAttribute.serialize
     """
     attr = UnicodeAttribute()
     assert attr.serialize('foo') == six.u('foo')
     assert attr.serialize(u'foo') == six.u('foo')
     assert attr.serialize(u'') is None
     assert attr.serialize(None) is None
예제 #4
0
 def test_unicode_serialize(self):
     """
     UnicodeAttribute.serialize
     """
     attr = UnicodeAttribute()
     self.assertEqual(attr.serialize("foo"), six.u("foo"))
     self.assertEqual(attr.serialize(u"foo"), six.u("foo"))
     self.assertEqual(attr.serialize(u""), None)
     self.assertEqual(attr.serialize(None), None)
예제 #5
0
 def serialize(self, value):
     if value not in AGENT_STATUS:
         raise ValueError(
             f"{self.attr_name} must be one of {AGENT_STATUS}, not '{value}'"
         )
     else:
         return UnicodeAttribute.serialize(self, value)
예제 #6
0
 def serialize(self, value):
     if not constants.OccurrenceType.has_value(value):
         raise ValueError(
             f"{self.attr_name} must be one of {constants.OccurrenceType.values()}, not '{value}'"
         )
     else:
         return UnicodeAttribute.serialize(self, value)