-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
139 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Tets dibgit plugin.""" | ||
|
||
|
||
def test_digbit_search_magnets(): | ||
"""Test digbit search magnets method.""" | ||
from katcr import DigBt | ||
from robobrowser import RoboBrowser | ||
from unittest.mock import patch, MagicMock | ||
|
||
with patch('katcr.torrentmirror.get_proxies', | ||
side_effect=({},)) as mock: | ||
with patch('katcr.robobrowser.RoboBrowser', spec=RoboBrowser) as mock: | ||
DigBt(MagicMock()).search_magnets('foo', 1) | ||
assert mock.open.called_once_with('foo') | ||
|
||
|
||
def test_digbit_tabulate(): | ||
"""Test tabulate method given a known structure. | ||
Note that this structure may change in the future or even between | ||
different proxied sites... This needs to be handled somehow. | ||
""" | ||
from katcr import DigBt | ||
import bs4 | ||
to_parse = """<tr><div class=head><a>Foo</a></div> | ||
<div class=tail>1 2 3 4 Bar<a href='foo'> | ||
</a></div></tr>""" | ||
fakelink = bs4.BeautifulSoup(to_parse, "html.parser") | ||
result = DigBt.tabulate(fakelink.find('tr')) | ||
assert result == ('Foo', 'Bar', 'foo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Test nyaasi plugin.""" | ||
|
||
|
||
def test_nyaasi_search_magnets(): | ||
"""Test nyaasi search magnets method.""" | ||
from katcr import NyaaSi | ||
from robobrowser import RoboBrowser | ||
from unittest.mock import patch, MagicMock | ||
|
||
with patch('katcr.torrentmirror.get_proxies', | ||
side_effect=({},)) as mock: | ||
with patch('katcr.robobrowser.RoboBrowser', spec=RoboBrowser) as mock: | ||
NyaaSi(MagicMock()).search_magnets('foo', 1) | ||
assert mock.open.called_once_with('foo') | ||
|
||
|
||
def test_nyaasi_tabulate(): | ||
"""Test tabulate method given a known structure. | ||
Note that this structure may change in the future or even between | ||
different proxied sites... This needs to be handled somehow. | ||
""" | ||
from katcr import NyaaSi | ||
import bs4 | ||
|
||
to_parse = """<tr><td><a href=""><img src="" alt="Cat"></a></td> | ||
<td><a href="">Foo</a></td> | ||
<td><a href=""></a> <a href="foo"><i class=fa-magnet></i></a></td> | ||
<td class="text-center">Bar</td></tr>""" | ||
fakelink = bs4.BeautifulSoup(to_parse, "html.parser") | ||
result = NyaaSi.tabulate(fakelink.find(class_='fa-magnet')) | ||
assert result == ('Foo Cat', 'Bar', 'foo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Test skytorrents plugin.""" | ||
|
||
|
||
def test_skytorrents_search_magnets(): | ||
"""Test skytorrents search magnets method.""" | ||
from katcr import Skytorrents | ||
from robobrowser import RoboBrowser | ||
from unittest.mock import patch, MagicMock | ||
|
||
with patch('katcr.torrentmirror.get_proxies', | ||
side_effect=({},)) as mock: | ||
with patch('katcr.robobrowser.RoboBrowser', spec=RoboBrowser) as mock: | ||
Skytorrents(MagicMock()).search_magnets('foo', 1) | ||
assert mock.open.called_once_with('foo') | ||
|
||
|
||
def test_skytorrents_tabulate(): | ||
"""Test tabulate method given a known structure. | ||
Note that this structure may change in the future or even between | ||
different proxied sites... This needs to be handled somehow. | ||
""" | ||
from katcr import Skytorrents | ||
import bs4 | ||
to_parse = """<tr><td><a href="">Foo</a> | ||
<a href="foo"></a></td><td>Bar</td></tr>""" | ||
fakelink = bs4.BeautifulSoup(to_parse, "html.parser") | ||
result = Skytorrents.tabulate(fakelink.find('tr')) | ||
assert result == ('Foo', 'Bar', 'foo') |