From eb182df1324f84d6864f324551fe6be7c535e451 Mon Sep 17 00:00:00 2001 From: volth Date: Thu, 25 Jul 2019 06:40:48 +0000 Subject: [mod] restore btdigg engine as btdig.com (#1515) --- tests/unit/engines/test_btdigg.py | 414 +++++++------------------------------- 1 file changed, 71 insertions(+), 343 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/engines/test_btdigg.py b/tests/unit/engines/test_btdigg.py index 6a88e3f75..45ddaa6e3 100644 --- a/tests/unit/engines/test_btdigg.py +++ b/tests/unit/engines/test_btdigg.py @@ -14,7 +14,7 @@ class TestBtdiggEngine(SearxTestCase): params = btdigg.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) - self.assertIn('btdigg.org', params['url']) + self.assertIn('btdig.com', params['url']) def test_response(self): self.assertRaises(AttributeError, btdigg.response, None) @@ -26,359 +26,87 @@ class TestBtdiggEngine(SearxTestCase): self.assertEqual(btdigg.response(response), []) html = u""" -
- - - - - -
1 - - - - -
- Should be the title -
- - - - - - - - - - - -
- [magnet] - - [cloud] - - Taille: - 8 B - - Fichiers: - 710 - - Téléchargements: - 5 - - Temps: - 417.8 jours - - Dernière mise à jour: - 5.3 jours - - Faux: - Aucun -
-
-                            Content
-                        
-
+
+
+
+ +
+
+
+
+ 4217 files 1 GBfound 3 years ago +
+
+
+
+
+ +
+ found 3 years ago +
+
+
+
+
3.9GBdeLibrosByHuasoFromHell(3de4)

+
Libros H-Z

+
H

H.H. Hollis - El truco de la espada-pdf.zip
17 KB
+
Hagakure - El Libro del Samurai-pdf.zip
95 KB
+
Hamsun, Knut (1859-1952)

+
Hamsun, Knut - Hambre-pdf.zip
786 KB
+ +
+
""" response = mock.Mock(text=html.encode('utf-8')) results = btdigg.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) - self.assertEqual(results[0]['title'], 'Should be the title') - self.assertEqual(results[0]['url'], 'https://btdigg.org/url') - self.assertEqual(results[0]['content'], 'Content') - self.assertEqual(results[0]['seed'], 5) - self.assertEqual(results[0]['leech'], 0) - self.assertEqual(results[0]['filesize'], 8) - self.assertEqual(results[0]['files'], 710) - self.assertEqual(results[0]['magnetlink'], 'magnet:?xt=urn:btih:magnet&dn=Test') + self.assertEqual(results[0]['title'], '3.9GBdeLibrosByHuasoFromHell(3de4)') + self.assertEqual(results[0]['url'], + 'http://btdig.com/a72f35b7ee3a10928f02bb799e40ae5db701ed1c/pdf?q=pdf&p=1&order=0') + self.assertEqual(results[0]['content'], + '3.9GBdeLibrosByHuasoFromHell(3de4) | ' + + 'Libros H-Z | ' + + 'H H.H. Hollis - El truco de la espada-pdf.zip17 KB | ' + + 'Hagakure - El Libro del Samurai-pdf.zip95 KB | ' + + 'Hamsun, Knut (1859-1952) | Hamsun, Knut - Hambre-pdf.zip786 KB | ' + + '4214 hidden files1 GB') + self.assertEqual(results[0]['filesize'], 1 * 1024 * 1024 * 1024) + self.assertEqual(results[0]['files'], 4217) + self.assertEqual(results[0]['magnetlink'], + 'magnet:?xt=urn:btih:a72f35b7ee3a10928f02bb799e40ae5db701ed1c&dn=3.9GBdeLibrosBy...') html = """ -
- -
-
- """ - response = mock.Mock(text=html.encode('utf-8')) - results = btdigg.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 0) +
- html = u""" -
- - - - - - - - - - - - - - - - - - - - - -
1 - - - - -
- Should be the title -
- - - - - - - - - - - -
- [magnet] - - [cloud] - - Taille: - 1 KB - - Fichiers: - 710 - - Téléchargements: - 5 - - Temps: - 417.8 jours - - Dernière mise à jour: - 5.3 jours - - Faux: - Aucun -
-
-                            Content
-                        
-
1 - - - - -
- Should be the title -
- - - - - - - - - - - -
- [magnet] - - [cloud] - - Taille: - 1 MB - - Fichiers: - a - - Téléchargements: - 4 - - Temps: - 417.8 jours - - Dernière mise à jour: - 5.3 jours - - Faux: - Aucun -
-
-                            Content
-                        
-
1 - - - - -
- Should be the title -
- - - - - - - - - - - -
- [magnet] - - [cloud] - - Taille: - 1 GB - - Fichiers: - 710 - - Téléchargements: - 3 - - Temps: - 417.8 jours - - Dernière mise à jour: - 5.3 jours - - Faux: - Aucun -
-
-                            Content
-                        
-
1 - - - - -
- Should be the title -
- - - - - - - - - - - -
- [magnet] - - [cloud] - - Taille: - 1 TB - - Fichiers: - 710 - - Téléchargements: - 2 - - Temps: - 417.8 jours - - Dernière mise à jour: - 5.3 jours - - Faux: - Aucun -
-
-                            Content
-                        
-
1 - - - - -
- Should be the title -
- - - - - - - - - - - -
- [magnet] - - [cloud] - - Taille: - a TB - - Fichiers: - 710 - - Téléchargements: - z - - Temps: - 417.8 jours - - Dernière mise à jour: - 5.3 jours - - Faux: - Aucun -
-
-                            Content
-                        
-
""" response = mock.Mock(text=html.encode('utf-8')) results = btdigg.response(response) self.assertEqual(type(results), list) - self.assertEqual(len(results), 5) - self.assertEqual(results[0]['title'], 'Should be the title') - self.assertEqual(results[0]['url'], 'https://btdigg.org/url') - self.assertEqual(results[0]['content'], 'Content') - self.assertEqual(results[0]['seed'], 5) - self.assertEqual(results[0]['leech'], 0) - self.assertEqual(results[0]['files'], 710) - self.assertEqual(results[0]['magnetlink'], 'magnet:?xt=urn:btih:magnet&dn=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(len(results), 0) -- cgit v1.2.3-54-g00ecf