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
12 changes: 4 additions & 8 deletions sherlock_project/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
from colorama import Fore, Style
import webbrowser

# Global variable to count the number of results.
globvar = 0


class QueryNotify:
"""Query Notify Object.

Expand Down Expand Up @@ -132,6 +128,7 @@ def __init__(self, result=None, verbose=False, print_all=False, browse=False):
self.verbose = verbose
self.print_all = print_all
self.browse = browse
self._result_count = 0


def start(self, message):
Expand Down Expand Up @@ -169,9 +166,8 @@ def countResults(self):
Return Value:
The number of results by the time we call the function.
"""
global globvar
globvar += 1
return globvar
self._result_count += 1
return self._result_count

def update(self, result):
"""Notify Update.
Expand Down Expand Up @@ -258,7 +254,7 @@ def finish(self, message="The processing has been finished."):
Return Value:
Nothing.
"""
NumberOfResults = self.countResults() - 1
NumberOfResults = self._result_count

print(Style.BRIGHT + Fore.GREEN + "[" +
Fore.YELLOW + "*" +
Expand Down
28 changes: 28 additions & 0 deletions tests/test_notify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from sherlock_project.notify import QueryNotifyPrint
from sherlock_project.result import QueryResult, QueryStatus


def claimed_result():
return QueryResult(
username='example',
site_name='Example',
site_url_user='https://example.com/example',
status=QueryStatus.CLAIMED,
)


def test_result_count_is_scoped_to_each_notifier(capsys):
first = QueryNotifyPrint()
first.update(claimed_result())
first.update(claimed_result())
first.finish()

assert ' 2 ' in capsys.readouterr().out
assert first._result_count == 2

second = QueryNotifyPrint()
second.update(claimed_result())
second.finish()

assert ' 1 ' in capsys.readouterr().out
assert second._result_count == 1