Skip to content

Commit

Permalink
Merge pull request #123 from MPEGGroup/5th-Ed
Browse files Browse the repository at this point in the history
commit to dev
  • Loading branch information
Michael A Dolan authored Jul 6, 2021
2 parents d760170 + 462e2b3 commit c85f97f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion example_patch_base.mpd → example_G21_patch_base.mpd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
minBufferTime="PT1.0S"
profiles="urn:mpeg:dash:profile:isoff-live:2011">

<PatchLocation ttl="60">live-stream/patch.mpd?publishTime=2020-05-13T05%3A34%3A06%2B00%3A00</PatchLocation>
<PatchLocation ttl="60">example_G21_patch.mpp?publishTime=2020-05-13T05%3A34%3A06%2B00%3A00</PatchLocation>

<Period id="1588435200" start="PT95725984.571S">
<AdaptationSet
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lxml==4.6.3
requests==2.25.1
43 changes: 34 additions & 9 deletions tests/validate.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
"""
MPD valication tests.
MPD validation tests.
"""

import sys
import unittest
import logging
import glob
import requests
from lxml import etree

class TestStringMethods(unittest.TestCase):

class PrefixResolver(etree.Resolver):
# https://lxml.de/resolvers.html
def __init__(self, prefix):
self.prefix = prefix.lower()

def resolve(self, url, pubid, context):
if url.lower().startswith(self.prefix):
res=requests.get(url, allow_redirects=True)
return self.resolve_string(res.text, context)


class TestDASH(unittest.TestCase):
def setUp(self):
self.log = logging.getLogger('TestLog')
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
parser=etree.XMLParser(load_dtd=True, huge_tree=True, resolve_entities=True)
with open('../DASH-MPD.xsd', 'r') as schema_file:
self.mpd_schema = etree.XMLSchema(etree.parse(schema_file, parser))
logging.basicConfig(stream=sys.stderr, level=logging.INFO)
self.parser=etree.XMLParser(load_dtd=True, no_network=False, huge_tree=True, resolve_entities=True)
self.parser.resolvers.add(PrefixResolver("https"))
self.parser.resolvers.add(PrefixResolver("http"))

def test_mpds(self):
""" Test all MPDs found in the repository."""
with open('../DASH-MPD.xsd', 'r') as schema_file:
mpd_schema = etree.XMLSchema( etree.parse(schema_file, self.parser) )
for mpd_path in glob.glob('../*.mpd'):
self.log.debug('Validating %s', mpd_path)
self.log.info('Validating %s', mpd_path)
with open(mpd_path) as mpd_file:
with self.subTest(mpd=mpd_path):
mpd = etree.parse(mpd_file)
self.mpd_schema.assertValid(mpd)
mpd_schema.assertValid( etree.parse(mpd_file) )


def test_mpps(self):
""" Test all MPPs found in the repository."""
with open('../DASH-MPD-PATCH.xsd', 'r') as mpp_schema_file:
mpp_schema = etree.XMLSchema( etree.parse(mpp_schema_file, self.parser) )
for mpp_path in glob.glob('../*.mpp'):
self.log.info('Validating %s', mpp_path)
with open(mpp_path) as mpp_file:
with self.subTest(mpp=mpp_path):
mpp_schema.assertValid( etree.parse(mpp_file) )

if __name__ == '__main__':
unittest.main()

0 comments on commit c85f97f

Please sign in to comment.