def testSplitDailyDir_004(self): """ Test with 99,999 byte limit, chopped down to 5,000 bytes """ self.extractTar("tree21") dailyDir = self.buildPath(["tree21", "2007", "01", "01"]) self.assertTrue(os.path.exists(dailyDir) and os.path.isdir(dailyDir)) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file001.a.b"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file001"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file001"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file003"))) sizeLimit = ByteQuantity("99999", UNIT_BYTES) splitSize = ByteQuantity("5000", UNIT_BYTES) _splitDailyDir(dailyDir, sizeLimit, splitSize, None, None) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file001.a.b"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file002"))) self.assertFalse(os.path.exists(pathJoin(dailyDir, "system1", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file001"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file002"))) self.assertFalse(os.path.exists(pathJoin(dailyDir, "system2", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file001"))) self.assertFalse(os.path.exists(pathJoin(dailyDir, "system3", "file002"))) self.assertFalse(os.path.exists(pathJoin(dailyDir, "system3", "file003"))) self.checkSplit(pathJoin(dailyDir, "system1", "file003"), 320000, 5000) self.checkSplit(pathJoin(dailyDir, "system2", "file003"), 100000, 5000) self.checkSplit(pathJoin(dailyDir, "system3", "file002"), 100000, 5000) self.checkSplit(pathJoin(dailyDir, "system3", "file003"), 100001, 5000)
def testConstructor_002(self): """ Test constructor with all values filled in, with valid values. """ split = SplitConfig(ByteQuantity("1.0", UNIT_BYTES), ByteQuantity("2.0", UNIT_KBYTES)) self.assertEqual(ByteQuantity("1.0", UNIT_BYTES), split.sizeLimit) self.assertEqual(ByteQuantity("2.0", UNIT_KBYTES), split.splitSize)
def testValidate_005(self): """ Test validate on a non-empty split section with valid values filled in. """ config = LocalConfig() config.split = SplitConfig(ByteQuantity("1.00", UNIT_MBYTES), ByteQuantity("1.00", UNIT_MBYTES)) config.validate()
def testSplitDailyDir_002(self): """ Test with 1.0 MB limit. """ self.extractTar("tree21") dailyDir = self.buildPath(["tree21", "2007", "01", "01"]) self.assertTrue(os.path.exists(dailyDir) and os.path.isdir(dailyDir)) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file001.a.b"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file001"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file001"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file003"))) sizeLimit = ByteQuantity("1.0", UNIT_MBYTES) splitSize = ByteQuantity("100000", UNIT_BYTES) _splitDailyDir(dailyDir, sizeLimit, splitSize, None, None) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file001.a.b"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system1", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file001"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system2", "file003"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file001"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file002"))) self.assertTrue(os.path.exists(pathJoin(dailyDir, "system3", "file003")))
def testAddConfig_005(self): """ Test with values set, GB values. """ split = SplitConfig(ByteQuantity("12", UNIT_GBYTES), ByteQuantity("63352", UNIT_GBYTES)) config = LocalConfig() config.split = split self.validateAddConfig(config)
def testAddConfig_002(self): """ Test with values set, byte values. """ split = SplitConfig(ByteQuantity("57521.0", UNIT_BYTES), ByteQuantity("121231", UNIT_BYTES)) config = LocalConfig() config.split = split self.validateAddConfig(config)
def testConstructor_004(self): """ Test assignment of sizeLimit attribute, valid value. """ split = SplitConfig() self.assertEqual(None, split.sizeLimit) split.sizeLimit = ByteQuantity("1.0", UNIT_BYTES) self.assertEqual(ByteQuantity("1.0", UNIT_BYTES), split.sizeLimit)
def testConstructor_008(self): """ Test assignment of splitSize attribute, valid value. """ split = SplitConfig() self.assertEqual(None, split.splitSize) split.splitSize = ByteQuantity("1.00", UNIT_KBYTES) self.assertEqual(ByteQuantity("1.00", UNIT_KBYTES), split.splitSize)
def testValidate_004(self): """ Test validate on a non-empty split section with only one value filled in. """ config = LocalConfig() config.split = SplitConfig(ByteQuantity("1.00", UNIT_MBYTES), None) self.assertRaises(ValueError, config.validate) config.split = SplitConfig(None, ByteQuantity("1.00", UNIT_MBYTES)) self.assertRaises(ValueError, config.validate)
def testSplitDailyDir_001(self): """ Test with a nonexistent daily staging directory. """ self.extractTar("tree21") dailyDir = self.buildPath(["tree21", "2007", "01", INVALID_PATH]) self.assertFalse(os.path.exists(dailyDir)) sizeLimit = ByteQuantity("1.0", UNIT_MBYTES) splitSize = ByteQuantity("100000", UNIT_BYTES) self.assertRaises(ValueError, _splitDailyDir, dailyDir, sizeLimit, splitSize, None, None)
def testComparison_006(self): """ Test comparison of two differing objects, splitSize differs. """ split1 = SplitConfig(ByteQuantity("99", UNIT_KBYTES), ByteQuantity("0.5", UNIT_MBYTES)) split2 = SplitConfig(ByteQuantity("99", UNIT_KBYTES), ByteQuantity("1.00", UNIT_MBYTES)) self.assertNotEqual(split1, split2) self.assertTrue(not split1 == split2) self.assertTrue(split1 < split2) self.assertTrue(split1 <= split2) self.assertTrue(not split1 > split2) self.assertTrue(not split1 >= split2) self.assertTrue(split1 != split2)
def testComparison_002(self): """ Test comparison of two identical objects, all attributes non-None. """ split1 = SplitConfig(ByteQuantity("99", UNIT_KBYTES), ByteQuantity("1.00", UNIT_MBYTES)) split2 = SplitConfig(ByteQuantity("99", UNIT_KBYTES), ByteQuantity("1.00", UNIT_MBYTES)) self.assertEqual(split1, split2) self.assertTrue(split1 == split2) self.assertTrue(not split1 < split2) self.assertTrue(split1 <= split2) self.assertTrue(not split1 > split2) self.assertTrue(split1 >= split2) self.assertTrue(not split1 != split2)
def testParse_005(self): """ Parse config document with filled-in values, size in GB. """ path = self.resources["split.conf.5"] with open(path) as f: contents = f.read() config = LocalConfig(xmlPath=path, validate=False) self.assertNotEqual(None, config.split) self.assertEqual(ByteQuantity("1.25", UNIT_GBYTES), config.split.sizeLimit) self.assertEqual(ByteQuantity("0.6", UNIT_GBYTES), config.split.splitSize) config = LocalConfig(xmlData=contents, validate=False) self.assertNotEqual(None, config.split) self.assertEqual(ByteQuantity("1.25", UNIT_GBYTES), config.split.sizeLimit) self.assertEqual(ByteQuantity("0.6", UNIT_GBYTES), config.split.splitSize)
def testSplitFile_005(self): """ Test with a local other than "C" or "en_US" set. """ locale = self.findBadLocale() if locale is not None: os.environ["LANG"] = locale os.environ["LC_ADDRESS"] = locale os.environ["LC_ALL"] = locale os.environ["LC_COLLATE"] = locale os.environ["LC_CTYPE"] = locale os.environ["LC_IDENTIFICATION"] = locale os.environ["LC_MEASUREMENT"] = locale os.environ["LC_MESSAGES"] = locale os.environ["LC_MONETARY"] = locale os.environ["LC_NAME"] = locale os.environ["LC_NUMERIC"] = locale os.environ["LC_PAPER"] = locale os.environ["LC_TELEPHONE"] = locale os.environ["LC_TIME"] = locale self.extractTar("tree21") sourcePath = self.buildPath(["tree21", "2007", "01", "01", "system1", "file001.a.b"]) self.assertTrue(os.path.exists(sourcePath)) splitSize = ByteQuantity("320", UNIT_BYTES) _splitFile(sourcePath, splitSize, None, None, removeSource=True) self.assertFalse(os.path.exists(sourcePath)) self.checkSplit(sourcePath, 3200, 320)
def testComparison_004(self): """ Test comparison of two differing objects, split differs. """ config1 = LocalConfig() config1.split = SplitConfig(sizeLimit=ByteQuantity("0.1", UNIT_MBYTES)) config2 = LocalConfig() config2.split = SplitConfig(sizeLimit=ByteQuantity("1.00", UNIT_MBYTES)) self.assertNotEqual(config1, config2) self.assertTrue(not config1 == config2) self.assertTrue(config1 < config2) self.assertTrue(config1 <= config2) self.assertTrue(not config1 > config2) self.assertTrue(not config1 >= config2) self.assertTrue(config1 != config2)
def testSplitFile_001(self): """ Test with a nonexistent file. """ self.extractTar("tree21") sourcePath = self.buildPath(["tree21", "2007", "01", "01", INVALID_PATH]) self.assertFalse(os.path.exists(sourcePath)) splitSize = ByteQuantity("320", UNIT_BYTES) self.assertRaises(ValueError, _splitFile, sourcePath, splitSize, None, None, removeSource=False)
def testSplitFile_004(self): """ Test with integer split size, removeSource=True. """ self.extractTar("tree21") sourcePath = self.buildPath(["tree21", "2007", "01", "01", "system1", "file001.a.b"]) self.assertTrue(os.path.exists(sourcePath)) splitSize = ByteQuantity("320", UNIT_BYTES) _splitFile(sourcePath, splitSize, None, None, removeSource=True) self.assertFalse(os.path.exists(sourcePath)) self.checkSplit(sourcePath, 3200, 320)
def testComparison_003(self): """ Test comparison of two differing objects, sizeLimit differs (one None). """ split1 = SplitConfig() split2 = SplitConfig(sizeLimit=ByteQuantity("99", UNIT_KBYTES)) self.assertNotEqual(split1, split2) self.assertTrue(not split1 == split2) self.assertTrue(split1 < split2) self.assertTrue(split1 <= split2) self.assertTrue(not split1 > split2) self.assertTrue(not split1 >= split2) self.assertTrue(split1 != split2)