Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sherlock_project/sherlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def sherlock(

# Results from analysis of all sites
results_total = {}
request_futures = {}

# First create futures for all requests. This allows for the requests to run in parallel
for social_network, net_info in site_data.items():
Expand Down Expand Up @@ -333,7 +334,7 @@ def sherlock(
)

# Store future in data for access later
net_info["request_future"] = future
request_futures[social_network] = future

# Add this site's results into final dictionary with all the other results.
results_total[social_network] = results_site
Expand All @@ -356,7 +357,7 @@ def sherlock(
error_type: list[str] = [error_type]

# Retrieve future and ensure it has finished
future = net_info["request_future"]
future = request_futures[social_network]
r, error_text, exception_text = get_response(
request_future=future, error_type=error_type, social_network=social_network
)
Expand Down
45 changes: 45 additions & 0 deletions tests/test_ux.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from sherlock_project import sherlock
from sherlock_project.notify import QueryNotify
from sherlock_interactives import Interactives
from sherlock_interactives import InteractivesSubprocessError

Expand Down Expand Up @@ -33,6 +34,50 @@ def test_wildcard_username_expansion():
assert sherlock.multiple_usernames('test{?}test') == ["test_test" , "test-test" , "test.test"]


def test_sherlock_does_not_mutate_input_site_data(monkeypatch):
class FakeResponse:
status_code = 404
text = ""
encoding = "UTF-8"
elapsed = None

class FakeFuture:
def result(self):
return FakeResponse()

class FakeFuturesSession:
def __init__(self, *args, **kwargs):
pass

def head(self, **kwargs):
return FakeFuture()

get = head
post = head
put = head

monkeypatch.setattr(sherlock.requests, "session", lambda: object())
monkeypatch.setattr(sherlock, "SherlockFuturesSession", FakeFuturesSession)
site_data = {
"Example": {
"urlMain": "https://example.com",
"url": "https://example.com/{}",
"errorType": "status_code",
"errorCode": 404,
}
}
original_site_data = {name: dict(info) for name, info in site_data.items()}

sherlock.sherlock(
username="alice",
site_data=site_data,
query_notify=QueryNotify(),
timeout=1,
)

assert site_data == original_site_data


@pytest.mark.parametrize('cliargs', [
'',
'--site urghrtuight --egiotr',
Expand Down
Loading