def test_decode(self): question = '1 + 1' timestamp = 1000 hashed = hash_question(question, timestamp) self.assertEqual( (question, timestamp), unhash_question(hashed) )
def test_invalid(self): with self.assertRaises(ValueError): unhash_question('')
def test_tamper(self): hashed = hash_question('', 0) + '00' with self.assertRaises(ValueError): unhash_question(hashed)