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
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)
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
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)
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)
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)