From aa85045a7d24ccc672c33a5f83ee92caa0386596 Mon Sep 17 00:00:00 2001 From: Pydo Date: Mon, 5 Sep 2016 14:50:26 -0400 Subject: Added seedpeer unitests --- tests/unit/engines/test_seedpeer.py | 159 ++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 tests/unit/engines/test_seedpeer.py (limited to 'tests') diff --git a/tests/unit/engines/test_seedpeer.py b/tests/unit/engines/test_seedpeer.py new file mode 100644 index 000000000..379282d19 --- /dev/null +++ b/tests/unit/engines/test_seedpeer.py @@ -0,0 +1,159 @@ +import mock +from collections import defaultdict +from searx.engines import seedpeer +from searx.testing import SearxTestCase +from datetime import datetime + + +class TestSeedPeerEngine(SearxTestCase): + html = """ + + + + + + + +
+

Verified Narcos season 2 torrents

+ + comments | + verified + + Torrent nameAgeSizeSeedsPeersHealth
Narcos season 2 Full Version20 hours681.3 MB28 654 Health
Narcos season 2 Trusted Source12 hours787.1 MB64 220 Health
Full Narcos season 2 Download Usenet24 hours775.5 MB60 236 Health
Narcos season 2 2014 - DIRECT STREAMING Movies17 hours654.1 MB2 391 Health
Narcos season 2 2014 Movies20 hours754.5 MB21 919 Health


Search Binaries

 2 Narcos season 2 Torrents were found

+ + comments | + verified + + Torrent nameAgeSizeSeedsPeersHealth
Add to FacebookNarcos Season 2 Complete 720p WebRip EN-SUB x264-[MULVAcoded] S02 19 hours4.39 GB715 183 Health
Add to FacebookNarcos - Season 2 - 720p WEBRiP - x265 HEVC - ShAaNiG 1 day2.48 GB861 332 Health

Related searches for: Narcos season 2


Other suggested searches:

Search for "narcos-season-2" on Torrentz2.eu
Search for "narcos-season-2" on Torrent-Finder
  
+
+ + + """ + + def test_request(self): + query = 'test_query' + dicto = defaultdict(dict) + dicto['pageno'] = 1 + params = seedpeer.request(query, dicto) + self.assertIn('url', params) + self.assertIn(query, params['url']) + self.assertIn('seedpeer.eu', params['url']) + + def test_response_raises_attr_error_on_empty_response(self): + self.assertRaises(AttributeError, seedpeer.response, None) + self.assertRaises(AttributeError, seedpeer.response, []) + self.assertRaises(AttributeError, seedpeer.response, '') + self.assertRaises(AttributeError, seedpeer.response, '[]') + + def test_response_returns_empty_list(self): + response = mock.Mock(text='') + self.assertEqual(seedpeer.response(response), []) + + def test_response_returns_all_results(self): + response = mock.Mock(text=self.html) + results = seedpeer.response(response) + self.assertTrue(isinstance(results, list)) + self.assertEqual(len(results), 2) + + def test_response_returns_correct_results(self): + response = mock.Mock(text=self.html) + results = seedpeer.response(response) + self.assertEqual( + results[0]['title'], 'Narcos - Season 2 - 720p WEBRiP - x265 HEVC - ShAaNiG ' + ) + self.assertEqual( + results[0]['url'], + 'http://www.seedpeer.eu/details/11685972/Narcos---Season-2---720p-WEBRiP---x265-HEVC---ShAaNiG.html' + ) + self.assertEqual(results[0]['content'], '2.48 GB, 1 day') + self.assertEqual(results[0]['seed'], '861') + self.assertEqual(results[0]['leech'], '332') \ No newline at end of file -- cgit v1.2.3 From ec4a03628edfed2ceb192a323a47b2bc6271bdcc Mon Sep 17 00:00:00 2001 From: Pydo Date: Mon, 5 Sep 2016 15:37:20 -0400 Subject: Put html fixture in file to be pep8 line length compliant --- tests/unit/engines/seedpeer_fixture.html | 110 +++++++++++++++++++++++++++++ tests/unit/engines/test_seedpeer.py | 116 ++----------------------------- 2 files changed, 114 insertions(+), 112 deletions(-) create mode 100644 tests/unit/engines/seedpeer_fixture.html (limited to 'tests') diff --git a/tests/unit/engines/seedpeer_fixture.html b/tests/unit/engines/seedpeer_fixture.html new file mode 100644 index 000000000..28207bfad --- /dev/null +++ b/tests/unit/engines/seedpeer_fixture.html @@ -0,0 +1,110 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tests/unit/engines/test_seedpeer.py b/tests/unit/engines/test_seedpeer.py index 379282d19..37b2de8e4 100644 --- a/tests/unit/engines/test_seedpeer.py +++ b/tests/unit/engines/test_seedpeer.py @@ -6,118 +6,10 @@ from datetime import datetime class TestSeedPeerEngine(SearxTestCase): - html = """ - - - - - - - - - - - """ + html = '' + with open('./tests/unit/engines/seedpeer_fixture.html') as fixture: + html += fixture.read() def test_request(self): query = 'test_query' @@ -156,4 +48,4 @@ class TestSeedPeerEngine(SearxTestCase): ) self.assertEqual(results[0]['content'], '2.48 GB, 1 day') self.assertEqual(results[0]['seed'], '861') - self.assertEqual(results[0]['leech'], '332') \ No newline at end of file + self.assertEqual(results[0]['leech'], '332') -- cgit v1.2.3 From d1d4ed4376e41fa380b5b3a72e1b08e1f36a35e8 Mon Sep 17 00:00:00 2001 From: marc Date: Tue, 20 Sep 2016 15:35:54 -0500 Subject: [fix] results with digbit don't truncate anymore --- tests/unit/engines/test_digbt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/engines/test_digbt.py b/tests/unit/engines/test_digbt.py index 867188ed9..31a1b03a4 100644 --- a/tests/unit/engines/test_digbt.py +++ b/tests/unit/engines/test_digbt.py @@ -28,7 +28,9 @@ class TestDigBTEngine(SearxTestCase): - + @@ -97,7 +97,7 @@ class TestKickassEngine(SearxTestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 1) self.assertEqual(results[0]['title'], 'This should be the title') - self.assertEqual(results[0]['url'], 'https://kickass.to/url.html') + self.assertEqual(results[0]['url'], 'https://kickass.cd/url.html') self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted') self.assertEqual(results[0]['seed'], 10) self.assertEqual(results[0]['leech'], 1) @@ -191,7 +191,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -235,7 +235,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -279,7 +279,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -323,7 +323,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -367,7 +367,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -380,17 +380,17 @@ class TestKickassEngine(SearxTestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 5) self.assertEqual(results[0]['title'], 'This should be the title') - self.assertEqual(results[0]['url'], 'https://kickass.to/url.html') + self.assertEqual(results[0]['url'], 'https://kickass.cd/url.html') self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted') self.assertEqual(results[0]['seed'], 10) self.assertEqual(results[0]['leech'], 1) self.assertEqual(results[0]['files'], 4) self.assertEqual(results[0]['magnetlink'], 'magnet:?xt=urn:btih:MAGNETURL&dn=test') self.assertEqual(results[0]['torrentfile'], 'http://torcache.net/torrent/53917.torrent?title=test') - self.assertEqual(results[0]['filesize'], 1024) - self.assertEqual(results[1]['filesize'], 1048576) - self.assertEqual(results[2]['filesize'], 1073741824) - self.assertEqual(results[3]['filesize'], 1099511627776) + self.assertEqual(results[0]['filesize'], 1000) + self.assertEqual(results[1]['filesize'], 1000000) + self.assertEqual(results[2]['filesize'], 1000000000) + self.assertEqual(results[3]['filesize'], 1000000000000) self.assertEqual(results[4]['seed'], 0) self.assertEqual(results[4]['leech'], 0) self.assertEqual(results[4]['files'], None) -- cgit v1.2.3
-- cgit v1.2.3 From bee7b497a300622f5ba2b619817f5c89c29ae871 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Thu, 22 Sep 2016 23:51:07 +0200 Subject: [mod] rename "default" theme to "legacy" --- tests/robot/test_basic.robot | 4 ++-- tests/unit/test_webapp.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/robot/test_basic.robot b/tests/robot/test_basic.robot index a455eeaa0..540060fef 100644 --- a/tests/robot/test_basic.robot +++ b/tests/robot/test_basic.robot @@ -67,7 +67,7 @@ Change theme Page Should Contain about Page Should Contain preferences Go To http://localhost:11111/preferences - List Selection Should Be theme default + List Selection Should Be theme legacy Select From List theme oscar Submit Form id=search_form Location Should Be http://localhost:11111/ @@ -139,7 +139,7 @@ Block a plugin Page Should Contain about Page Should Contain preferences Go To http://localhost:11111/preferences - List Selection Should Be theme default + List Selection Should Be theme legacy Select From List theme oscar Submit Form id=search_form Location Should Be http://localhost:11111/ diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py index 1762d66b6..912bebc4d 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -44,7 +44,7 @@ class ViewsTestCase(SearxTestCase): webapp.Search.search = search_mock def get_current_theme_name_mock(override=None): - return 'default' + return 'legacy' webapp.get_current_theme_name = get_current_theme_name_mock @@ -58,7 +58,7 @@ class ViewsTestCase(SearxTestCase): def test_index_html(self): result = self.app.post('/', data={'q': 'test'}) self.assertIn( - '

