コード例 #1
0
 def test_pack_unpack_presentationStatus(self):
     STATUSES=[
         ( ["okay"], "okay" ),
         ( ["transitioning"], "transitioning" ),
         ( ["fault"], "fault" ),
         ( ["other"], "other" ),
         ( ["okay", "sub"], "okay sub" ),
         ( ["transitioning", "sub1", "sub2"], "transitioning sub1 sub2" ),
     ]
     for (VALUE, ENCODED) in STATUSES:
         c=CII(presentationStatus=VALUE)
         self.assertEquals(c.presentationStatus, VALUE)
         
         msg=c.pack()
         j=json.loads(msg)
         self.assertEquals(j["presentationStatus"], ENCODED)
         self.assertEquals(len(j.keys()), 1)
         
         d=CII.unpack(msg)
         self.assertEquals(OMIT, d.protocolVersion)
         self.assertEquals(OMIT, d.contentId)
         self.assertEquals(OMIT, d.contentIdStatus)
         self.assertEquals(VALUE, d.presentationStatus)
         self.assertEquals(OMIT, d.mrsUrl)
         self.assertEquals(OMIT, d.wcUrl)
         self.assertEquals(OMIT, d.tsUrl)
         self.assertEquals(OMIT, d.teUrl)
         self.assertEquals(OMIT, d.timelines)
         self.assertEquals(OMIT, d.private)
コード例 #2
0
 def test_pack_unpack_protocolVersion(self):
     c=CII(protocolVersion="1.1")
     self.assertEquals(c.protocolVersion, "1.1")
     
     msg=c.pack()
     j=json.loads(msg)
     self.assertEquals(j["protocolVersion"], "1.1")
     self.assertEquals(len(j.keys()), 1)
     
     d=CII.unpack(msg)
     self.assertEquals("1.1", c.protocolVersion)
     self.assertEquals(OMIT, d.contentId)
     self.assertEquals(OMIT, d.contentIdStatus)
     self.assertEquals(OMIT, d.presentationStatus)
     self.assertEquals(OMIT, d.mrsUrl)
     self.assertEquals(OMIT, d.wcUrl)
     self.assertEquals(OMIT, d.tsUrl)
     self.assertEquals(OMIT, d.teUrl)
     self.assertEquals(OMIT, d.timelines)
     self.assertEquals(OMIT, d.private)
コード例 #3
0
 def test_pack_unpack_contentId(self):
     VALUE="dvb://a.b.c.d"
     c=CII(contentId=VALUE)
     self.assertEquals(c.contentId, VALUE)
     
     msg=c.pack()
     j=json.loads(msg)
     self.assertEquals(j["contentId"], VALUE)
     self.assertEquals(len(j.keys()), 1)
     
     d=CII.unpack(msg)
     self.assertEquals(OMIT, d.protocolVersion)
     self.assertEquals(VALUE, d.contentId)
     self.assertEquals(OMIT, d.contentIdStatus)
     self.assertEquals(OMIT, d.presentationStatus)
     self.assertEquals(OMIT, d.mrsUrl)
     self.assertEquals(OMIT, d.wcUrl)
     self.assertEquals(OMIT, d.tsUrl)
     self.assertEquals(OMIT, d.teUrl)
     self.assertEquals(OMIT, d.timelines)
     self.assertEquals(OMIT, d.private)
コード例 #4
0
 def test_pack_unpack_teUrl(self):
     VALUE="ws://1.2.3.4:5678/seilgr"
     c=CII(teUrl=VALUE)
     self.assertEquals(c.teUrl, VALUE)
     
     msg=c.pack()
     j=json.loads(msg)
     self.assertEquals(j["teUrl"], VALUE)
     self.assertEquals(len(j.keys()), 1)
     
     d=CII.unpack(msg)
     self.assertEquals(OMIT, d.protocolVersion)
     self.assertEquals(OMIT, d.contentId)
     self.assertEquals(OMIT, d.contentIdStatus)
     self.assertEquals(OMIT, d.presentationStatus)
     self.assertEquals(OMIT, d.mrsUrl)
     self.assertEquals(OMIT, d.wcUrl)
     self.assertEquals(OMIT, d.tsUrl)
     self.assertEquals(VALUE, d.teUrl)
     self.assertEquals(OMIT, d.timelines)
     self.assertEquals(OMIT, d.private)
