def testAnalysis(self): """Test that main() runs and returns the correct analysis object.""" result = pass_check.main("0000000000") self.assertEqual(result.word, "0000000000") self.assertGreater(result.cost, 1) self.assertEqual(result.parts[0].word, "0000000000") self.assertEqual(result.parts[0].type, "repetition") self.assertGreater(result.time, 0)
def testPatternWordCombination(self): """Test that combinations of words are identified.""" result = pass_check.main("wordthreat") self.assertGreater(result.cost, 1) self.assertEqual(result.parts[0].word, "word") self.assertEqual(result.parts[0].pattern, "word-combination") self.assertEqual(result.parts[1].word, "threat") self.assertEqual(result.parts[1].pattern, "word-combination")
def testPatternWordRepeat(self): """Test that repeated words are identified.""" result = pass_check.main("timertimer") self.assertGreater(result.cost, 1) self.assertEqual(result.parts[0].word, "timer") self.assertEqual(result.parts[0].pattern, "word-repeat") self.assertEqual(result.parts[1].word, "timer") self.assertEqual(result.parts[1].pattern, "word-repeat")
def testRandomPassword(self): """Test that main() runs and returns a valid analysis object.""" result = pass_check.main(randomPassword=True) self.assertTrue(bool(result.word)) self.assertGreater(result.cost, 1) self.assertTrue(bool(result.parts[0].word)) self.assertTrue(bool(result.parts[0].type)) self.assertTrue(bool(result.word))
def testPatternBorderMirror(self): """Test that a mirrored border is identified: ((example))""" result = pass_check.main("((mirrors))") self.assertGreater(result.cost, 1) self.assertEqual(result.parts[0].word, "((") self.assertEqual(result.parts[0].pattern, "border-mirror") self.assertEqual(result.parts[1].word, "mirrors") self.assertEqual(result.parts[1].pattern, None) self.assertEqual(result.parts[2].word, "))") self.assertEqual(result.parts[2].pattern, "border-mirror")
def testPatternBorderRepeat(self): """Test that a repeated border is identified: !!example!!""" result = pass_check.main("!!borders!!") self.assertGreater(result.cost, 1) self.assertEqual(result.parts[0].word, "!!") self.assertEqual(result.parts[0].pattern, "border-repeat") self.assertEqual(result.parts[1].word, "borders") self.assertEqual(result.parts[1].pattern, None) self.assertEqual(result.parts[2].word, "!!") self.assertEqual(result.parts[2].pattern, "border-repeat")
def testPatternWordCombinationDelimiter(self): """Test that two words with a single delimiter are identified.""" result = pass_check.main("money$dollars") self.assertGreater(result.cost, 1) self.assertEqual(result.parts[0].word, "money") self.assertEqual(result.parts[0].pattern, "word-combination") self.assertEqual(result.parts[1].word, "$") self.assertEqual(result.parts[1].pattern, "word-combination-delimiter") self.assertEqual(result.parts[2].word, "dollars") self.assertEqual(result.parts[2].pattern, "word-combination")
def testTime(self): """Test random passwords, fail if any time is greater than 1""" for i in range(0, 20): result = pass_check.main(randomPassword=True) self.assertLess(result.time, 1)