コード例 #1
0
 def testSingle(self):
     """Test export of single file."""
     mime = 'application/x-po'
     storage = ExportFileStorage()
     storage.addFile('/tmp/a/test/file.po', 'po', 'test file', mime)
     outfile = storage.export()
     self.assertEquals(outfile.path, '/tmp/a/test/file.po')
     self.assertEquals(outfile.file_extension, 'po')
     self.assertEquals(outfile.read(), 'test file')
コード例 #2
0
 def testSingle(self):
     """Test export of single file."""
     mime = 'application/x-po'
     storage = ExportFileStorage()
     storage.addFile('/tmp/a/test/file.po', 'po', 'test file', mime)
     outfile = storage.export()
     self.assertEquals(outfile.path, '/tmp/a/test/file.po')
     self.assertEquals(outfile.file_extension, 'po')
     self.assertEquals(outfile.read(), 'test file')
コード例 #3
0
 def testTarball(self):
     """Test export of tarball."""
     mime = 'application/x-po'
     storage = ExportFileStorage()
     storage.addFile('/tmp/a/test/file.po', 'po', 'test file', mime)
     storage.addFile('/tmp/another/test.po', 'po', 'another test file',
                     mime)
     outfile = storage.export()
     tarball = TarFile.open(mode='r|gz', fileobj=StringIO(outfile.read()))
     elements = set(tarball.getnames())
     self.assertTrue('/tmp/a/test/file.po' in elements)
     self.assertTrue('/tmp/another/test.po' in elements)
コード例 #4
0
 def testTarball(self):
     """Test export of tarball."""
     mime = 'application/x-po'
     storage = ExportFileStorage()
     storage.addFile('/tmp/a/test/file.po', 'po', 'test file', mime)
     storage.addFile(
         '/tmp/another/test.po', 'po', 'another test file', mime)
     outfile = storage.export()
     tarball = TarFile.open(mode='r|gz', fileobj=StringIO(outfile.read()))
     elements = set(tarball.getnames())
     self.assertTrue('/tmp/a/test/file.po' in elements)
     self.assertTrue('/tmp/another/test.po' in elements)
コード例 #5
0
 def testFull(self):
     """Behaviour of isFull."""
     mime = 'application/x-po'
     storage = ExportFileStorage()
     storage.addFile('/tmp/a/test/file.po', 'po', 'test file', mime)
     # The storage object starts out with a SingleFileStorageStrategy, so
     # it's full now that we've added one file.
     self.assertTrue(storage._store.isFull())
     # If we add another file however, the storage object transparently
     # switches to a TarballFileStorageStrategy.  That type of storage
     # object is never full.
     storage.addFile('/tmp/another/test/file.po', 'po', 'test file two',
                     mime)
     self.assertFalse(storage._store.isFull())
     # We can now add any number of files without filling the storage
     # object.
     storage.addFile('/tmp/yet/another/test/file.po', 'po', 'test file 3',
                     mime)
     self.assertFalse(storage._store.isFull())
コード例 #6
0
 def testFull(self):
     """Behaviour of isFull."""
     mime = 'application/x-po'
     storage = ExportFileStorage()
     storage.addFile('/tmp/a/test/file.po', 'po', 'test file', mime)
     # The storage object starts out with a SingleFileStorageStrategy, so
     # it's full now that we've added one file.
     self.assertTrue(storage._store.isFull())
     # If we add another file however, the storage object transparently
     # switches to a TarballFileStorageStrategy.  That type of storage
     # object is never full.
     storage.addFile(
         '/tmp/another/test/file.po', 'po', 'test file two', mime)
     self.assertFalse(storage._store.isFull())
     # We can now add any number of files without filling the storage
     # object.
     storage.addFile(
         '/tmp/yet/another/test/file.po', 'po', 'test file 3', mime)
     self.assertFalse(storage._store.isFull())