Esempio n. 1
0
 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)
Esempio n. 2
0
    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()
Esempio n. 3
0
 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)
Esempio n. 4
0
    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()
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)