Skip to content

Commit

Permalink
fix: test: flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
rachmadaniHaryono committed Nov 29, 2020
1 parent 7121cb6 commit 7529a1c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[tool:pytest]
flake8-max-line-length = 99
markers =
non_travis

[flake8]
max-line-length = 99
Expand Down
10 changes: 7 additions & 3 deletions tests/test_doc.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from datetime import datetime
from pathlib import Path


def test_arg_option_doc():
with open('README.rst') as f:
readme_path = Path(__file__).parent.parent / 'README.rst'
with readme_path.open() as f:
content = f.read()
option_parts = content.split('Options\n-------')[1].split('Video options\n')[0].strip()
option_parts = option_parts.splitlines()[1:-1]
option_parts = [x.split(' ', 2) for x in option_parts]
for idx, x in enumerate(option_parts):
option_parts[idx][2] = x[2].strip()
with open('we_get/core/we_get.py') as f:
we_get_path = Path(__file__).parent.parent / 'we_get' / 'core' / 'we_get.py'
with we_get_path.open() as f:
m_content = f.read()
m_option_parts = m_content.split('Options:')[1].split('Video options')[0].strip().splitlines()
m_option_parts = [x.strip().split(' ', 2) for x in m_option_parts]
Expand All @@ -20,7 +23,8 @@ def test_arg_option_doc():

def test_year():
current_year = datetime.now().year
with open('we_get/core/we_get.py') as f:
path = Path(__file__).parent.parent / 'we_get' / 'core' / 'we_get.py'
with path.open() as f:
m_content = f.read()
m_content.splitlines()[1]
year = m_content.split('Copyright (c) 2016-')[1].split(' ')[0]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_the_pirate_bay.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def test_search():
from we_get.modules.the_pirate_bay import the_pirate_bay
cl = the_pirate_bay('')
cl.search_query = 'ubuntu'
with vcr.use_cassette('fixtures/test_the_pirate_bay_test_search.yaml', record_mode='new_episodes'):
with vcr.use_cassette(
'fixtures/test_the_pirate_bay_test_search.yaml', record_mode='new_episodes'):
res = cl.search()
assert res
assert any('user_status' in res[k] for k in res)
Expand Down
1 change: 1 addition & 0 deletions we_get/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'user_status_vip': 'magenta'
}


def format_help(doc, errmsg):
""" format_help: fix help message.
"""
Expand Down
2 changes: 1 addition & 1 deletion we_get/core/we_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
-n --results=<n> Number of results to retrieve.
-S --sort-type=<type> Sort torrents by name/seeds [default: seeds].
-c --config=<file> Load config file.
-w --sfw Restrict results to safe for work content (the_pirate_bay only)
-w --sfw Restrict results to safe for work content (the_pirate_bay only)
Video options:
-q --quality=<q> Try to match quality for the torrent (720p,1080p, ...).
Expand Down
7 changes: 2 additions & 5 deletions we_get/modules/the_pirate_bay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
Copyright (c) 2016-2020 we-get developers (https://github.com/rachmadaniHaryono/we-get/)
See the file 'LICENSE' for copying permission
"""
from bs4 import BeautifulSoup

from we_get.core.module import Module
import re
import urllib
import json

Expand All @@ -14,7 +11,7 @@
API_SEARCH_LOC = "/q.php?q="
ALI_LIST_LOC = "/precompiled/data_top100_all.json"
API_SFW_FILTER = "&cat=100,200,300,400,600"
API_TRACKERS = "&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2850%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2920%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce"
API_TRACKERS = "&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2850%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2920%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce" # NOQA


class the_pirate_bay(object):
Expand All @@ -41,7 +38,7 @@ def parse_pargs(self):
self.filter = API_SFW_FILTER

def generate_magnet(self, data):
return f"magnet:?xt=urn:btih:{data['info_hash']}&dn={urllib.parse.quote(data['name'])}{API_TRACKERS}"
return f"magnet:?xt=urn:btih:{data['info_hash']}&dn={urllib.parse.quote(data['name'])}{API_TRACKERS}" # NOQA

def _parse_data(self, data):
for row in json.loads(data):
Expand Down

0 comments on commit 7529a1c

Please sign in to comment.