コード例 #5
0
 def test_pack_unpack_mrsUrl(self):
     VALUE="http://blah.com"
     c=CII(mrsUrl=VALUE)
     self.assertEquals(c.mrsUrl, VALUE)
     
     msg=c.pack()
     j=json.loads(msg)
     self.assertEquals(j["mrsUrl"], VALUE)
     self.assertEquals(len(j.keys()), 1)
     
     d=CII.unpack(msg)
     self.assertEquals(OMIT, d.protocolVersion)
     self.assertEquals(OMIT, d.contentId)
     self.assertEquals(OMIT, d.contentIdStatus)
     self.assertEquals(OMIT, d.presentationStatus)
     self.assertEquals(VALUE, d.mrsUrl)
     self.assertEquals(OMIT, d.wcUrl)
     self.assertEquals(OMIT, d.tsUrl)
     self.assertEquals(OMIT, d.teUrl)
     self.assertEquals(OMIT, d.timelines)
     self.assertEquals(OMIT, d.private)
コード例 #6
0
 def test_pack_unpack_contentIdStatus(self):
     for VALUE in ["partial","final"]:
         c=CII(contentIdStatus=VALUE)
         self.assertEquals(c.contentIdStatus, VALUE)
         
         msg=c.pack()
         j=json.loads(msg)
         self.assertEquals(j["contentIdStatus"], VALUE)
         self.assertEquals(len(j.keys()), 1)
         
         d=CII.unpack(msg)
         self.assertEquals(OMIT, d.protocolVersion)
         self.assertEquals(OMIT, d.contentId)
         self.assertEquals(VALUE, d.contentIdStatus)
         self.assertEquals(OMIT, d.presentationStatus)
         self.assertEquals(OMIT, d.mrsUrl)
         self.assertEquals(OMIT, d.wcUrl)
         self.assertEquals(OMIT, d.tsUrl)
         self.assertEquals(OMIT, d.teUrl)
         self.assertEquals(OMIT, d.timelines)
         self.assertEquals(OMIT, d.private)
コード例 #7
0
 def test_pack_empty_message(self):
     c=CII()
     msg=c.pack()
     j=json.loads(msg)
     self.assertEquals(j,{})
コード例 #8
0
 def test_pack_unpack_timelines(self):
     TIMELINES=[
         ( [], [] ),
         ( [ TimelineOption("urn:dvb:css:timeline:pts", 1, 1000, 0.2, OMIT) ],
           [ { "timelineSelector" : "urn:dvb:css:timeline:pts",
               "timelineProperties" : {
                   "unitsPerTick" : 1,
                   "unitsPerSecond" : 1000,
                   "accuracy" : 0.2
               }
             }
           ]
         ),
         ( [ TimelineOption("urn:dvb:css:timeline:pts", 1, 1000, 0.2, OMIT),
             TimelineOption("urn:dvb:css:timeline:temi:1:5", 1001, 30000, OMIT, []),
             TimelineOption("urn:dvb:css:timeline:temi:1:6", 1, 25, OMIT, [{'type':'blah','abc':5},{'type':'bbc','pqr':None}]),
             
           ],
           [ { "timelineSelector" : "urn:dvb:css:timeline:pts",
               "timelineProperties" : {
                   "unitsPerTick" : 1,
                   "unitsPerSecond" : 1000,
                   "accuracy" : 0.2
               }
             },
             { "timelineSelector" : "urn:dvb:css:timeline:temi:1:5",
               "timelineProperties" : {
                   "unitsPerTick" : 1001,
                   "unitsPerSecond" : 30000
               },
               "private" : []
             },
             { "timelineSelector" : "urn:dvb:css:timeline:temi:1:6",
               "timelineProperties" : {
                   "unitsPerTick" : 1,
                   "unitsPerSecond" : 25,
               },
               "private" : [{'type':'blah','abc':5},{'type':'bbc','pqr':None}]
             }
           ]
         ),
     ]
     for (VALUE, ENCODED) in TIMELINES:
         c=CII(timelines=VALUE)
         self.assertEquals(c.timelines, VALUE)
         
         msg=c.pack()
         j=json.loads(msg)
         self.assertEquals(j["timelines"], ENCODED)
         self.assertEquals(len(j.keys()), 1)
         
         d=CII.unpack(msg)
         self.assertEquals(OMIT, d.protocolVersion)
         self.assertEquals(OMIT, d.contentId)
         self.assertEquals(OMIT, d.contentIdStatus)
         self.assertEquals(OMIT, d.presentationStatus)
         self.assertEquals(OMIT, d.mrsUrl)
         self.assertEquals(OMIT, d.wcUrl)
         self.assertEquals(OMIT, d.tsUrl)
         self.assertEquals(OMIT, d.teUrl)
         self.assertEquals(VALUE, d.timelines)
         self.assertEquals(OMIT, d.private)
コード例 #9
0
 def test_pack_presentationStatus_not_a_string(self):
     c=CII(presentationStatus="okay")
     with self.assertRaises(ValueError):
         c.pack()