Example #1
0
    def testClean(self):
        manifestsRootDir = os.path.join(ASSETS_DIR, "manifests")
        mm = ManifestRepository(manifestsRootDir)

        mm.section("8a33738d88be7edbacef48e262bbb5bc").setManifest("8a33738d88be7edbacef48e262bbb5bc",
                                                                   TestManifestRepository.manifest1)
        mm.section("0623305942d216c165970948424ae7d1").setManifest("0623305942d216c165970948424ae7d1",
                                                                   TestManifestRepository.manifest2)

        cleaningResultSize = mm.clean(240)
        # Only one of those manifests can be left
        self.assertLessEqual(cleaningResultSize, 240)
        self.assertLessEqual(self._getDirectorySize(manifestsRootDir), 240)

        cleaningResultSize = mm.clean(240)
        # The one remaining is remains alive
        self.assertLessEqual(cleaningResultSize, 240)
        self.assertGreaterEqual(cleaningResultSize, 120)
        self.assertLessEqual(self._getDirectorySize(manifestsRootDir), 240)
        self.assertGreaterEqual(self._getDirectorySize(manifestsRootDir), 120)

        cleaningResultSize = mm.clean(0)
        # All manifest are gone
        self.assertEqual(cleaningResultSize, 0)
        self.assertEqual(self._getDirectorySize(manifestsRootDir), 0)
Example #2
0
    def testClean(self):
        manifestsRootDir = os.path.join(ASSETS_DIR, "manifests")
        mm = ManifestRepository(manifestsRootDir)

        # Size in (120, 240] bytes
        manifest1 = Manifest([r'somepath\myinclude.h'], {
            "fdde59862785f9f0ad6e661b9b5746b7": "a649723940dc975ebd17167d29a532f8"
        })
        # Size in (120, 240] bytes
        manifest2 = Manifest([r'somepath\myinclude.h', 'moreincludes.h'], {
            "474e7fc26a592d84dfa7416c10f036c6": "8771d7ebcf6c8bd57a3d6485f63e3a89"
        })
        mm.section("8a33738d88be7edbacef48e262bbb5bc").setManifest("8a33738d88be7edbacef48e262bbb5bc", manifest1)
        mm.section("0623305942d216c165970948424ae7d1").setManifest("0623305942d216c165970948424ae7d1", manifest2)

        cleaningResultSize = mm.clean(240)
        # Only one of those manifests can be left
        self.assertLessEqual(cleaningResultSize, 240)
        self.assertLessEqual(self._getDirectorySize(manifestsRootDir), 240)

        cleaningResultSize = mm.clean(240)
        # The one remaining is remains alive
        self.assertLessEqual(cleaningResultSize, 240)
        self.assertGreaterEqual(cleaningResultSize, 120)
        self.assertLessEqual(self._getDirectorySize(manifestsRootDir), 240)
        self.assertGreaterEqual(self._getDirectorySize(manifestsRootDir), 120)

        cleaningResultSize = mm.clean(0)
        # All manifest are gone
        self.assertEqual(cleaningResultSize, 0)
        self.assertEqual(self._getDirectorySize(manifestsRootDir), 0)