Esempio n. 1
0
 def testInvalidReplaceLen(self):
     original = 'short'
     replaceLen = 8
     maxLen = 7
     with self.assertRaises(Exception):
         s = util.random_num_replace(
             original, replaceLen, max_length=maxLen)
Esempio n. 2
0
 def testReplaceNoLimit(self):
     original = 'test'
     replaceLen = 8
     modified = util.random_num_replace(original, replaceLen)
     self.assertEqual(len(original) + replaceLen, len(modified))
     self.assertEqual(original, modified[0:len(original)])
     self.assertTrue(re.match('[0-9A-Za-z]+', modified[len(original):]))
Esempio n. 3
0
 def testReplaceNoLimit(self):
     original = 'test'
     replaceLen = 8
     modified = util.random_num_replace(original, replaceLen)
     self.assertEqual(len(original) + replaceLen, len(modified))
     self.assertEqual(original, modified[0:len(original)])
     self.assertTrue(re.match('[0-9A-Za-z]+', modified[len(original):]))
Esempio n. 4
0
 def testInvalidReplaceLen(self):
     original = 'short'
     replaceLen = 8
     maxLen = 7
     with self.assertRaises(Exception):
         s = util.random_num_replace(original,
                                     replaceLen,
                                     max_length=maxLen)
Esempio n. 5
0
 def testReplaceStrictLimit(self):
     original = 'testingstuffmore'
     replaceLen = 6
     unreplacedLen = len(original) - replaceLen
     modified = util.random_num_replace(original, replaceLen, max_length=len(original))
     self.assertEqual(len(original), len(modified))
     self.assertEqual(original[:unreplacedLen], modified[:unreplacedLen])
     self.assertTrue(re.match('[0-9A-Za-z]+', modified[unreplacedLen:]))
Esempio n. 6
0
 def testReplaceWithLimit(self):
     original = 'testingstuff'
     replaceLen = 4
     totalLen = len(original) + 2
     unreplacedLen = totalLen - replaceLen
     modified = util.random_num_replace(original, replaceLen, max_length=totalLen)
     self.assertEqual(totalLen, len(modified))
     self.assertEqual(original[:unreplacedLen], modified[:unreplacedLen])
     self.assertTrue(re.match('[0-9A-Za-z]+', modified[unreplacedLen:]))
Esempio n. 7
0
 def testReplaceWithLimit(self):
     original = 'testingstuff'
     replaceLen = 4
     totalLen = len(original) + 2
     unreplacedLen = totalLen - replaceLen
     modified = util.random_num_replace(original, replaceLen, max_length=totalLen)
     self.assertEqual(totalLen, len(modified))
     self.assertEqual(original[:unreplacedLen], modified[:unreplacedLen])
     self.assertTrue(re.match('[0-9A-Za-z]+', modified[unreplacedLen:]))
Esempio n. 8
0
 def testReplaceStrictLimit(self):
     original = 'testingstuffmore'
     replaceLen = 6
     unreplacedLen = len(original) - replaceLen
     modified = util.random_num_replace(original,
                                        replaceLen,
                                        max_length=len(original))
     self.assertEqual(len(original), len(modified))
     self.assertEqual(original[:unreplacedLen], modified[:unreplacedLen])
     self.assertTrue(re.match('[0-9A-Za-z]+', modified[unreplacedLen:]))