Example #1
0
 def test_lookup_archive_day(self):
     uri = str(ORFLibraryUri(ORFUriType.ARCHIVE_DAY, "oe1", "20140914"))
     result = self.library.lookup(uri)
     self.client_mock.get_day.assert_called_once_with("oe1", "20140914")
     self.assertEqual(len(result), 3)
     self.assertEqual(result[0].type, Ref.DIRECTORY)
     self.assertEqual(result[0].uri, "orfradio:oe1/20140914/1")
     self.assertEqual(result[0].name, "01:00: Item1")
Example #2
0
 def test_lookup_archive_show(self):
     uri = str(
         ORFLibraryUri(ORFUriType.ARCHIVE_SHOW, "oe1", "20140914",
                       "1234567"))
     result = self.library.lookup(uri)
     self.client_mock.get_show.assert_called_once_with(
         "oe1", "20140914", "1234567")
     self.assertEqual(len(result), 3)
     # this test might be wrong:
     self.assertEqual(result[0].uri, "orfradio:oe1/20140914/1234567/1")
     self.assertEqual(result[0].name, "01:00: Item1")
Example #3
0
 def test_browse_station(self):
     uri = str(ORFLibraryUri(ORFUriType.STATION, "oe1"))
     result = self.library.browse(uri)
     self.assertEqual(len(result), 9)
     self.assertEqual(result[0].type, Ref.TRACK)
     self.assertEqual(result[0].uri, "orfradio:oe1/live")
     self.assertEqual(result[0].name, "Ö1 Live")
     self.assertEqual(result[1].type, Ref.DIRECTORY)
     today = datetime.datetime.today().strftime("%Y%m%d")
     self.assertEqual(result[1].uri, f"orfradio:oe1/{today}")
     labeltext = datetime.datetime.today().strftime("%Y-%m-%d %A")
     self.assertEqual(result[1].name, labeltext)
Example #4
0
    def translate_uri(self, uri):
        try:
            library_uri = ORFLibraryUri.parse(uri)
        except InvalidORFUri:
            return None

        if library_uri.uri_type == ORFUriType.LIVE:
            return self.client.get_live_url(library_uri.station)

        if library_uri.uri_type == ORFUriType.ARCHIVE_ITEM:
            return self.client.get_item_url(
                library_uri.station,
                library_uri.shoutcast,
                library_uri.day_id,
                library_uri.show_id,
                library_uri.item_id,
            )
Example #5
0
 def test_create_live_uri(self):
     parsed_uri = ORFLibraryUri(ORFUriType.LIVE, "oe1")
     self.assertEqual(str(parsed_uri), "orfradio:oe1/live")
Example #6
0
 def test_create_station_uri(self):
     parsed_uri = ORFLibraryUri(ORFUriType.STATION, "oe1")
     self.assertEqual(str(parsed_uri), "orfradio:oe1")
Example #7
0
 def test_create_root_uri(self):
     parsed_uri = ORFLibraryUri(ORFUriType.ROOT)
     self.assertEqual(str(parsed_uri), "orfradio:")
Example #8
0
 def test_parse_show_uri(self):
     uri = "orfradio:oe1/20140914/382176"
     result = ORFLibraryUri.parse(uri)
     self.assertEqual(result.uri_type, ORFUriType.ARCHIVE_SHOW)
     self.assertEqual(result.day_id, "20140914")
     self.assertEqual(result.show_id, "382176")
Example #9
0
 def test_parse_day_uri(self):
     uri = "orfradio:oe1/20140914"
     result = ORFLibraryUri.parse(uri)
     self.assertEqual(result.uri_type, ORFUriType.ARCHIVE_DAY)
     self.assertEqual(result.day_id, "20140914")
Example #10
0
 def test_parse_live_uri(self):
     uri = "orfradio:oe1/live"
     result = ORFLibraryUri.parse(uri)
     self.assertEqual(result.uri_type, ORFUriType.LIVE)
Example #11
0
 def test_browse_unbrowsable_uri(self):
     uri = str(ORFLibraryUri(ORFUriType.LIVE, "oe1"))
     result = self.library.browse(uri)
     self.assertEqual(result, [])
Example #12
0
 def test_lookup_live(self):
     uri = str(ORFLibraryUri(ORFUriType.LIVE, "oe1"))
     result = self.library.lookup(uri)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].uri, uri)
     self.assertEqual(result[0].name, "Live")
Example #13
0
 def test_browse_unlookable_uri(self):
     uri = str(ORFLibraryUri(ORFUriType.ROOT))
     result = self.library.lookup(uri)
     self.assertEqual(result, [])
Example #14
0
 def test_parse_root_uri(self):
     uri = "orfradio:"
     result = ORFLibraryUri.parse(uri)
     self.assertEqual(result.uri_type, ORFUriType.ROOT)
Example #15
0
 def test_browse_root(self):
     uri = str(ORFLibraryUri(ORFUriType.ROOT))
     result = self.library.browse(uri)
     self.assertEqual(len(result), 2)
Example #16
0
 def test_create_day_uri(self):
     parsed_uri = ORFLibraryUri(ORFUriType.ARCHIVE_DAY, "oe1", "20140914")
     self.assertEqual(str(parsed_uri), "orfradio:oe1/20140914")
Example #17
0
 def test_create_show_uri(self):
     parsed_uri = ORFLibraryUri(ORFUriType.ARCHIVE_SHOW, "oe1", "20140914",
                                "382176")
     self.assertEqual(str(parsed_uri), "orfradio:oe1/20140914/382176")
Example #18
0
 def test_parse_station_uri(self):
     uri = "orfradio:oe1"
     result = ORFLibraryUri.parse(uri)
     self.assertEqual(result.uri_type, ORFUriType.STATION)