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_drop_is_saved(mock_pymongo): """See if drop is saved properly.""" dead = DropHandler(mock_pymongo) data = {"test": "here"} dead.drop(data) mock_pymongo.dead.drop.insert_one.assert_called_with({ 'key': ANY, 'data': data, 'createdDate': datetime.datetime(2012, 1, 14) })
def test_track_is_saved(mock_pymongo): """See if drop as tracked properly.""" dead = DropHandler(mock_pymongo) dead.set_request_hash("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 })
def test_user_hash_is_truncated(mock_pymongo): """See if client_hash is set properly.""" dead = DropHandler(mock_pymongo) ip_addr = "127.0.0.1" dead.set_request_hash(ip_addr) data = {'test': "here"} dead.drop(data) salted_ip = dead.salt + ip_addr hasher = hashlib.sha256() hasher.update(salted_ip.encode('utf-8')) client_hash = hasher.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_drop_is_saved(mock_pymongo): dead = DropHandler(mock_pymongo) data = {"test":"here"} dead.drop(data) mock_pymongo.dead.drop.insert_one.assert_called_with({"key": ANY, "data":data,"createdDate":datetime.datetime(2012, 1, 14)})
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})