From f96faa117167cefda7b04fea49c713ca13b71e80 Mon Sep 17 00:00:00 2001 From: KD Date: Wed, 15 May 2024 00:20:36 +0300 Subject: [PATCH 01/23] basic setup of env, vscode --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b5a19b1..ec16573 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ RemoteSystemsTempFiles .metadata .settings *.prefs +.vscode/ From dd0bdfcf7db458163a2aab42fb8b0f3412a4849d Mon Sep 17 00:00:00 2001 From: KD Date: Wed, 15 May 2024 01:38:34 +0300 Subject: [PATCH 02/23] Changed name of plugin from 'googles.py' to 'google.py'. Changed misstype 'googles' to 'google' in plugin. Because of these, the first example in the documentation didn't work. --- plugins/{googles.py => google.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename plugins/{googles.py => google.py} (95%) diff --git a/plugins/googles.py b/plugins/google.py similarity index 95% rename from plugins/googles.py rename to plugins/google.py index 557d186..c0892b1 100644 --- a/plugins/googles.py +++ b/plugins/google.py @@ -36,6 +36,6 @@ class Plugin: def __init__(self, app, conf):# global app_emailharvester, config #config = conf - app.register_plugin('googles', {'search': search}) + app.register_plugin('google', {'search': search}) app_emailharvester = app From 6dddca297ce753d6fff258408c2ad37c7c897fd7 Mon Sep 17 00:00:00 2001 From: KD Date: Thu, 16 May 2024 01:51:41 +0300 Subject: [PATCH 03/23] Resolve merge conflicts --- tests/__init__.py | 0 tests/test_emailharvester.py | 7 +++++++ tests/test_plugins/test_ask.py | 7 +++++++ tests/test_plugins/test_baidu.py | 7 +++++++ tests/test_plugins/test_bing.py | 7 +++++++ tests/test_plugins/test_dogpile.py | 7 +++++++ tests/test_plugins/test_exalead.py | 7 +++++++ tests/test_plugins/test_github.py | 7 +++++++ tests/test_plugins/test_google.py | 7 +++++++ tests/test_plugins/test_googleplus.py | 7 +++++++ tests/test_plugins/test_instagram.py | 0 tests/test_plugins/test_linkedin.py | 7 +++++++ tests/test_plugins/test_reddit.py | 7 +++++++ tests/test_plugins/test_twitter.py | 7 +++++++ tests/test_plugins/test_yahoo.py | 7 +++++++ tests/test_plugins/test_youtube.py | 7 +++++++ 16 files changed, 98 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_emailharvester.py create mode 100644 tests/test_plugins/test_ask.py create mode 100644 tests/test_plugins/test_baidu.py create mode 100644 tests/test_plugins/test_bing.py create mode 100644 tests/test_plugins/test_dogpile.py create mode 100644 tests/test_plugins/test_exalead.py create mode 100644 tests/test_plugins/test_github.py create mode 100644 tests/test_plugins/test_google.py create mode 100644 tests/test_plugins/test_googleplus.py create mode 100644 tests/test_plugins/test_instagram.py create mode 100644 tests/test_plugins/test_linkedin.py create mode 100644 tests/test_plugins/test_reddit.py create mode 100644 tests/test_plugins/test_twitter.py create mode 100644 tests/test_plugins/test_yahoo.py create mode 100644 tests/test_plugins/test_youtube.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_emailharvester.py b/tests/test_emailharvester.py new file mode 100644 index 0000000..afbac31 --- /dev/null +++ b/tests/test_emailharvester.py @@ -0,0 +1,7 @@ +import unittest +import EmailHarvester + +#template for futher tests +class TestEmailHarvester(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_ask.py b/tests/test_plugins/test_ask.py new file mode 100644 index 0000000..ccd4f8c --- /dev/null +++ b/tests/test_plugins/test_ask.py @@ -0,0 +1,7 @@ +import unittest +from plugins import ask + +#template for futher tests +class TestAskPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_baidu.py b/tests/test_plugins/test_baidu.py new file mode 100644 index 0000000..1e00087 --- /dev/null +++ b/tests/test_plugins/test_baidu.py @@ -0,0 +1,7 @@ +import unittest +from plugins import baidu + +#template for futher tests +class TestBaiduPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_bing.py b/tests/test_plugins/test_bing.py new file mode 100644 index 0000000..bcbcc72 --- /dev/null +++ b/tests/test_plugins/test_bing.py @@ -0,0 +1,7 @@ +import unittest +from plugins import bing + +#template for futher tests +class TestBingPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_dogpile.py b/tests/test_plugins/test_dogpile.py new file mode 100644 index 0000000..f6440d8 --- /dev/null +++ b/tests/test_plugins/test_dogpile.py @@ -0,0 +1,7 @@ +import unittest +from plugins import dogpile + +#template for futher tests +class TestDogpilePlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_exalead.py b/tests/test_plugins/test_exalead.py new file mode 100644 index 0000000..b7cba7e --- /dev/null +++ b/tests/test_plugins/test_exalead.py @@ -0,0 +1,7 @@ +import unittest +from plugins import exalead + +#template for futher tests +class TestExaleadPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_github.py b/tests/test_plugins/test_github.py new file mode 100644 index 0000000..6179ed9 --- /dev/null +++ b/tests/test_plugins/test_github.py @@ -0,0 +1,7 @@ +import unittest +from plugins import github + +#template for futher tests +class TestGitHubPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_google.py b/tests/test_plugins/test_google.py new file mode 100644 index 0000000..d9026c9 --- /dev/null +++ b/tests/test_plugins/test_google.py @@ -0,0 +1,7 @@ +import unittest +from plugins import google + +#template for futher tests +class TestGooglePlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_googleplus.py b/tests/test_plugins/test_googleplus.py new file mode 100644 index 0000000..e2a2cd3 --- /dev/null +++ b/tests/test_plugins/test_googleplus.py @@ -0,0 +1,7 @@ +import unittest +from plugins import googleplus + +#template for futher tests +class TestGooglePlusPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_instagram.py b/tests/test_plugins/test_instagram.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_plugins/test_linkedin.py b/tests/test_plugins/test_linkedin.py new file mode 100644 index 0000000..856c7cd --- /dev/null +++ b/tests/test_plugins/test_linkedin.py @@ -0,0 +1,7 @@ +import unittest +from plugins import linkedin + +#template for futher tests +class TestLinkedInPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_reddit.py b/tests/test_plugins/test_reddit.py new file mode 100644 index 0000000..9c3f88d --- /dev/null +++ b/tests/test_plugins/test_reddit.py @@ -0,0 +1,7 @@ +import unittest +from plugins import reddit + +#template for futher tests +class TestRedditPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_twitter.py b/tests/test_plugins/test_twitter.py new file mode 100644 index 0000000..051b1cc --- /dev/null +++ b/tests/test_plugins/test_twitter.py @@ -0,0 +1,7 @@ +import unittest +from plugins import twitter + +#template for futher tests +class TestTwitterPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_yahoo.py b/tests/test_plugins/test_yahoo.py new file mode 100644 index 0000000..14d4d2a --- /dev/null +++ b/tests/test_plugins/test_yahoo.py @@ -0,0 +1,7 @@ +import unittest +from plugins import yahoo + +#template for futher tests +class TestYahooPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_youtube.py b/tests/test_plugins/test_youtube.py new file mode 100644 index 0000000..d265146 --- /dev/null +++ b/tests/test_plugins/test_youtube.py @@ -0,0 +1,7 @@ +import unittest +from plugins import youtube + +#template for futher tests +class TestYoutubePlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file From 834c1a4828ea3abc40dec7300b7b041f83ca3085 Mon Sep 17 00:00:00 2001 From: Konstantin Didenko Date: Thu, 16 May 2024 02:38:12 +0300 Subject: [PATCH 04/23] Add files via upload --- tests/__init__.py | 0 tests/test_emailharvester.py | 7 +++++++ tests/test_plugins/test_ask.py | 7 +++++++ tests/test_plugins/test_baidu.py | 7 +++++++ tests/test_plugins/test_bing.py | 7 +++++++ tests/test_plugins/test_dogpile.py | 7 +++++++ tests/test_plugins/test_exalead.py | 7 +++++++ tests/test_plugins/test_github.py | 7 +++++++ tests/test_plugins/test_google.py | 7 +++++++ tests/test_plugins/test_googleplus.py | 7 +++++++ tests/test_plugins/test_instagram.py | 7 +++++++ tests/test_plugins/test_linkedin.py | 7 +++++++ tests/test_plugins/test_reddit.py | 7 +++++++ tests/test_plugins/test_twitter.py | 7 +++++++ tests/test_plugins/test_yahoo.py | 7 +++++++ tests/test_plugins/test_youtube.py | 7 +++++++ 16 files changed, 105 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_emailharvester.py create mode 100644 tests/test_plugins/test_ask.py create mode 100644 tests/test_plugins/test_baidu.py create mode 100644 tests/test_plugins/test_bing.py create mode 100644 tests/test_plugins/test_dogpile.py create mode 100644 tests/test_plugins/test_exalead.py create mode 100644 tests/test_plugins/test_github.py create mode 100644 tests/test_plugins/test_google.py create mode 100644 tests/test_plugins/test_googleplus.py create mode 100644 tests/test_plugins/test_instagram.py create mode 100644 tests/test_plugins/test_linkedin.py create mode 100644 tests/test_plugins/test_reddit.py create mode 100644 tests/test_plugins/test_twitter.py create mode 100644 tests/test_plugins/test_yahoo.py create mode 100644 tests/test_plugins/test_youtube.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_emailharvester.py b/tests/test_emailharvester.py new file mode 100644 index 0000000..afbac31 --- /dev/null +++ b/tests/test_emailharvester.py @@ -0,0 +1,7 @@ +import unittest +import EmailHarvester + +#template for futher tests +class TestEmailHarvester(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_ask.py b/tests/test_plugins/test_ask.py new file mode 100644 index 0000000..ccd4f8c --- /dev/null +++ b/tests/test_plugins/test_ask.py @@ -0,0 +1,7 @@ +import unittest +from plugins import ask + +#template for futher tests +class TestAskPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_baidu.py b/tests/test_plugins/test_baidu.py new file mode 100644 index 0000000..1e00087 --- /dev/null +++ b/tests/test_plugins/test_baidu.py @@ -0,0 +1,7 @@ +import unittest +from plugins import baidu + +#template for futher tests +class TestBaiduPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_bing.py b/tests/test_plugins/test_bing.py new file mode 100644 index 0000000..bcbcc72 --- /dev/null +++ b/tests/test_plugins/test_bing.py @@ -0,0 +1,7 @@ +import unittest +from plugins import bing + +#template for futher tests +class TestBingPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_dogpile.py b/tests/test_plugins/test_dogpile.py new file mode 100644 index 0000000..f6440d8 --- /dev/null +++ b/tests/test_plugins/test_dogpile.py @@ -0,0 +1,7 @@ +import unittest +from plugins import dogpile + +#template for futher tests +class TestDogpilePlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_exalead.py b/tests/test_plugins/test_exalead.py new file mode 100644 index 0000000..b7cba7e --- /dev/null +++ b/tests/test_plugins/test_exalead.py @@ -0,0 +1,7 @@ +import unittest +from plugins import exalead + +#template for futher tests +class TestExaleadPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_github.py b/tests/test_plugins/test_github.py new file mode 100644 index 0000000..6179ed9 --- /dev/null +++ b/tests/test_plugins/test_github.py @@ -0,0 +1,7 @@ +import unittest +from plugins import github + +#template for futher tests +class TestGitHubPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_google.py b/tests/test_plugins/test_google.py new file mode 100644 index 0000000..d9026c9 --- /dev/null +++ b/tests/test_plugins/test_google.py @@ -0,0 +1,7 @@ +import unittest +from plugins import google + +#template for futher tests +class TestGooglePlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_googleplus.py b/tests/test_plugins/test_googleplus.py new file mode 100644 index 0000000..e2a2cd3 --- /dev/null +++ b/tests/test_plugins/test_googleplus.py @@ -0,0 +1,7 @@ +import unittest +from plugins import googleplus + +#template for futher tests +class TestGooglePlusPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_instagram.py b/tests/test_plugins/test_instagram.py new file mode 100644 index 0000000..cea96f6 --- /dev/null +++ b/tests/test_plugins/test_instagram.py @@ -0,0 +1,7 @@ +import unittest +from plugins import instagram + +#template for futher tests +class TestInstagramPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_linkedin.py b/tests/test_plugins/test_linkedin.py new file mode 100644 index 0000000..856c7cd --- /dev/null +++ b/tests/test_plugins/test_linkedin.py @@ -0,0 +1,7 @@ +import unittest +from plugins import linkedin + +#template for futher tests +class TestLinkedInPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_reddit.py b/tests/test_plugins/test_reddit.py new file mode 100644 index 0000000..9c3f88d --- /dev/null +++ b/tests/test_plugins/test_reddit.py @@ -0,0 +1,7 @@ +import unittest +from plugins import reddit + +#template for futher tests +class TestRedditPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_twitter.py b/tests/test_plugins/test_twitter.py new file mode 100644 index 0000000..051b1cc --- /dev/null +++ b/tests/test_plugins/test_twitter.py @@ -0,0 +1,7 @@ +import unittest +from plugins import twitter + +#template for futher tests +class TestTwitterPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_yahoo.py b/tests/test_plugins/test_yahoo.py new file mode 100644 index 0000000..14d4d2a --- /dev/null +++ b/tests/test_plugins/test_yahoo.py @@ -0,0 +1,7 @@ +import unittest +from plugins import yahoo + +#template for futher tests +class TestYahooPlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file diff --git a/tests/test_plugins/test_youtube.py b/tests/test_plugins/test_youtube.py new file mode 100644 index 0000000..d265146 --- /dev/null +++ b/tests/test_plugins/test_youtube.py @@ -0,0 +1,7 @@ +import unittest +from plugins import youtube + +#template for futher tests +class TestYoutubePlugin(unittest.TestCase): + def test_(self): + self.assertEqual(1, 1) \ No newline at end of file From 91d1bb94e0590bcc37e4e4288cbde24d26dfd032 Mon Sep 17 00:00:00 2001 From: KD Date: Thu, 23 May 2024 00:18:06 +0300 Subject: [PATCH 05/23] fixing imports in test files --- tests/test_emailharvester.py | 13 +++++++++++-- tests/test_plugins/__init__.py | 0 tests/test_plugins/test_ask.py | 15 ++++++++++++--- tests/test_plugins/test_baidu.py | 15 ++++++++++++--- tests/test_plugins/test_bing.py | 16 +++++++++++++--- tests/test_plugins/test_dogpile.py | 15 ++++++++++++--- tests/test_plugins/test_exalead.py | 16 +++++++++++++--- tests/test_plugins/test_github.py | 15 ++++++++++++--- tests/test_plugins/test_google.py | 14 +++++++++++--- tests/test_plugins/test_googleplus.py | 15 ++++++++++++--- tests/test_plugins/test_instagram.py | 15 ++++++++++++--- tests/test_plugins/test_linkedin.py | 15 ++++++++++++--- tests/test_plugins/test_reddit.py | 15 ++++++++++++--- tests/test_plugins/test_twitter.py | 14 ++++++++++++-- tests/test_plugins/test_yahoo.py | 15 ++++++++++++--- tests/test_plugins/test_youtube.py | 15 ++++++++++++--- 16 files changed, 180 insertions(+), 43 deletions(-) create mode 100644 tests/test_plugins/__init__.py diff --git a/tests/test_emailharvester.py b/tests/test_emailharvester.py index afbac31..1f8c169 100644 --- a/tests/test_emailharvester.py +++ b/tests/test_emailharvester.py @@ -1,7 +1,16 @@ import unittest +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + import EmailHarvester -#template for futher tests class TestEmailHarvester(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/__init__.py b/tests/test_plugins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_plugins/test_ask.py b/tests/test_plugins/test_ask.py index ccd4f8c..28a9be9 100644 --- a/tests/test_plugins/test_ask.py +++ b/tests/test_plugins/test_ask.py @@ -1,7 +1,16 @@ import unittest -from plugins import ask +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.ask import Plugin, search -#template for futher tests class TestAskPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_baidu.py b/tests/test_plugins/test_baidu.py index 1e00087..026f006 100644 --- a/tests/test_plugins/test_baidu.py +++ b/tests/test_plugins/test_baidu.py @@ -1,7 +1,16 @@ import unittest -from plugins import baidu +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.baidu import Plugin, search -#template for futher tests class TestBaiduPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_bing.py b/tests/test_plugins/test_bing.py index bcbcc72..822ced8 100644 --- a/tests/test_plugins/test_bing.py +++ b/tests/test_plugins/test_bing.py @@ -1,7 +1,17 @@ import unittest -from plugins import bing +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.bing import Plugin, search -#template for futher tests class TestBingPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_dogpile.py b/tests/test_plugins/test_dogpile.py index f6440d8..9d8bc70 100644 --- a/tests/test_plugins/test_dogpile.py +++ b/tests/test_plugins/test_dogpile.py @@ -1,7 +1,16 @@ import unittest -from plugins import dogpile +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.dogpile import Plugin, search -#template for futher tests class TestDogpilePlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_exalead.py b/tests/test_plugins/test_exalead.py index b7cba7e..cf212d3 100644 --- a/tests/test_plugins/test_exalead.py +++ b/tests/test_plugins/test_exalead.py @@ -1,7 +1,17 @@ import unittest -from plugins import exalead +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.exalead import Plugin, search + -#template for futher tests class TestExaleadPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_github.py b/tests/test_plugins/test_github.py index 6179ed9..8062574 100644 --- a/tests/test_plugins/test_github.py +++ b/tests/test_plugins/test_github.py @@ -1,7 +1,16 @@ import unittest -from plugins import github +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.github import Plugin, search -#template for futher tests class TestGitHubPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_google.py b/tests/test_plugins/test_google.py index d9026c9..d471a21 100644 --- a/tests/test_plugins/test_google.py +++ b/tests/test_plugins/test_google.py @@ -1,7 +1,15 @@ import unittest -from plugins import google +from unittest.mock import MagicMock, patch +import sys +import os -#template for futher tests +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.google import Plugin, search class TestGooglePlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_googleplus.py b/tests/test_plugins/test_googleplus.py index e2a2cd3..2bffba4 100644 --- a/tests/test_plugins/test_googleplus.py +++ b/tests/test_plugins/test_googleplus.py @@ -1,7 +1,16 @@ import unittest -from plugins import googleplus +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.googleplus import Plugin, search -#template for futher tests class TestGooglePlusPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_instagram.py b/tests/test_plugins/test_instagram.py index cea96f6..11534f4 100644 --- a/tests/test_plugins/test_instagram.py +++ b/tests/test_plugins/test_instagram.py @@ -1,7 +1,16 @@ import unittest -from plugins import instagram +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.instagram import Plugin, search -#template for futher tests class TestInstagramPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_linkedin.py b/tests/test_plugins/test_linkedin.py index 856c7cd..b3dd456 100644 --- a/tests/test_plugins/test_linkedin.py +++ b/tests/test_plugins/test_linkedin.py @@ -1,7 +1,16 @@ import unittest -from plugins import linkedin +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.linkedin import Plugin, search -#template for futher tests class TestLinkedInPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_reddit.py b/tests/test_plugins/test_reddit.py index 9c3f88d..6a7ee14 100644 --- a/tests/test_plugins/test_reddit.py +++ b/tests/test_plugins/test_reddit.py @@ -1,7 +1,16 @@ import unittest -from plugins import reddit +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.reddit import Plugin, search -#template for futher tests class TestRedditPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_twitter.py b/tests/test_plugins/test_twitter.py index 051b1cc..4faeac3 100644 --- a/tests/test_plugins/test_twitter.py +++ b/tests/test_plugins/test_twitter.py @@ -1,7 +1,17 @@ import unittest -from plugins import twitter +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.twitter import Plugin, search #template for futher tests class TestTwitterPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_yahoo.py b/tests/test_plugins/test_yahoo.py index 14d4d2a..15b51e2 100644 --- a/tests/test_plugins/test_yahoo.py +++ b/tests/test_plugins/test_yahoo.py @@ -1,7 +1,16 @@ import unittest -from plugins import yahoo +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.yahoo import Plugin, search -#template for futher tests class TestYahooPlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_youtube.py b/tests/test_plugins/test_youtube.py index d265146..5ca88b9 100644 --- a/tests/test_plugins/test_youtube.py +++ b/tests/test_plugins/test_youtube.py @@ -1,7 +1,16 @@ import unittest -from plugins import youtube +from unittest.mock import MagicMock, patch +import sys +import os + +# Add the root directory of your project to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +from plugins.youtube import Plugin, search -#template for futher tests class TestYoutubePlugin(unittest.TestCase): def test_(self): - self.assertEqual(1, 1) \ No newline at end of file + self.assertEqual(1, 1) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From 4e9f1cc209c1bd56a191cd9bfe87e4ccfdf47329 Mon Sep 17 00:00:00 2001 From: KD Date: Sat, 25 May 2024 00:25:18 +0300 Subject: [PATCH 06/23] Unit tests for google plugin in plugins/google.py --- tests/test_plugins/test_google.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_google.py b/tests/test_plugins/test_google.py index d471a21..983242e 100644 --- a/tests/test_plugins/test_google.py +++ b/tests/test_plugins/test_google.py @@ -8,8 +8,32 @@ from plugins.google import Plugin, search class TestGooglePlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('google', {'search': search}) + + @patch('plugins.google.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(return_value = ['john_doe@email.com']) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_url = 'https://www.google.com/search?num=100&start={counter}&hl=en&q="%40{word}"' + + mock_app_emailharvester.init_search(expected_url, domain, limit, 0, 100, 'Google') + mock_app_emailharvester.process.assert_called_once() + mock_app_emailharvester.get_emails.assert_called_once() + + self.assertEqual(result,['john_doe@email.com']) + if __name__ == '__main__': unittest.main() \ No newline at end of file From 2d7fa54a08009809c4d89960b5310aef79791f02 Mon Sep 17 00:00:00 2001 From: KD Date: Sat, 25 May 2024 22:28:42 +0300 Subject: [PATCH 07/23] Unit tests for youtube plugin in plugins/youtube.py --- tests/test_plugins/test_youtube.py | 40 ++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_youtube.py b/tests/test_plugins/test_youtube.py index 5ca88b9..e598141 100644 --- a/tests/test_plugins/test_youtube.py +++ b/tests/test_plugins/test_youtube.py @@ -9,8 +9,44 @@ from plugins.youtube import Plugin, search class TestYoutubePlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('youtube', {'search': search}) + + @patch('plugins.youtube.app_emailharvester') + def test_search(self, mock_app_emailharvester): + all_emails = [] + + mock_app_emailharvester.init = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(side_effect=[ + ['22@email.com', 'john.doe@email.com'], + [], + ['2212@email.com'], + [], + [] + ]) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_calls = [ + unittest.mock.call("http://search.yahoo.com/search?p=site%3Ayoutube.com+%40{word}&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vd=all&vst=0&vf=all&vm=p&fl=0&fr=yfp-t-152&xargs=0&pstart=1&b={counter}", domain, limit, 1, 100, 'Yahoo + Youtube'), + unittest.mock.call("http://www.bing.com/search?q=site%3Ayoutube.com+%40{word}&count=50&first={counter}", domain, limit, 0, 50, 'Bing + Youtube'), + unittest.mock.call('https://www.google.com/search?num=100&start={counter}&hl=en&q=site%3Ayoutube.com+"%40{word}"', domain, limit, 0, 100, 'Google + Youtube'), + unittest.mock.call('http://www.baidu.com/search/s?wd=site%3Ayoutube.com+"%40{word}"&pn={counter}', domain, limit, 0, 10, 'Baidu + Youtube'), + unittest.mock.call("http://www.exalead.com/search/web/results/?q=site%3Ayoutube.com+%40{word}&elements_per_page=10&start_index={counter}", domain, limit, 0, 50, 'Exalead + Youtube') + ] + + mock_app_emailharvester.init_search.assert_has_calls(expected_calls) + + self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + if __name__ == '__main__': unittest.main() \ No newline at end of file From 3f2cc4d792824e93ab721d88e0cc55a3dd2b9f10 Mon Sep 17 00:00:00 2001 From: KD Date: Sat, 25 May 2024 23:48:05 +0300 Subject: [PATCH 08/23] Unit tests for yahoo plugin in plugins/yahoo.py --- tests/test_plugins/test_yahoo.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_yahoo.py b/tests/test_plugins/test_yahoo.py index 15b51e2..fe86241 100644 --- a/tests/test_plugins/test_yahoo.py +++ b/tests/test_plugins/test_yahoo.py @@ -9,8 +9,33 @@ from plugins.yahoo import Plugin, search class TestYahooPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('yahoo', {'search': search}) + + @patch('plugins.yahoo.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(return_value = ['john_doe@email.com']) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_url = "http://search.yahoo.com/search?p=%40{word}&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vd=all&vst=0&vf=all&vm=p&fl=0&fr=yfp-t-152&xargs=0&pstart=1&b={counter}" + + mock_app_emailharvester.init_search(expected_url, domain, limit, 1, 100, 'Yahoo') + mock_app_emailharvester.process.assert_called_once() + mock_app_emailharvester.get_emails.assert_called_once() + + self.assertEqual(result,['john_doe@email.com']) + + if __name__ == '__main__': unittest.main() \ No newline at end of file From 58ac971c50553b99090c0c63ce1ed223405a19e7 Mon Sep 17 00:00:00 2001 From: KD Date: Sun, 26 May 2024 00:55:58 +0300 Subject: [PATCH 09/23] Unit tests for twitter plugin in plugins/twitter.py --- tests/test_plugins/test_twitter.py | 38 ++++++++++++++++++++++++++++-- tests/test_plugins/test_youtube.py | 1 - 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/test_plugins/test_twitter.py b/tests/test_plugins/test_twitter.py index 4faeac3..734b432 100644 --- a/tests/test_plugins/test_twitter.py +++ b/tests/test_plugins/test_twitter.py @@ -10,8 +10,42 @@ #template for futher tests class TestTwitterPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('twitter', {'search':search}) + + @patch('plugins.twitter.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(side_effect=[ + ['22@email.com', 'john.doe@email.com'], + [], + ['2212@email.com'], + [], + [] + ]) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_calls = [ + unittest.mock.call('http://search.yahoo.com/search?p=site%3Atwitter.com+intitle:"on Twitter"+%40{word}&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vd=all&vst=0&vf=all&vm=p&fl=0&fr=yfp-t-152&xargs=0&pstart=1&b={counter}', domain, limit, 1, 100, 'Yahoo + Twitter'), + unittest.mock.call('http://www.bing.com/search?q=site%3Atwitter.com+intitle:"on Twitter"+%40{word}&count=50&first={counter}', domain, limit, 0, 50, 'Bing + Twitter'), + unittest.mock.call('https://www.google.com/search?num=100&start={counter}&hl=en&q=site%3Atwitter.com+intitle:"on Twitter"+"%40{word}"', domain, limit, 0, 100, 'Google + Twitter'), + unittest.mock.call('http://www.baidu.com/search/s?wd=site%3Atwitter.com+intitle:"on Twitter"+"%40{word}"&pn={counter}', domain, limit, 0, 10, 'Baidu + Twitter'), + unittest.mock.call('http://www.exalead.com/search/web/results/?q=site%3Atwitter.com+intitle:"on Twitter"+%40{word}&elements_per_page=10&start_index={counter}', domain, limit, 0, 50, 'Exalead + Twitter') + ] + + mock_app_emailharvester.init_search.assert_has_calls(expected_calls) + + self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_youtube.py b/tests/test_plugins/test_youtube.py index e598141..7e87995 100644 --- a/tests/test_plugins/test_youtube.py +++ b/tests/test_plugins/test_youtube.py @@ -19,7 +19,6 @@ def test_plugin_init(self): @patch('plugins.youtube.app_emailharvester') def test_search(self, mock_app_emailharvester): - all_emails = [] mock_app_emailharvester.init = MagicMock() mock_app_emailharvester.process = MagicMock() From be9577f652de5bf6735d6268849d6db3df865f73 Mon Sep 17 00:00:00 2001 From: KD Date: Sun, 26 May 2024 18:11:21 +0300 Subject: [PATCH 10/23] Unit tests for reddit plugin in plugins/reddit.py --- tests/test_plugins/test_reddit.py | 38 +++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_reddit.py b/tests/test_plugins/test_reddit.py index 6a7ee14..299762f 100644 --- a/tests/test_plugins/test_reddit.py +++ b/tests/test_plugins/test_reddit.py @@ -9,8 +9,42 @@ from plugins.reddit import Plugin, search class TestRedditPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('reddit', {'search': search}) + + @patch('plugins.reddit.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.show_message = MagicMock() + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(side_effect=[ + ['22@email.com', 'john.doe@email.com'], + [], + ['2212@email.com'], + [], + [] + ]) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_calls = [ + unittest.mock.call('http://search.yahoo.com/search?p=site%3Areddit.com+%40{word}&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vd=all&vst=0&vf=all&vm=p&fl=0&fr=yfp-t-152&xargs=0&pstart=1&b={counter}', domain, limit, 1, 100, 'Yahoo + Reddit'), + unittest.mock.call('http://www.bing.com/search?q=site%3Areddit.com+%40{word}&count=50&first={counter}', domain, limit, 0, 50, 'Bing + Reddit'), + unittest.mock.call('https://www.google.com/search?num=100&start={counter}&hl=en&q=site%3Areddit.com+"%40{word}"', domain, limit, 0, 100, 'Google + Reddit'), + unittest.mock.call('http://www.baidu.com/search/s?wd=site%3Areddit.com+"%40{word}"&pn={counter}', domain, limit, 0, 10, 'Baidu + Reddit'), + unittest.mock.call('http://www.exalead.com/search/web/results/?q=site%3Areddit.com+%40{word}&elements_per_page=10&start_index={counter}', domain, limit, 0, 50, 'Exalead + Reddit') + ] + + mock_app_emailharvester.init_search.assert_has_calls(expected_calls) + + self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) if __name__ == '__main__': unittest.main() \ No newline at end of file From 515af864e1502c7042332c219c0858280a067341 Mon Sep 17 00:00:00 2001 From: KD Date: Sun, 26 May 2024 18:23:07 +0300 Subject: [PATCH 11/23] Fixing mistypes in test_twitter.py and test_youtube.py: mock_app_emailharvester.init = MagicMock() -> mock_app_emailharvester.init_search = MagicMock() Added mock_app_emailharvester.show_message = MagicMock() --- tests/test_plugins/test_twitter.py | 3 ++- tests/test_plugins/test_youtube.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_plugins/test_twitter.py b/tests/test_plugins/test_twitter.py index 734b432..7fb78c4 100644 --- a/tests/test_plugins/test_twitter.py +++ b/tests/test_plugins/test_twitter.py @@ -20,7 +20,8 @@ def test_plugin_init(self): @patch('plugins.twitter.app_emailharvester') def test_search(self, mock_app_emailharvester): - mock_app_emailharvester.init = MagicMock() + mock_app_emailharvester.show_message = MagicMock() + mock_app_emailharvester.init_search = MagicMock() mock_app_emailharvester.process = MagicMock() mock_app_emailharvester.get_emails = MagicMock(side_effect=[ ['22@email.com', 'john.doe@email.com'], diff --git a/tests/test_plugins/test_youtube.py b/tests/test_plugins/test_youtube.py index 7e87995..d2f2002 100644 --- a/tests/test_plugins/test_youtube.py +++ b/tests/test_plugins/test_youtube.py @@ -19,8 +19,8 @@ def test_plugin_init(self): @patch('plugins.youtube.app_emailharvester') def test_search(self, mock_app_emailharvester): - - mock_app_emailharvester.init = MagicMock() + mock_app_emailharvester.show_message = MagicMock() + mock_app_emailharvester.init_search = MagicMock() mock_app_emailharvester.process = MagicMock() mock_app_emailharvester.get_emails = MagicMock(side_effect=[ ['22@email.com', 'john.doe@email.com'], From c8e17c67d5d24d6c066974dc819edb6f6b1c0336 Mon Sep 17 00:00:00 2001 From: KD Date: Tue, 28 May 2024 00:16:02 +0300 Subject: [PATCH 12/23] Unit tests for linkedin plugin in plugins/linkedin.py --- tests/test_plugins/test_linkedin.py | 38 +++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_linkedin.py b/tests/test_plugins/test_linkedin.py index b3dd456..2feb6ce 100644 --- a/tests/test_plugins/test_linkedin.py +++ b/tests/test_plugins/test_linkedin.py @@ -9,8 +9,42 @@ from plugins.linkedin import Plugin, search class TestLinkedInPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('linkedin', {'search': search}) + + @patch('plugins.linkedin.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.show_message = MagicMock() + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(side_effect=[ + ['22@email.com', 'john.doe@email.com'], + [], + ['2212@email.com'], + [], + [] + ]) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_calls = [ + unittest.mock.call('http://search.yahoo.com/search?p=site%3Alinkedin.com+%40{word}&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vd=all&vst=0&vf=all&vm=p&fl=0&fr=yfp-t-152&xargs=0&pstart=1&b={counter}', domain, limit, 1, 100, 'Yahoo + Linkedin'), + unittest.mock.call('http://www.bing.com/search?q=site%3Alinkedin.com+%40{word}&count=50&first={counter}', domain, limit, 0, 50, 'Bing + Linkedin'), + unittest.mock.call('https://www.google.com/search?num=100&start={counter}&hl=en&q=site%3Alinkedin.com+"%40{word}"', domain, limit, 0, 100, 'Google + Linkedin'), + unittest.mock.call('http://www.baidu.com/search/s?wd=site%3Alinkedin.com+"%40{word}"&pn={counter}', domain, limit, 0, 10, 'Baidu + Linkedin'), + unittest.mock.call('http://www.exalead.com/search/web/results/?q=site%3Alinkedin.com+%40{word}&elements_per_page=10&start_index={counter}', domain, limit, 0, 50, 'Exalead + Linkedin') + ] + + mock_app_emailharvester.init_search.assert_has_calls(expected_calls) + + self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) if __name__ == '__main__': unittest.main() \ No newline at end of file From 66183e5a4ff91220bbf5babb15ee5185a9deb726 Mon Sep 17 00:00:00 2001 From: KD Date: Tue, 28 May 2024 00:35:33 +0300 Subject: [PATCH 13/23] Unit tests for instagram plugin in plugins/instagram.py --- tests/test_plugins/test_instagram.py | 39 ++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_instagram.py b/tests/test_plugins/test_instagram.py index 11534f4..2067721 100644 --- a/tests/test_plugins/test_instagram.py +++ b/tests/test_plugins/test_instagram.py @@ -9,8 +9,43 @@ from plugins.instagram import Plugin, search class TestInstagramPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('instagram', {'search': search}) + + @patch('plugins.instagram.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.show_message = MagicMock() + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(side_effect=[ + ['22@email.com', 'john.doe@email.com'], + [], + ['2212@email.com'], + [], + [] + ]) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_calls = [ + unittest.mock.call('http://search.yahoo.com/search?p=site%3Ainstagram.com+%40{word}&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vd=all&vst=0&vf=all&vm=p&fl=0&fr=yfp-t-152&xargs=0&pstart=1&b={counter}', domain, limit, 1, 100, 'Yahoo + Instagram'), + unittest.mock.call('http://www.bing.com/search?q=site%3Ainstagram.com+%40{word}&count=50&first={counter}', domain, limit, 0, 50, 'Bing + Instagram'), + unittest.mock.call('https://www.google.com/search?num=100&start={counter}&hl=en&q=site%3Ainstagram.com+"%40{word}"', domain, limit, 0, 100, 'Google + Instagram'), + unittest.mock.call('http://www.baidu.com/search/s?wd=site%3Ainstagram.com+"%40{word}"&pn={counter}', domain, limit, 0, 10, 'Baidu + Instagram'), + unittest.mock.call('http://www.exalead.com/search/web/results/?q=site%3Ainstagram.com+%40{word}&elements_per_page=10&start_index={counter}', domain, limit, 0, 50, 'Exalead + Instagram') + ] + + mock_app_emailharvester.init_search.assert_has_calls(expected_calls) + + self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + if __name__ == '__main__': unittest.main() \ No newline at end of file From 0e043f14c08f6426c0f251741ac51617dfed9cc4 Mon Sep 17 00:00:00 2001 From: KD Date: Tue, 28 May 2024 01:02:22 +0300 Subject: [PATCH 14/23] Unit tests for googleplus plugin in plugins/googleplus.py --- tests/test_plugins/test_googleplus.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_googleplus.py b/tests/test_plugins/test_googleplus.py index 2bffba4..44662b6 100644 --- a/tests/test_plugins/test_googleplus.py +++ b/tests/test_plugins/test_googleplus.py @@ -9,8 +9,31 @@ from plugins.googleplus import Plugin, search class TestGooglePlusPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('googleplus', {'search': search}) + + @patch('plugins.googleplus.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(return_value = ['john_doe@email.com']) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_url = 'https://www.google.com/search?num=100&start={counter}&hl=en&q=site%3Aplus.google.com+intext:"Works at"+-inurl:photos+-inurl:about+-inurl:posts+-inurl:plusones+%40{word}' + + mock_app_emailharvester.init_search(expected_url, domain, limit, 0, 100, 'Google+') + mock_app_emailharvester.process.assert_called_once() + mock_app_emailharvester.get_emails.assert_called_once() + + self.assertEqual(result,['john_doe@email.com']) if __name__ == '__main__': unittest.main() \ No newline at end of file From 78b61a50c9a8c42210b5ff6c754f3ecf2abfe235 Mon Sep 17 00:00:00 2001 From: KD Date: Tue, 28 May 2024 01:24:32 +0300 Subject: [PATCH 15/23] Unit tests for github plugin in plugins/github.py --- tests/test_plugins/test_github.py | 39 +++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_github.py b/tests/test_plugins/test_github.py index 8062574..6cb6a63 100644 --- a/tests/test_plugins/test_github.py +++ b/tests/test_plugins/test_github.py @@ -9,8 +9,43 @@ from plugins.github import Plugin, search class TestGitHubPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('github', {'search': search}) + + @patch('plugins.github.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.show_message = MagicMock() + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(side_effect=[ + ['22@email.com', 'john.doe@email.com'], + [], + ['2212@email.com'], + [], + [] + ]) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_calls = [ + unittest.mock.call('http://search.yahoo.com/search?p=site%3Agithub.com+%40{word}&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vd=all&vst=0&vf=all&vm=p&fl=0&fr=yfp-t-152&xargs=0&pstart=1&b={counter}', domain, limit, 1, 100, 'Yahoo + Github'), + unittest.mock.call('http://www.bing.com/search?q=site%3Agithub.com+%40{word}&count=50&first={counter}', domain, limit, 0, 50, 'Bing + Github'), + unittest.mock.call('https://www.google.com/search?num=100&start={counter}&hl=en&q=site%3Agithub.com+"%40{word}"', domain, limit, 0, 100, 'Google + Github'), + unittest.mock.call('http://www.baidu.com/search/s?wd=site%3Agithub.com+"%40{word}"&pn={counter}', domain, limit, 0, 10, 'Baidu + Github'), + unittest.mock.call('http://www.exalead.com/search/web/results/?q=site%3Agithub.com+%40{word}&elements_per_page=10&start_index={counter}', domain, limit, 0, 50, 'Exalead + Github') + ] + + mock_app_emailharvester.init_search.assert_has_calls(expected_calls) + + self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + if __name__ == '__main__': unittest.main() \ No newline at end of file From e8773bb6b1510a6109bb63488d94e4c1de27e2e6 Mon Sep 17 00:00:00 2001 From: KD Date: Tue, 28 May 2024 01:43:33 +0300 Subject: [PATCH 16/23] Unit tests for exalead plugin in plugins/exalead.py --- tests/test_plugins/test_exalead.py | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_exalead.py b/tests/test_plugins/test_exalead.py index cf212d3..f42f833 100644 --- a/tests/test_plugins/test_exalead.py +++ b/tests/test_plugins/test_exalead.py @@ -10,8 +10,35 @@ class TestExaleadPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('exalead', {'search': search}) + + @patch('plugins.exalead.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(return_value = ['john_doe@email.com']) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_url = 'http://www.exalead.com/search/web/results/?q=%40{word}&elements_per_page=10&start_index={counter}' + + mock_app_emailharvester.init_search(expected_url, domain, limit, 0, 50, 'Exalead') + mock_app_emailharvester.process.assert_called_once() + mock_app_emailharvester.get_emails.assert_called_once() + + self.assertEqual(result,['john_doe@email.com']) + + + + if __name__ == '__main__': unittest.main() \ No newline at end of file From d970715cab8a2681c948412fe26e6f8a7de8b14d Mon Sep 17 00:00:00 2001 From: KD Date: Tue, 28 May 2024 01:59:47 +0300 Subject: [PATCH 17/23] Unit tests for dogpile plugin in plugins/dogpile.py --- tests/test_plugins/test_dogpile.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_dogpile.py b/tests/test_plugins/test_dogpile.py index 9d8bc70..ba0d298 100644 --- a/tests/test_plugins/test_dogpile.py +++ b/tests/test_plugins/test_dogpile.py @@ -9,8 +9,31 @@ from plugins.dogpile import Plugin, search class TestDogpilePlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('dogpile', {'search': search}) + + @patch('plugins.dogpile.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(return_value = ['john_doe@email.com']) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_url = 'http://www.dogpile.com/search/web?qsi={counter}&q="%40{word}"' + + mock_app_emailharvester.init_search(expected_url, domain, limit, 1, 10, 'Dogpile') + mock_app_emailharvester.process.assert_called_once() + mock_app_emailharvester.get_emails.assert_called_once() + + self.assertEqual(result,['john_doe@email.com']) if __name__ == '__main__': unittest.main() \ No newline at end of file From 5f08270f3866463abaa5b2ac942be5bc1784760a Mon Sep 17 00:00:00 2001 From: KD Date: Wed, 29 May 2024 16:09:59 +0300 Subject: [PATCH 18/23] Unit tests for bing plugin in plugins/bing.py --- tests/test_plugins/test_bing.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_bing.py b/tests/test_plugins/test_bing.py index 822ced8..a7ba120 100644 --- a/tests/test_plugins/test_bing.py +++ b/tests/test_plugins/test_bing.py @@ -9,9 +9,31 @@ from plugins.bing import Plugin, search class TestBingPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('bing', {'search': search}) + + @patch('plugins.bing.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(return_value = ['john_doe@email.com']) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_url = 'http://www.bing.com/search?q=%40{word}&count=50&first={counter}' + + mock_app_emailharvester.init_search(expected_url, domain, limit, 0, 50, 'Bing') + mock_app_emailharvester.process.assert_called_once() + mock_app_emailharvester.get_emails.assert_called_once() + + self.assertEqual(result,['john_doe@email.com']) if __name__ == '__main__': unittest.main() \ No newline at end of file From 6be20c605c79a9496bf52ae2de11364f43eb6a31 Mon Sep 17 00:00:00 2001 From: KD Date: Wed, 29 May 2024 16:23:48 +0300 Subject: [PATCH 19/23] Unit tests for baidu plugin in plugins/baidu.py --- tests/test_plugins/test_baidu.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/test_plugins/test_baidu.py b/tests/test_plugins/test_baidu.py index 026f006..3d56e14 100644 --- a/tests/test_plugins/test_baidu.py +++ b/tests/test_plugins/test_baidu.py @@ -9,8 +9,34 @@ from plugins.baidu import Plugin, search class TestBaiduPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('baidu', {'search': search}) + + @patch('plugins.baidu.app_emailharvester') + def test_search(self, mock_app_emailharvester): + mock_app_emailharvester.init_search = MagicMock() + mock_app_emailharvester.process = MagicMock() + mock_app_emailharvester.get_emails = MagicMock(return_value = ['john_doe@email.com']) + + domain = "email.com" + limit = 10 + result = search(domain,limit) + + expected_url = 'http://www.baidu.com/search/s?wd="%40{word}"&pn={counter}' + + mock_app_emailharvester.init_search(expected_url, domain, limit, 0, 10, 'Baidu') + mock_app_emailharvester.process.assert_called_once() + mock_app_emailharvester.get_emails.assert_called_once() + + self.assertEqual(result,['john_doe@email.com']) + + + if __name__ == '__main__': unittest.main() \ No newline at end of file From 202dceff0dfa4598011630d5f181aa68c4fd36a3 Mon Sep 17 00:00:00 2001 From: KD Date: Fri, 31 May 2024 23:30:33 +0300 Subject: [PATCH 20/23] Unit tests for ask plugin in plugins/ask.py --- tests/test_plugins/test_ask.py | 59 ++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/tests/test_plugins/test_ask.py b/tests/test_plugins/test_ask.py index 28a9be9..c8e379b 100644 --- a/tests/test_plugins/test_ask.py +++ b/tests/test_plugins/test_ask.py @@ -6,11 +6,64 @@ # Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) -from plugins.ask import Plugin, search +from plugins.ask import Plugin, search, AskSearch class TestAskPlugin(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.app_mock = MagicMock() + self.config = {'useragent':'test-agent', 'proxy': None} + self.plugin = Plugin(self.app_mock, self.config) + + def test_plugin_init(self): + self.app_mock.register_plugin.assert_called_once_with('ask', {'search': search}) + + @patch('plugins.ask.config', new_callable=dict) + @patch('plugins.ask.requests.get') + @patch('plugins.ask.app_emailharvester') + def test_search(self, mock_app_emailharvester, mock_requests_get, mock_config): + # Setup mock configuration + mock_config['proxy'] = None + mock_config['useragent'] = 'test-agent' + + # Mock parser methods + mock_app_emailharvester.parser = MagicMock() + mock_app_emailharvester.parser.extract = MagicMock() + mock_app_emailharvester.parser.emails = MagicMock(return_value=['john_doe@email.com']) + + # Mock the HTTP response from requests.get + mock_response = MagicMock() + mock_response.content.decode.return_value = "response content" + mock_response.encoding = 'utf-8' + mock_requests_get.return_value = mock_response + + domain = "email.com" + limit = 10 + + # Execute the search function + result = search(domain, limit) + + #--- + + expected_url_template = 'http://www.ask.com/web?q=%40{word}&page={page}' + + # Extract called URLs from requests.get + urls_called = [call[0][0] for call in mock_requests_get.call_args_list] + + # Generate expected URLs + expected_urls = [expected_url_template.format(word=domain, page=i+1) for i in range(limit // 10)] + + # Verify that each expected URL was called + for expected_url in expected_urls: + self.assertIn(expected_url, urls_called, f"{expected_url} was not called") + + #--- + + # Verify that the parser methods were called correctly + mock_app_emailharvester.parser.extract.assert_called_once_with("response content", domain) + mock_app_emailharvester.parser.emails.assert_called_once() + + # Check the result of the search function + self.assertEqual(result, ['john_doe@email.com']) if __name__ == '__main__': unittest.main() \ No newline at end of file From a65fcec4d2bc35d8a46c9fda49d0ab6237b51841 Mon Sep 17 00:00:00 2001 From: KD Date: Sat, 8 Jun 2024 14:42:09 +0300 Subject: [PATCH 21/23] Unit tests for class myparser in EmailHarvester.py --- tests/test_myparser.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test_myparser.py diff --git a/tests/test_myparser.py b/tests/test_myparser.py new file mode 100644 index 0000000..21bdff5 --- /dev/null +++ b/tests/test_myparser.py @@ -0,0 +1,40 @@ +import unittest +from unittest.mock import MagicMock, patch +import sys +import os + +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) + +import EmailHarvester + +class TestMyParser(unittest.TestCase): + def setUp(self): + self.testParser = EmailHarvester.myparser() + + def test_extract(self): + self.testParser.extract("some results", "example.com") + self.assertEqual(self.testParser.results, "some results") + self.assertEqual(self.testParser.word, "example.com") + + + def test_genericClean(self): + self.testParser.extract("test%2femail", "example.com") + self.testParser.genericClean() + expected_result = "test email" + self.assertEqual(self.testParser.results, expected_result) + + def test_emails(self): + self.testParser.extract("Contact us at info@example.com and support@example.com", "example.com") + emails = self.testParser.emails() + expected_emails = ["info@example.com", "support@example.com"] + self.assertEqual(set(emails), set(expected_emails)) + + def test_unique(self): + self.testParser.temp = ["duplicate@example.com", "unique@example.com", "duplicate@example.com"] + unique_emails = self.testParser.unique() + expected_unique_emails = ["duplicate@example.com", "unique@example.com"] + self.assertEqual(set(unique_emails), set(expected_unique_emails)) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From dfc15fdc105ed5245c2cb363cbbfe5ef8d2262f2 Mon Sep 17 00:00:00 2001 From: KD Date: Sat, 8 Jun 2024 18:38:36 +0300 Subject: [PATCH 22/23] Unit tests for class EmailHarvester in EmailHarvester.py --- tests/test_emailharvester.py | 95 ++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 4 deletions(-) diff --git a/tests/test_emailharvester.py b/tests/test_emailharvester.py index 1f8c169..4db965e 100644 --- a/tests/test_emailharvester.py +++ b/tests/test_emailharvester.py @@ -1,16 +1,103 @@ import unittest -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock, patch, Mock import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) import EmailHarvester class TestEmailHarvester(unittest.TestCase): - def test_(self): - self.assertEqual(1, 1) + def setUp(self): + self.userAgent = 'test-agent' + self.proxy = None + self.emailHarvester = EmailHarvester.EmailHarvester(self.userAgent, self.proxy) + + def test_register_plugin(self): + mock_function = MagicMock() + + self.emailHarvester.register_plugin('test_method', {'function': mock_function}) + + self.assertIn('test_method', self.emailHarvester.plugins) + self.assertEqual(self.emailHarvester.plugins['test_method'], {'function': mock_function}) + + def test_get_plugins(self): + mock_function1 = MagicMock() + self.emailHarvester.register_plugin('test_method1', {'function1': mock_function1}) + + mock_function2 = MagicMock() + self.emailHarvester.register_plugin('test_method2', {'function2': mock_function2}) + + self.assertEqual(self.emailHarvester.get_plugins(), self.emailHarvester.plugins) + + @patch('builtins.print') + def test_show_message(self, mock_print): + test_message = "Test message" + self.emailHarvester.show_message(test_message) + mock_print.assert_called_once_with(test_message) + + def test_init_search(self): + url = 'http://example.com/search?q={word}&start={counter}' + word = 'test' + limit = 100 + counterInit = 0 + counterStep = 10 + engineName = 'Test-Engine' + + self.emailHarvester.init_search(url, word, limit, counterInit, counterStep, engineName) + + self.assertEqual(self.emailHarvester.url, url) + self.assertEqual(self.emailHarvester.word, word) + self.assertEqual(self.emailHarvester.limit, limit) + self.assertEqual(self.emailHarvester.counter, counterInit) + self.assertEqual(self.emailHarvester.step, counterStep) + self.assertEqual(self.emailHarvester.activeEngine, engineName) + self.assertEqual(self.emailHarvester.results, "") + self.assertEqual(self.emailHarvester.totalresults, "") + + @patch('requests.get') + def test_do_search(self, mock_get): + url = "http://example.com/search?q={word}&start={counter}" + word = "test" + response_content = "Search results content" + mock_response = Mock() + mock_response.content = response_content.encode('utf-8') + mock_response.encoding = 'utf-8' + mock_get.return_value = mock_response + + self.emailHarvester.init_search(url, word, 1, 0, 1, "ExampleEngine") + self.emailHarvester.do_search() + + expected_url = url.format(counter = '0', word = word) + mock_get.assert_called_once_with(expected_url, headers={'User-Agent': self.userAgent}) + self.assertEqual(self.emailHarvester.results, response_content) + self.assertEqual(self.emailHarvester.totalresults, response_content) + + @patch('time.sleep', return_value = None) + @patch('requests.get') + @patch('builtins.print') + def test_process(self, mock_print, mock_get, mock_sleep): + url = "http://example.com/search?q={word}&start={counter}" + word = "test" + response_content = "Search results content" + mock_response = Mock() + mock_response.content = response_content.encode('utf-8') + mock_response.encoding = 'utf-8' + mock_get.return_value = mock_response + + self.emailHarvester.init_search(url, word, 20, 0, 10, "ExampleEngine") + self.emailHarvester.process() + + self.assertEqual(mock_get.call_count, 2) + self.assertEqual(self.emailHarvester.counter, 20) + self.assertEqual(self.emailHarvester.totalresults, response_content * 2) + + def test_get_emails(self): + self.emailHarvester.totalresults = "Contact us at info@example.com and support@example.com" + self.emailHarvester.word = "example.com" + emails = self.emailHarvester.get_emails() + expected_emails = ["info@example.com", "support@example.com"] + self.assertEqual(set(emails), set(expected_emails)) if __name__ == '__main__': unittest.main() \ No newline at end of file From 5d6eda7c325356e66c60d9b4e7a521f99998af99 Mon Sep 17 00:00:00 2001 From: KD Date: Wed, 12 Jun 2024 23:22:51 +0300 Subject: [PATCH 23/23] Made some cosmetic edits --- tests/test_emailharvester.py | 30 +++++++++++++-------------- tests/test_myparser.py | 10 ++++----- tests/test_plugins/test_ask.py | 3 +-- tests/test_plugins/test_baidu.py | 3 +-- tests/test_plugins/test_bing.py | 3 +-- tests/test_plugins/test_dogpile.py | 3 +-- tests/test_plugins/test_exalead.py | 3 +-- tests/test_plugins/test_github.py | 3 +-- tests/test_plugins/test_google.py | 3 +-- tests/test_plugins/test_googleplus.py | 3 +-- tests/test_plugins/test_instagram.py | 3 +-- tests/test_plugins/test_linkedin.py | 3 +-- tests/test_plugins/test_reddit.py | 3 +-- tests/test_plugins/test_twitter.py | 4 +--- tests/test_plugins/test_yahoo.py | 3 +-- tests/test_plugins/test_youtube.py | 3 +-- 16 files changed, 34 insertions(+), 49 deletions(-) diff --git a/tests/test_emailharvester.py b/tests/test_emailharvester.py index 4db965e..7670ada 100644 --- a/tests/test_emailharvester.py +++ b/tests/test_emailharvester.py @@ -19,7 +19,7 @@ def test_register_plugin(self): self.emailHarvester.register_plugin('test_method', {'function': mock_function}) self.assertIn('test_method', self.emailHarvester.plugins) - self.assertEqual(self.emailHarvester.plugins['test_method'], {'function': mock_function}) + self.assertEqual({'function': mock_function}, self.emailHarvester.plugins['test_method']) def test_get_plugins(self): mock_function1 = MagicMock() @@ -46,14 +46,14 @@ def test_init_search(self): self.emailHarvester.init_search(url, word, limit, counterInit, counterStep, engineName) - self.assertEqual(self.emailHarvester.url, url) - self.assertEqual(self.emailHarvester.word, word) - self.assertEqual(self.emailHarvester.limit, limit) - self.assertEqual(self.emailHarvester.counter, counterInit) - self.assertEqual(self.emailHarvester.step, counterStep) - self.assertEqual(self.emailHarvester.activeEngine, engineName) - self.assertEqual(self.emailHarvester.results, "") - self.assertEqual(self.emailHarvester.totalresults, "") + self.assertEqual(url, self.emailHarvester.url) + self.assertEqual(word, self.emailHarvester.word) + self.assertEqual(limit, self.emailHarvester.limit) + self.assertEqual(counterInit, self.emailHarvester.counter) + self.assertEqual(counterStep, self.emailHarvester.step) + self.assertEqual(engineName, self.emailHarvester.activeEngine) + self.assertEqual("",self.emailHarvester.results) + self.assertEqual("", self.emailHarvester.totalresults) @patch('requests.get') def test_do_search(self, mock_get): @@ -70,8 +70,8 @@ def test_do_search(self, mock_get): expected_url = url.format(counter = '0', word = word) mock_get.assert_called_once_with(expected_url, headers={'User-Agent': self.userAgent}) - self.assertEqual(self.emailHarvester.results, response_content) - self.assertEqual(self.emailHarvester.totalresults, response_content) + self.assertEqual(response_content, self.emailHarvester.results) + self.assertEqual(response_content, self.emailHarvester.totalresults) @patch('time.sleep', return_value = None) @patch('requests.get') @@ -88,16 +88,16 @@ def test_process(self, mock_print, mock_get, mock_sleep): self.emailHarvester.init_search(url, word, 20, 0, 10, "ExampleEngine") self.emailHarvester.process() - self.assertEqual(mock_get.call_count, 2) - self.assertEqual(self.emailHarvester.counter, 20) - self.assertEqual(self.emailHarvester.totalresults, response_content * 2) + self.assertEqual(2, mock_get.call_count) + self.assertEqual(20, self.emailHarvester.counter) + self.assertEqual(response_content * 2, self.emailHarvester.totalresults) def test_get_emails(self): self.emailHarvester.totalresults = "Contact us at info@example.com and support@example.com" self.emailHarvester.word = "example.com" emails = self.emailHarvester.get_emails() expected_emails = ["info@example.com", "support@example.com"] - self.assertEqual(set(emails), set(expected_emails)) + self.assertEqual(set(expected_emails), set(emails)) if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_myparser.py b/tests/test_myparser.py index 21bdff5..585ffd5 100644 --- a/tests/test_myparser.py +++ b/tests/test_myparser.py @@ -13,27 +13,27 @@ def setUp(self): def test_extract(self): self.testParser.extract("some results", "example.com") - self.assertEqual(self.testParser.results, "some results") - self.assertEqual(self.testParser.word, "example.com") + self.assertEqual("some results", self.testParser.results) + self.assertEqual("example.com", self.testParser.word) def test_genericClean(self): self.testParser.extract("test%2femail", "example.com") self.testParser.genericClean() expected_result = "test email" - self.assertEqual(self.testParser.results, expected_result) + self.assertEqual(expected_result, self.testParser.results) def test_emails(self): self.testParser.extract("Contact us at info@example.com and support@example.com", "example.com") emails = self.testParser.emails() expected_emails = ["info@example.com", "support@example.com"] - self.assertEqual(set(emails), set(expected_emails)) + self.assertEqual(set(expected_emails), set(emails)) def test_unique(self): self.testParser.temp = ["duplicate@example.com", "unique@example.com", "duplicate@example.com"] unique_emails = self.testParser.unique() expected_unique_emails = ["duplicate@example.com", "unique@example.com"] - self.assertEqual(set(unique_emails), set(expected_unique_emails)) + self.assertEqual(set(expected_unique_emails), set(unique_emails)) if __name__ == '__main__': diff --git a/tests/test_plugins/test_ask.py b/tests/test_plugins/test_ask.py index c8e379b..8ee1e40 100644 --- a/tests/test_plugins/test_ask.py +++ b/tests/test_plugins/test_ask.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.ask import Plugin, search, AskSearch @@ -63,7 +62,7 @@ def test_search(self, mock_app_emailharvester, mock_requests_get, mock_config): mock_app_emailharvester.parser.emails.assert_called_once() # Check the result of the search function - self.assertEqual(result, ['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_baidu.py b/tests/test_plugins/test_baidu.py index 3d56e14..3bdce55 100644 --- a/tests/test_plugins/test_baidu.py +++ b/tests/test_plugins/test_baidu.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.baidu import Plugin, search @@ -33,7 +32,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.process.assert_called_once() mock_app_emailharvester.get_emails.assert_called_once() - self.assertEqual(result,['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) diff --git a/tests/test_plugins/test_bing.py b/tests/test_plugins/test_bing.py index a7ba120..cb6db06 100644 --- a/tests/test_plugins/test_bing.py +++ b/tests/test_plugins/test_bing.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.bing import Plugin, search @@ -33,7 +32,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.process.assert_called_once() mock_app_emailharvester.get_emails.assert_called_once() - self.assertEqual(result,['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_dogpile.py b/tests/test_plugins/test_dogpile.py index ba0d298..ba0b656 100644 --- a/tests/test_plugins/test_dogpile.py +++ b/tests/test_plugins/test_dogpile.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.dogpile import Plugin, search @@ -33,7 +32,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.process.assert_called_once() mock_app_emailharvester.get_emails.assert_called_once() - self.assertEqual(result,['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_exalead.py b/tests/test_plugins/test_exalead.py index f42f833..bc0e49e 100644 --- a/tests/test_plugins/test_exalead.py +++ b/tests/test_plugins/test_exalead.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.exalead import Plugin, search @@ -34,7 +33,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.process.assert_called_once() mock_app_emailharvester.get_emails.assert_called_once() - self.assertEqual(result,['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) diff --git a/tests/test_plugins/test_github.py b/tests/test_plugins/test_github.py index 6cb6a63..8e56fe6 100644 --- a/tests/test_plugins/test_github.py +++ b/tests/test_plugins/test_github.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.github import Plugin, search @@ -44,7 +43,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.init_search.assert_has_calls(expected_calls) - self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + self.assertEqual(['22@email.com', 'john.doe@email.com', '2212@email.com'], result) if __name__ == '__main__': diff --git a/tests/test_plugins/test_google.py b/tests/test_plugins/test_google.py index 983242e..86162ae 100644 --- a/tests/test_plugins/test_google.py +++ b/tests/test_plugins/test_google.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.google import Plugin, search @@ -32,7 +31,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.process.assert_called_once() mock_app_emailharvester.get_emails.assert_called_once() - self.assertEqual(result,['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) if __name__ == '__main__': diff --git a/tests/test_plugins/test_googleplus.py b/tests/test_plugins/test_googleplus.py index 44662b6..c65c00c 100644 --- a/tests/test_plugins/test_googleplus.py +++ b/tests/test_plugins/test_googleplus.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.googleplus import Plugin, search @@ -33,7 +32,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.process.assert_called_once() mock_app_emailharvester.get_emails.assert_called_once() - self.assertEqual(result,['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_instagram.py b/tests/test_plugins/test_instagram.py index 2067721..41a5169 100644 --- a/tests/test_plugins/test_instagram.py +++ b/tests/test_plugins/test_instagram.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.instagram import Plugin, search @@ -44,7 +43,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.init_search.assert_has_calls(expected_calls) - self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + self.assertEqual(['22@email.com', 'john.doe@email.com', '2212@email.com'], result) if __name__ == '__main__': diff --git a/tests/test_plugins/test_linkedin.py b/tests/test_plugins/test_linkedin.py index 2feb6ce..302f511 100644 --- a/tests/test_plugins/test_linkedin.py +++ b/tests/test_plugins/test_linkedin.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.linkedin import Plugin, search @@ -44,7 +43,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.init_search.assert_has_calls(expected_calls) - self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + self.assertEqual(['22@email.com', 'john.doe@email.com', '2212@email.com'], result) if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_reddit.py b/tests/test_plugins/test_reddit.py index 299762f..3986b59 100644 --- a/tests/test_plugins/test_reddit.py +++ b/tests/test_plugins/test_reddit.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.reddit import Plugin, search @@ -44,7 +43,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.init_search.assert_has_calls(expected_calls) - self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + self.assertEqual(['22@email.com', 'john.doe@email.com', '2212@email.com'], result) if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/tests/test_plugins/test_twitter.py b/tests/test_plugins/test_twitter.py index 7fb78c4..45eed67 100644 --- a/tests/test_plugins/test_twitter.py +++ b/tests/test_plugins/test_twitter.py @@ -3,12 +3,10 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.twitter import Plugin, search -#template for futher tests class TestTwitterPlugin(unittest.TestCase): def setUp(self): self.app_mock = MagicMock() @@ -45,7 +43,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.init_search.assert_has_calls(expected_calls) - self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + self.assertEqual(['22@email.com', 'john.doe@email.com', '2212@email.com'], result) if __name__ == '__main__': diff --git a/tests/test_plugins/test_yahoo.py b/tests/test_plugins/test_yahoo.py index fe86241..6982827 100644 --- a/tests/test_plugins/test_yahoo.py +++ b/tests/test_plugins/test_yahoo.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.yahoo import Plugin, search @@ -33,7 +32,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.process.assert_called_once() mock_app_emailharvester.get_emails.assert_called_once() - self.assertEqual(result,['john_doe@email.com']) + self.assertEqual(['john_doe@email.com'], result) diff --git a/tests/test_plugins/test_youtube.py b/tests/test_plugins/test_youtube.py index d2f2002..0b9cf3d 100644 --- a/tests/test_plugins/test_youtube.py +++ b/tests/test_plugins/test_youtube.py @@ -3,7 +3,6 @@ import sys import os -# Add the root directory of your project to the Python path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) from plugins.youtube import Plugin, search @@ -44,7 +43,7 @@ def test_search(self, mock_app_emailharvester): mock_app_emailharvester.init_search.assert_has_calls(expected_calls) - self.assertEqual(result, ['22@email.com', 'john.doe@email.com', '2212@email.com']) + self.assertEqual(['22@email.com', 'john.doe@email.com', '2212@email.com'], result) if __name__ == '__main__':