Esempio n. 1
0
    def test_prefixDirectories(self):
        # _relFileLocation splits eight hex digits across four path segments
        self.assertEqual('12/34/56/78', _relFileLocation(0x12345678))

        # less than eight hex digits will be padded
        self.assertEqual('00/00/01/23', _relFileLocation(0x123))

        # more than eight digits will make the final segment longer, if that
        # were to ever happen
        self.assertEqual('12/34/56/789', _relFileLocation(0x123456789))
Esempio n. 2
0
    def test_prefixDirectories(self):
        # _relFileLocation splits eight hex digits across four path segments
        self.assertEqual('12/34/56/78', _relFileLocation(0x12345678))

        # less than eight hex digits will be padded
        self.assertEqual('00/00/01/23', _relFileLocation(0x123))

        # more than eight digits will make the final segment longer, if that
        # were to ever happen
        self.assertEqual('12/34/56/789', _relFileLocation(0x123456789))
Esempio n. 3
0
    def test_prefixDirectories(self):
        # _relFileLocation splits eight hex digits across four path segments
        self.assertEqual('12/34/56/78', _relFileLocation(0x12345678))

        # less than eight hex digits will be padded
        self.assertEqual('00/00/01/23', _relFileLocation(0x123))

        # more than eight digits will make the final segment longer, if that
        # were to ever happen
        # However, instead of allowing this to happen it is guarded by
        # an assert. Other tools, such as the garbage collector, rely
        # on the filesystem layout to efficiently iterate over the objects
        # in order.
        # self.assertEqual('12/34/56/789', _relFileLocation(0x123456789))
        self.assertRaises(AssertionError, _relFileLocation, 0x123456789)
Esempio n. 4
0
def fillLibrarianFile(fileid, content='Fake Content'):
    """Write contents in disk for a librarian sampledata."""
    filepath = os.path.join(
        config.librarian_server.root, _relFileLocation(fileid))

    if not os.path.exists(os.path.dirname(filepath)):
        os.makedirs(os.path.dirname(filepath))

    libfile = open(filepath, 'wb')
    libfile.write(content)
    libfile.close()
Esempio n. 5
0
def fillLibrarianFile(fileid, content=None):
    """Write contents in disk for a librarian sampledata."""
    if content is None:
        content = 'x' * LibraryFileContent.get(fileid).filesize

    filepath = os.path.join(
        config.librarian_server.root, _relFileLocation(fileid))

    if not os.path.exists(os.path.dirname(filepath)):
        os.makedirs(os.path.dirname(filepath))

    with open(filepath, 'wb') as libfile:
        libfile.write(content)
Esempio n. 6
0
def filesystem_path(lfc_id):
    from lp.services.librarianserver.storage import _relFileLocation
    return os.path.join(config.librarian_server.root, _relFileLocation(lfc_id))