Пример #1
0
 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')
Пример #2
0
 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')
Пример #3
0
 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')
Пример #4
0
    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)
Пример #5
0
 def test_create_archive_uri(self):
     parsed_uri = OE1LibraryUri(OE1UriType.ARCHIVE)
     self.assertEqual(str(parsed_uri), 'oe1:archive')
Пример #6
0
 def test_create_campus_uri(self):
     parsed_uri = OE1LibraryUri(OE1UriType.CAMPUS)
     self.assertEqual(str(parsed_uri), 'oe1:campus')
Пример #7
0
 def test_create_root_uri(self):
     parsed_uri = OE1LibraryUri(OE1UriType.ROOT)
     self.assertEqual(str(parsed_uri), 'oe1:directory')
Пример #8
0
 def test_browse_root(self):
     uri = str(OE1LibraryUri(OE1UriType.ROOT))
     result = self.library.browse(uri)
     self.assertEqual(len(result), 3)
Пример #9
0
 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')
Пример #10
0
 def test_parse_campus_uri(self):
     uri = 'oe1:campus'
     result = OE1LibraryUri.parse(uri)
     self.assertEqual(result.uri_type, OE1UriType.CAMPUS)
Пример #11
0
 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')
Пример #12
0
 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')
Пример #13
0
 def test_browse_unlookable_uri(self):
     uri = str(OE1LibraryUri(OE1UriType.ROOT))
     result = self.library.lookup(uri)
     self.assertEqual(result, [])
Пример #14
0
 def test_parse_root_uri(self):
     uri = 'oe1:directory'
     result = OE1LibraryUri.parse(uri)
     self.assertEqual(result.uri_type, OE1UriType.ROOT)
Пример #15
0
 def test_create_day_uri(self):
     parsed_uri = OE1LibraryUri(OE1UriType.ARCHIVE_DAY, '20140914')
     self.assertEqual(str(parsed_uri), 'oe1:archive:20140914')
Пример #16
0
 def test_parse_campus_uri(self):
     uri = 'oe1:campus'
     result = OE1LibraryUri.parse(uri)
     self.assertEqual(result.uri_type, OE1UriType.CAMPUS)
Пример #17
0
 def test_create_item_uri(self):
     parsed_uri = OE1LibraryUri(OE1UriType.ARCHIVE_ITEM, '20140914',
                                '382176')
     self.assertEqual(str(parsed_uri), 'oe1:archive:20140914:382176')
Пример #18
0
 def test_parse_archive_uri(self):
     uri = 'oe1:archive'
     result = OE1LibraryUri.parse(uri)
     self.assertEqual(result.uri_type, OE1UriType.ARCHIVE)
Пример #19
0
 def test_parse_root_uri(self):
     uri = 'oe1:directory'
     result = OE1LibraryUri.parse(uri)
     self.assertEqual(result.uri_type, OE1UriType.ROOT)
Пример #20
0
 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')
Пример #21
0
 def test_parse_archive_uri(self):
     uri = 'oe1:archive'
     result = OE1LibraryUri.parse(uri)
     self.assertEqual(result.uri_type, OE1UriType.ARCHIVE)
Пример #22
0
 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')
Пример #23
0
 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')
Пример #24
0
 def test_browse_unbrowsable_uri(self):
     uri = str(OE1LibraryUri(OE1UriType.LIVE))
     result = self.library.browse(uri)
     self.assertEqual(result, [])