Example #1
0
 def test_set_hash(self):
     """Test set_hash() returns a hashed URL"""
     url = "http://example.org/"
     hashed = shortis.set_hash(url)
     self.assertEqual('HUxnkdfT', hashed)
     again = shortis.set_hash(url)
     self.assertEqual(hashed, again)
     other = shortis.set_hash(url + "foo")
     self.assertNotEqual(hashed, other)
Example #2
0
 def test_lookup_hash(self):
     """Test lookup_hash()"""
     url = shortis.lookup_hash('HUxnkdfT')
     self.assertIsNone(url)
     url = 'http://example.org'
     hashed = shortis.set_hash(url)
     res = shortis.lookup_hash(hashed)
     self.assertIsNotNone(res)
     self.assertEqual(url, res)