def test_browse_archive(self): uri = str(OE1LibraryUri(OE1UriType.ARCHIVE)) result = self.library.browse(uri) self.assertEqual(len(result), 2) self.assertEqual(result[0].type, Ref.DIRECTORY) self.assertEqual(result[0].uri, 'oe1:archive:1') self.assertEqual(result[0].name, 'Day1')
def test_lookup_archive_day(self): uri = str(OE1LibraryUri(OE1UriType.ARCHIVE_DAY, '20140914')) result = self.library.lookup(uri) self.client_mock.get_day.assert_called_once_with('20140914') self.assertEqual(len(result), 3) self.assertEqual(result[0].type, Ref.TRACK) self.assertEqual(result[0].uri, 'oe1:archive:20140914:1') self.assertEqual(result[0].name, '01:00 Item1')
def test_lookup_archive_item(self): uri = str(OE1LibraryUri(OE1UriType.ARCHIVE_ITEM, '20140914', '1234567')) result = self.library.lookup(uri) self.client_mock.get_item.assert_called_once_with( '20140914', '1234567') self.assertEqual(len(result), 1) self.assertEqual(result[0].uri, 'oe1:archive:20140914:1') self.assertEqual(result[0].name, '01:00 Item1')
def translate_uri(self, uri): try: library_uri = OE1LibraryUri.parse(uri) except InvalidOE1Uri: return None if library_uri.uri_type == OE1UriType.LIVE: return OE1Client.LIVE if library_uri.uri_type == OE1UriType.CAMPUS: return OE1Client.CAMPUS if library_uri.uri_type == OE1UriType.ARCHIVE_ITEM: return self.client.get_item_url(library_uri.day_id, library_uri.item_id)
def test_create_archive_uri(self): parsed_uri = OE1LibraryUri(OE1UriType.ARCHIVE) self.assertEqual(str(parsed_uri), 'oe1:archive')
def test_create_campus_uri(self): parsed_uri = OE1LibraryUri(OE1UriType.CAMPUS) self.assertEqual(str(parsed_uri), 'oe1:campus')
def test_create_root_uri(self): parsed_uri = OE1LibraryUri(OE1UriType.ROOT) self.assertEqual(str(parsed_uri), 'oe1:directory')
def test_browse_root(self): uri = str(OE1LibraryUri(OE1UriType.ROOT)) result = self.library.browse(uri) self.assertEqual(len(result), 3)
def test_parse_day_uri(self): uri = 'oe1:archive:20140914' result = OE1LibraryUri.parse(uri) self.assertEqual(result.uri_type, OE1UriType.ARCHIVE_DAY) self.assertEqual(result.day_id, '20140914')
def test_parse_campus_uri(self): uri = 'oe1:campus' result = OE1LibraryUri.parse(uri) self.assertEqual(result.uri_type, OE1UriType.CAMPUS)
def test_lookup_campus(self): uri = str(OE1LibraryUri(OE1UriType.CAMPUS)) result = self.library.lookup(uri) self.assertEqual(len(result), 1) self.assertEqual(result[0].uri, uri) self.assertEqual(result[0].name, 'Campus')
def test_lookup_live(self): uri = str(OE1LibraryUri(OE1UriType.LIVE)) result = self.library.lookup(uri) self.assertEqual(len(result), 1) self.assertEqual(result[0].uri, uri) self.assertEqual(result[0].name, 'Live')
def test_browse_unlookable_uri(self): uri = str(OE1LibraryUri(OE1UriType.ROOT)) result = self.library.lookup(uri) self.assertEqual(result, [])
def test_parse_root_uri(self): uri = 'oe1:directory' result = OE1LibraryUri.parse(uri) self.assertEqual(result.uri_type, OE1UriType.ROOT)
def test_create_day_uri(self): parsed_uri = OE1LibraryUri(OE1UriType.ARCHIVE_DAY, '20140914') self.assertEqual(str(parsed_uri), 'oe1:archive:20140914')
def test_create_item_uri(self): parsed_uri = OE1LibraryUri(OE1UriType.ARCHIVE_ITEM, '20140914', '382176') self.assertEqual(str(parsed_uri), 'oe1:archive:20140914:382176')
def test_parse_archive_uri(self): uri = 'oe1:archive' result = OE1LibraryUri.parse(uri) self.assertEqual(result.uri_type, OE1UriType.ARCHIVE)
def test_parse_item_uri(self): uri = 'oe1:archive:20140914:382176' result = OE1LibraryUri.parse(uri) self.assertEqual(result.uri_type, OE1UriType.ARCHIVE_ITEM) self.assertEqual(result.day_id, '20140914') self.assertEqual(result.item_id, '382176')
def test_browse_unbrowsable_uri(self): uri = str(OE1LibraryUri(OE1UriType.LIVE)) result = self.library.browse(uri) self.assertEqual(result, [])