class MediaBackendTest(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.client = MediaBackend().configured_login(config_dir=os.path.dirname(__file__)).env(ENV).debug() def test_xml_to_bytes_string(self): self.assertEquals("<a xmlns='urn:vpro:media:update:2009' />", self.client.xml_to_bytes("<a xmlns='urn:vpro:media:update:2009' />").decode("utf-8")) def test_xml_to_bytes_minidom(self): self.assertEquals('<a xmlns="urn:vpro:media:update:2009"/>', self.client.xml_to_bytes( minidom.parseString("<a xmlns='urn:vpro:media:update:2009' />").documentElement).decode( "utf-8")) def test_append_params(self): self.assertEquals("http://vpro.nl?a=a&x=y", self.client.append_params("http://vpro.nl", include_errors=False, a="a", x="y")) def test_set_duration(self): existing = poms.CreateFromDocument(self.client.get("WO_VPRO_1422026")) existing.duration = "PT30M" self.client.post(existing) def test_get_locations(self): bytes=self.client.get_locations("POMS_VPRO_1421796") locations=poms.CreateFromDocument(bytes) print(str(locations)) def test_get_segments(self): bytes = self.client.get("RBX_AT_2145721") existing = mediaupdate.CreateFromDocument(bytes) self.assertTrue(type(existing) == mediaupdate.segmentUpdateType) def test_get_images(self): mid="POMS_VPRO_1421796" media=poms.CreateFromDocument(self.client.get(mid)) print(len(media.images.image)) image=media.images.image[0] bytes = self.client.get_images("POMS_VPRO_1421796") images= poms.CreateFromDocument(bytes) image2=images.wildcardElements()[0] self.assertEquals(image.title, image2.title) self.assertEquals(image2.title, "sdf") print(image2.toxml()) def test_set_location(self): mid = "POMS_VPRO_1421796" self.client.set_location(mid, "http://www.vpro.nl/123", publishStop="2012-01-11T17:16:01.287Z") def test_set_location_by_id(self): mid = "POMS_VPRO_1421796" self.client.set_location(mid, 58758190, publishStop="2012-01-11T17:16:01.287Z") def test_set_location_by_id_as_string(self): mid = "POMS_VPRO_1421796" self.client.set_location(mid, "58758190", publishStop="2013-01-11T17:16:01.287Z") def test_set_location_by_urn(self): mid = "POMS_VPRO_1421796" self.client.set_location(mid, "urn:vpro:media:location:58758190", publishStop="2014-01-11T17:16:01.287Z") def test_create_location(self): mid = "POMS_VPRO_1421796" self.client.set_location(mid, "http://www.vpro.nl/" + str(round(time.time())) + ".mp3", publishStop="2012-01-11T17:16:01.287Z")