Exemple #1
0
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
    })
Exemple #2
0
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
    })