def test_serialize(self): hdr = Header(None) hdr.version = "1.0" serialized_data = {} hdr.serialize(serialized_data) expected_data = { "header": { "version": "1.0", } } self.assertEqual(serialized_data, expected_data)
def test_version(self): hdr = Header(None) # empty version hdr.version = None self.assertRaises(TypeError, hdr.validate) # invalid version hdr.version = "first" self.assertRaises(ValueError, hdr.validate) hdr.version = "1.alpha2" self.assertRaises(ValueError, hdr.validate) hdr.version = "1" self.assertRaises(ValueError, hdr.validate) # valid version hdr.version = "1.22" hdr.validate()
def test_serialize(self): hdr = Header(None, "productmd.header") hdr.version = "1.0" serialized_data = {} hdr.serialize(serialized_data) expected_data = { "header": { "type": "productmd.header", "version": "1.2", } } self.assertEqual(serialized_data, expected_data)