Esempio n. 1
0
    async def test_mkfile(self):
        archive = Archive7.setup(self.filename, self.secret)
        self.assertIsInstance(
            await archive.mkfile("/first.bin", os.urandom(2**20)), uuid.UUID)
        archive.close()

        self.analyze()
Esempio n. 2
0
    async def test_load(self):
        data = os.urandom(2**20)
        filename = "/first.bin"

        archive = Archive7.setup(self.filename, self.secret)
        self.assertIsInstance(await archive.mkfile(filename, data), uuid.UUID)
        self.assertEqual(await archive.load(filename), data)
        archive.close()
Esempio n. 3
0
    async def test_info(self):
        archive = Archive7.setup(self.filename, self.secret)
        await archive.mkdir("/first")
        await archive.mkfile("/first/second.bin", os.urandom(2**18))

        entry = await archive.info("/first/second.bin")
        self.assertIsInstance(entry, EntryRecord)
        archive.close()
Esempio n. 4
0
    async def test_mkdir(self):
        archive = Archive7.setup(self.filename, self.secret)
        self.assertIsInstance(await archive.mkdir("/first"), uuid.UUID)
        self.assertIsInstance(await archive.mkdir("/first/second"), uuid.UUID)
        self.assertIsInstance(await archive.mkdir("/first/second/third"),
                              uuid.UUID)
        archive.close()

        self.analyze()
Esempio n. 5
0
    async def test_isdir(self):
        archive = Archive7.setup(self.filename, self.secret)
        await archive.mkdir("/first")
        await archive.mkdir("/first/second")
        await archive.mkfile("/first/third.bin", os.urandom(2**18))

        self.assertTrue(archive.isdir("/first"))
        self.assertTrue(archive.isdir("/first/second"))
        self.assertFalse(archive.isdir("/first/third.bin"))
        archive.close()
Esempio n. 6
0
 async def test_chmod(self):
     archive = Archive7.setup(self.filename, self.secret)
     await archive.mkfile("/first.bin", os.urandom(2**18))
     await archive.chmod("/first.bin",
                         owner=uuid.UUID(int=3),
                         deleted=False,
                         user="******",
                         group="tester",
                         perms=0o755)
     archive.close()
Esempio n. 7
0
    async def test_link(self):
        archive = Archive7.setup(self.filename, self.secret)
        self.assertIsInstance(await archive.mkdir("/first"), uuid.UUID)
        self.assertIsInstance(
            await archive.mkfile("/first/second.bin", os.urandom(2**18)),
            uuid.UUID)
        self.assertIsInstance(
            await archive.link("/first/third", "/first/second.bin"), uuid.UUID)
        archive.close()

        self.analyze()
Esempio n. 8
0
    def test_stats(self):
        archive = Archive7.setup(self.filename, self.secret)
        header = archive.stats()
        archive.close()

        archive.open(self.filename, self.secret)
        header2 = archive.stats()
        archive.close()

        self.assertEqual(header.id, header2.id)
        self.assertEqual(header.created, header2.created)
 def setUpClass(cls) -> None:
     """Prepare class-wise environment"""
     random.seed(0)
     cls.dir = TemporaryDirectory()
     cls.secret = os.urandom(32)
     cls.filename = Path(cls.dir.name, "test.ar7")
     if cls.filename.exists():
         raise OSError("File shouldn't be there.")
     cls.owner = Generate.uuid()
     cls.archive = Archive7.setup(cls.filename, cls.secret, owner=cls.owner)
     cls.files = dict()
     cls.links = dict()
     for _ in range(cls.FILE_COUNT):
         filename = PurePosixPath(random.choice(LIPSUM_PATH),
                                  Generate.filename())
         cls.files[filename] = Generate.lipsum()
     cls.archive.close()
Esempio n. 10
0
 def test_closed(self):
     archive = Archive7.setup(self.filename, self.secret)
     self.assertFalse(archive.closed)
     archive.close()
     self.assertTrue(archive.closed)
Esempio n. 11
0
    def test_open(self):
        archive = Archive7.setup(self.filename, self.secret)
        archive.close()

        archive.open(self.filename, self.secret)
        archive.close()