def test_user_hash_is_truncated(mock_pymongo): dead = DropHandler(mock_pymongo) ipAddr ="127.0.0.1" dead.setRequestHash(ipAddr) data = {"test":"here"} dead.drop(data) saltedIP = DropHandler.salt +ipAddr m = hashlib.sha256() m.update(saltedIP.encode('utf-8')) client_hash = m.hexdigest()[:32] mock_pymongo.dead.track.insert_one.assert_called_with({"key": ANY,"userHash": client_hash, "createdDate":datetime.datetime(2012, 1, 14),"pickedUp":ANY})
def test_track_is_saved(mock_pymongo): dead = DropHandler(mock_pymongo) dead.setRequestHash("127.0.0.1") data = {"test":"here"} dead.drop(data) mock_pymongo.dead.track.insert_one.assert_called_with({"key": ANY,"userHash":ANY, "createdDate":datetime.datetime(2012, 1, 14),"pickedUp":ANY})