youtubeSecond Test

', # noqa + '

youtubeSecond Test

', # noqa result.data ) self.assertIn( -- cgit v1.2.3 From 295fc9ce96d8cca9c6c4776a00e5fb0942eb6f4d Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Wed, 28 Sep 2016 22:59:13 +0200 Subject: [fix] robot test engine names II. --- tests/robot/test_basic.robot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/robot/test_basic.robot b/tests/robot/test_basic.robot index 540060fef..ab41265a0 100644 --- a/tests/robot/test_basic.robot +++ b/tests/robot/test_basic.robot @@ -24,8 +24,8 @@ Preferences page Page Should Contain Preferences Page Should Contain Default categories Page Should Contain Currently used search engines - Page Should Contain dummy_dummy - Page Should Contain general_dummy + Page Should Contain dummy dummy + Page Should Contain general dummy Switch category Go To http://localhost:11111/preferences -- cgit v1.2.3 From 3c5883408c92ec10227054140b65982d7b70fd76 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Tue, 13 Sep 2016 00:53:53 +0200 Subject: initial commit of pdbe engine Adds support for queries to the Protein Data Bank Europe (PDBe). --- tests/unit/engines/test_pdbe.py | 109 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 tests/unit/engines/test_pdbe.py (limited to 'tests') diff --git a/tests/unit/engines/test_pdbe.py b/tests/unit/engines/test_pdbe.py new file mode 100644 index 000000000..7aa8e2655 --- /dev/null +++ b/tests/unit/engines/test_pdbe.py @@ -0,0 +1,109 @@ +import mock +from collections import defaultdict +from searx.engines import pdbe +from searx.testing import SearxTestCase + + +class TestPdbeEngine(SearxTestCase): + def test_request(self): + query = 'test_query' + dicto = defaultdict(dict) + params = pdbe.request(query, dicto) + self.assertTrue('url' in params) + self.assertTrue('ebi.ac.uk' in params['url']) + self.assertTrue('data' in params) + self.assertTrue('q' in params['data']) + self.assertTrue(query in params['data']['q']) + self.assertTrue('wt' in params['data']) + self.assertTrue('json' in params['data']['wt']) + self.assertTrue('method' in params) + self.assertTrue(params['method'] == 'POST') + + def test_response(self): + self.assertRaises(AttributeError, pdbe.response, None) + self.assertRaises(AttributeError, pdbe.response, []) + self.assertRaises(AttributeError, pdbe.response, '') + self.assertRaises(AttributeError, pdbe.response, '[]') + + json = """ +{ + "response": { + "docs": [ + { + "citation_title": "X-ray crystal structure of ferric Aplysia limacina myoglobin in different liganded states.", + "citation_year": 1993, + "entry_author_list": [ + "Conti E, Moser C, Rizzi M, Mattevi A, Lionetti C, Coda A, Ascenzi P, Brunori M, Bolognesi M" + ], + "journal": "J. Mol. Biol.", + "journal_page": "498-508", + "journal_volume": "233", + "pdb_id": "2fal", + "status": "REL", + "title": "X-RAY CRYSTAL STRUCTURE OF FERRIC APLYSIA LIMACINA MYOGLOBIN IN DIFFERENT LIGANDED STATES" + } + ], + "numFound": 1, + "start": 0 + }, + "responseHeader": { + "QTime": 0, + "params": { + "q": "2fal", + "wt": "json" + }, + "status": 0 + } +} +""" + + response = mock.Mock(text=json) + results = pdbe.response(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 1) + self.assertEqual(results[0]['title'], + 'X-RAY CRYSTAL STRUCTURE OF FERRIC APLYSIA LIMACINA MYOGLOBIN IN DIFFERENT LIGANDED STATES') + self.assertEqual(results[0]['url'], pdbe.pdbe_entry_url.format(pdb_id='2fal')) + self.assertEqual(results[0]['img_src'], pdbe.pdbe_preview_url.format(pdb_id='2fal')) + self.assertTrue('Conti E' in results[0]['content']) + self.assertTrue('X-ray crystal structure of ferric Aplysia limacina myoglobin in different liganded states.' in + results[0]['content']) + self.assertTrue('1993' in results[0]['content']) + + # Testing proper handling of PDB entries marked as obsolete + json = """ +{ + "response": { + "docs": [ + { + "citation_title": "Obsolete entry test", + "citation_year": 2016, + "entry_author_list": ["Doe J"], + "journal": "J. Obs.", + "journal_page": "1-2", + "journal_volume": "1", + "pdb_id": "xxxx", + "status": "OBS", + "title": "OBSOLETE ENTRY TEST", + "superseded_by": "yyyy" + } + ], + "numFound": 1, + "start": 0 + }, + "responseHeader": { + "QTime": 0, + "params": { + "q": "xxxx", + "wt": "json" + }, + "status": 0 + } +} +""" + response = mock.Mock(text=json) + results = pdbe.response(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 1) + self.assertEqual(results[0]['title'], 'OBSOLETE ENTRY TEST (OBSOLETE)') + self.assertTrue(results[0]['content'].startswith('This entry has been superseded by')) -- cgit v1.2.3 From 629fa4355afc5a4680ae14d8b3d4d31e3616f9f6 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Sat, 22 Oct 2016 04:45:29 +0200 Subject: [fix] gecko driver cannot detect the page load finish on preferences form submit. It now works with this dirty workaround.. --- tests/robot/test_basic.robot | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/robot/test_basic.robot b/tests/robot/test_basic.robot index ab41265a0..a466a095c 100644 --- a/tests/robot/test_basic.robot +++ b/tests/robot/test_basic.robot @@ -4,6 +4,14 @@ Test Setup Open Browser http://localhost:11111/ Test Teardown Close All Browsers +*** Keywords *** +Submit Preferences + Set Selenium Speed 2 seconds + Submit Form id=search_form + Location Should Be http://localhost:11111/ + Set Selenium Speed 0 seconds + + *** Test Cases *** Front page Page Should Contain about @@ -33,8 +41,7 @@ Switch category Page Should Contain Checkbox category_dummy Click Element xpath=//*[.="general"] Click Element xpath=//*[.="dummy"] - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Checkbox Should Not Be Selected category_general Checkbox Should Be Selected category_dummy @@ -43,8 +50,7 @@ Change language Page Should Contain preferences Go To http://localhost:11111/preferences Select From List locale hu - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Page Should Contain rólunk Page Should Contain beállítások @@ -53,13 +59,11 @@ Change method Page Should Contain preferences Go To http://localhost:11111/preferences Select From List method GET - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be method GET Select From List method POST - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be method POST @@ -69,8 +73,7 @@ Change theme Go To http://localhost:11111/preferences List Selection Should Be theme legacy Select From List theme oscar - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be theme oscar @@ -80,8 +83,7 @@ Change safesearch Go To http://localhost:11111/preferences List Selection Should Be safesearch None Select From List safesearch Strict - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be safesearch Strict @@ -91,8 +93,7 @@ Change image proxy Go To http://localhost:11111/preferences List Selection Should Be image_proxy Disabled Select From List image_proxy Enabled - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be image_proxy Enabled @@ -102,8 +103,7 @@ Change search language Go To http://localhost:11111/preferences List Selection Should Be language Automatic Select From List language Turkish (Turkey) - tr_TR - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be language Turkish (Turkey) - tr_TR @@ -113,8 +113,7 @@ Change autocomplete Go To http://localhost:11111/preferences List Selection Should Be autocomplete - Select From List autocomplete google - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be autocomplete google @@ -126,8 +125,7 @@ Change allowed/disabled engines Element Should Contain xpath=//label[@class="deny"][@for='engine_dummy_dummy_dummy'] Block Element Should Contain xpath=//label[@class="deny"][@for='engine_general_general_dummy'] Block Click Element xpath=//label[@class="deny"][@for='engine_general_general_dummy'] - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Page Should Contain about Page Should Contain preferences Go To http://localhost:11111/preferences @@ -141,16 +139,14 @@ Block a plugin Go To http://localhost:11111/preferences List Selection Should Be theme legacy Select From List theme oscar - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences List Selection Should Be theme oscar Page Should Contain Plugins Click Link Plugins Checkbox Should Not Be Selected id=plugin_HTTPS_rewrite Click Element xpath=//label[@for='plugin_HTTPS_rewrite'] - Submit Form id=search_form - Location Should Be http://localhost:11111/ + Submit Preferences Go To http://localhost:11111/preferences Page Should Contain Plugins Click Link Plugins -- cgit v1.2.3 From 53c9fde992741dea936d9ca92d13e5a8a30b1c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Tue, 11 Oct 2016 19:31:42 +0200 Subject: fix kickass torrents engine --- tests/unit/engines/test_kickass.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/unit/engines/test_kickass.py b/tests/unit/engines/test_kickass.py index 4cfcaa63c..96c17911c 100644 --- a/tests/unit/engines/test_kickass.py +++ b/tests/unit/engines/test_kickass.py @@ -14,7 +14,7 @@ class TestKickassEngine(SearxTestCase): params = kickass.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) - self.assertIn('kickass.to', params['url']) + self.assertIn('kickass.cd', params['url']) self.assertFalse(params['verify']) def test_response(self): @@ -84,7 +84,7 @@ class TestKickassEngine(SearxTestCase):
449 bytes449 bytes 4 2 years 10 1 KB1 KiB 4 2 years 10 1 MB1 MiB 4 2 years 9 1 GB1 GiB 4 2 years 8 1 TB1 TiB 4 2 years 7 z bytesz bytes r 2 years a