Rename rtv to tuir
This commit is contained in:
@@ -11,15 +11,15 @@ import pytest
|
||||
from vcr import VCR
|
||||
from six.moves.urllib.parse import urlparse, parse_qs
|
||||
|
||||
from rtv.oauth import OAuthHelper, OAuthHandler, OAuthHTTPServer
|
||||
from rtv.content import RequestHeaderRateLimiter
|
||||
from rtv.config import Config
|
||||
from rtv.packages import praw
|
||||
from rtv.terminal import Terminal
|
||||
from rtv.subreddit_page import SubredditPage
|
||||
from rtv.submission_page import SubmissionPage
|
||||
from rtv.subscription_page import SubscriptionPage
|
||||
from rtv.inbox_page import InboxPage
|
||||
from tuir.oauth import OAuthHelper, OAuthHandler, OAuthHTTPServer
|
||||
from tuir.content import RequestHeaderRateLimiter
|
||||
from tuir.config import Config
|
||||
from tuir.packages import praw
|
||||
from tuir.terminal import Terminal
|
||||
from tuir.subreddit_page import SubredditPage
|
||||
from tuir.submission_page import SubmissionPage
|
||||
from tuir.subscription_page import SubscriptionPage
|
||||
from tuir.inbox_page import InboxPage
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
@@ -40,7 +40,7 @@ for name in ['vcr.matchers', 'vcr.stubs']:
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption('--record-mode', dest='record_mode', default='none')
|
||||
parser.addoption('--refresh-token', dest='refresh_token',
|
||||
default='~/.local/share/rtv/refresh-token')
|
||||
default='~/.local/share/tuir/refresh-token')
|
||||
|
||||
|
||||
class MockStdscr(mock.MagicMock):
|
||||
@@ -184,9 +184,9 @@ def reddit(vcr, request):
|
||||
os.remove(filename)
|
||||
|
||||
with vcr.use_cassette(cassette_name):
|
||||
with patch('rtv.packages.praw.Reddit.get_access_information'):
|
||||
with patch('tuir.packages.praw.Reddit.get_access_information'):
|
||||
handler = RequestHeaderRateLimiter()
|
||||
reddit = praw.Reddit(user_agent='rtv test suite',
|
||||
reddit = praw.Reddit(user_agent='tuir test suite',
|
||||
decode_html_entities=False,
|
||||
disable_update_check=True,
|
||||
handler=handler)
|
||||
|
||||
@@ -3,8 +3,8 @@ from __future__ import unicode_literals
|
||||
|
||||
import pytest
|
||||
|
||||
from rtv.clipboard import copy
|
||||
from rtv.exceptions import ProgramError
|
||||
from tuir.clipboard import copy
|
||||
from tuir.exceptions import ProgramError
|
||||
|
||||
|
||||
try:
|
||||
|
||||
@@ -5,7 +5,7 @@ import os
|
||||
import codecs
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from rtv.config import Config, copy_default_config, copy_default_mailcap
|
||||
from tuir.config import Config, copy_default_config, copy_default_mailcap
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
@@ -17,7 +17,7 @@ def test_copy_default_config():
|
||||
"""Make sure the default config file was included in the package"""
|
||||
|
||||
with NamedTemporaryFile(suffix='.cfg') as fp:
|
||||
with mock.patch('rtv.config.six.moves.input', return_value='y'):
|
||||
with mock.patch('tuir.config.six.moves.input', return_value='y'):
|
||||
copy_default_config(fp.name)
|
||||
assert fp.read()
|
||||
# Check that the permissions were changed
|
||||
@@ -29,7 +29,7 @@ def test_copy_default_config_cancel():
|
||||
"""Pressing ``n`` should cancel the copy"""
|
||||
|
||||
with NamedTemporaryFile(suffix='.cfg') as fp:
|
||||
with mock.patch('rtv.config.six.moves.input', return_value='n'):
|
||||
with mock.patch('tuir.config.six.moves.input', return_value='n'):
|
||||
copy_default_config(fp.name)
|
||||
assert not fp.read()
|
||||
|
||||
@@ -38,7 +38,7 @@ def test_copy_config_interrupt():
|
||||
"""Pressing ``Ctrl-C`` should cancel the copy"""
|
||||
|
||||
with NamedTemporaryFile(suffix='.cfg') as fp:
|
||||
with mock.patch('rtv.config.six.moves.input') as func:
|
||||
with mock.patch('tuir.config.six.moves.input') as func:
|
||||
func.side_effect = KeyboardInterrupt
|
||||
copy_default_config(fp.name)
|
||||
assert not fp.read()
|
||||
@@ -48,7 +48,7 @@ def test_copy_default_mailcap():
|
||||
"""Make sure the example mailcap file was included in the package"""
|
||||
|
||||
with NamedTemporaryFile() as fp:
|
||||
with mock.patch('rtv.config.six.moves.input', return_value='y'):
|
||||
with mock.patch('tuir.config.six.moves.input', return_value='y'):
|
||||
copy_default_mailcap(fp.name)
|
||||
assert fp.read()
|
||||
# Check that the permissions were changed
|
||||
@@ -79,7 +79,7 @@ def test_config_interface():
|
||||
def test_config_get_args():
|
||||
"""Ensure that command line arguments are parsed properly"""
|
||||
|
||||
args = ['rtv',
|
||||
args = ['tuir',
|
||||
'https://reddit.com/permalink •',
|
||||
'-s', 'cfb',
|
||||
'--log', 'logfile.log',
|
||||
@@ -95,7 +95,7 @@ def test_config_get_args():
|
||||
'--no-flash',
|
||||
'--no-autologin']
|
||||
|
||||
with mock.patch('sys.argv', ['rtv']):
|
||||
with mock.patch('sys.argv', ['tuir']):
|
||||
config_dict = Config.get_args()
|
||||
config = Config(**config_dict)
|
||||
assert config.config == {}
|
||||
@@ -124,14 +124,14 @@ def test_config_get_args():
|
||||
def test_config_link_deprecated():
|
||||
|
||||
# Should still be able to specify the link using the old "-l"
|
||||
args = ['rtv', '-l', 'https://reddit.com/option']
|
||||
args = ['tuir', '-l', 'https://reddit.com/option']
|
||||
with mock.patch('sys.argv', args):
|
||||
config_dict = Config.get_args()
|
||||
config = Config(**config_dict)
|
||||
assert config['link'] == 'https://reddit.com/option'
|
||||
|
||||
# But the positional argument should take preference
|
||||
args = ['rtv', 'https://reddit.com/arg', '-l', 'https://reddit.com/option']
|
||||
args = ['tuir', 'https://reddit.com/arg', '-l', 'https://reddit.com/option']
|
||||
with mock.patch('sys.argv', args):
|
||||
config_dict = Config.get_args()
|
||||
config = Config(**config_dict)
|
||||
@@ -172,9 +172,9 @@ def test_config_from_file():
|
||||
assert config.config == {}
|
||||
assert config.keymap._keymap == default_keymap
|
||||
|
||||
# [rtv]
|
||||
# [tuir]
|
||||
rows = ['{0}={1}'.format(key, val) for key, val in args.items()]
|
||||
data = '\n'.join(['[rtv]'] + rows)
|
||||
data = '\n'.join(['[tuir]'] + rows)
|
||||
fp.write(codecs.encode(data, 'utf-8'))
|
||||
|
||||
# [bindings]
|
||||
|
||||
@@ -8,9 +8,9 @@ from collections import OrderedDict
|
||||
import six
|
||||
import pytest
|
||||
|
||||
from rtv import exceptions
|
||||
from rtv.packages import praw
|
||||
from rtv.content import (
|
||||
from tuir import exceptions
|
||||
from tuir.packages import praw
|
||||
from tuir.content import (
|
||||
Content, SubmissionContent, SubredditContent, SubscriptionContent,
|
||||
RequestHeaderRateLimiter)
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pytest
|
||||
from rtv.packages.praw.errors import InvalidUser
|
||||
from tuir.packages.praw.errors import InvalidUser
|
||||
|
||||
from rtv import exceptions
|
||||
from rtv.docs import FOOTER_INBOX
|
||||
from rtv.inbox_page import InboxPage
|
||||
from rtv.submission_page import SubmissionPage
|
||||
from tuir import exceptions
|
||||
from tuir.docs import FOOTER_INBOX
|
||||
from tuir.inbox_page import InboxPage
|
||||
from tuir.submission_page import SubmissionPage
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
|
||||
@@ -6,7 +6,7 @@ from collections import OrderedDict
|
||||
|
||||
import pytest
|
||||
|
||||
from rtv.mime_parsers import parsers, ImgurApiMIMEParser
|
||||
from tuir.mime_parsers import parsers, ImgurApiMIMEParser
|
||||
|
||||
|
||||
RegexpType = type(re.compile(''))
|
||||
|
||||
@@ -3,9 +3,9 @@ from __future__ import unicode_literals
|
||||
|
||||
import requests
|
||||
|
||||
from rtv.oauth import OAuthHelper, OAuthHandler
|
||||
from rtv.exceptions import InvalidRefreshToken
|
||||
from rtv.packages.praw.errors import OAuthException
|
||||
from tuir.oauth import OAuthHelper, OAuthHandler
|
||||
from tuir.exceptions import InvalidRefreshToken
|
||||
from tuir.packages.praw.errors import OAuthException
|
||||
|
||||
|
||||
try:
|
||||
@@ -128,8 +128,8 @@ def test_oauth_authorize(oauth, reddit, stdscr, refresh_token):
|
||||
# Because we use `from .helpers import open_browser` we have to patch the
|
||||
# function in the destination oauth module and not the helpers module
|
||||
with mock.patch('uuid.UUID.hex', new_callable=mock.PropertyMock) as uuid, \
|
||||
mock.patch('rtv.terminal.Terminal.open_browser') as open_browser, \
|
||||
mock.patch('rtv.oauth.OAuthHTTPServer') as http_server, \
|
||||
mock.patch('tuir.terminal.Terminal.open_browser') as open_browser, \
|
||||
mock.patch('tuir.oauth.OAuthHTTPServer') as http_server, \
|
||||
mock.patch.object(oauth.reddit, 'user'), \
|
||||
mock.patch('time.sleep'):
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import pytest
|
||||
import requests
|
||||
from six.moves import reload_module
|
||||
|
||||
from rtv import exceptions
|
||||
from rtv.objects import Controller, Navigator, Command, KeyMap, \
|
||||
from tuir import exceptions
|
||||
from tuir.objects import Controller, Navigator, Command, KeyMap, \
|
||||
curses_session, patch_webbrowser
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from rtv import packages
|
||||
from tuir import packages
|
||||
|
||||
|
||||
def test_praw3_package():
|
||||
|
||||
@@ -5,7 +5,7 @@ import curses
|
||||
|
||||
import pytest
|
||||
|
||||
from rtv.page import Page, PageController, logged_in
|
||||
from tuir.page import Page, PageController, logged_in
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
|
||||
@@ -6,8 +6,8 @@ from collections import OrderedDict
|
||||
|
||||
import pytest
|
||||
|
||||
from rtv.submission_page import SubmissionPage
|
||||
from rtv.docs import FOOTER_SUBMISSION
|
||||
from tuir.submission_page import SubmissionPage
|
||||
from tuir.docs import FOOTER_SUBMISSION
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
@@ -262,9 +262,9 @@ def test_submission_vote(submission_page, refresh_token):
|
||||
submission_page.oauth.authorize()
|
||||
|
||||
# Test voting on the submission
|
||||
with mock.patch('rtv.packages.praw.objects.Submission.upvote') as upvote, \
|
||||
mock.patch('rtv.packages.praw.objects.Submission.downvote') as downvote, \
|
||||
mock.patch('rtv.packages.praw.objects.Submission.clear_vote') as clear_vote:
|
||||
with mock.patch('tuir.packages.praw.objects.Submission.upvote') as upvote, \
|
||||
mock.patch('tuir.packages.praw.objects.Submission.downvote') as downvote, \
|
||||
mock.patch('tuir.packages.praw.objects.Submission.clear_vote') as clear_vote:
|
||||
|
||||
data = submission_page.get_selected_item()
|
||||
data['object'].archived = False
|
||||
@@ -338,8 +338,8 @@ def test_submission_save(submission_page, refresh_token):
|
||||
submission_page.oauth.authorize()
|
||||
|
||||
# Test save on the submission
|
||||
with mock.patch('rtv.packages.praw.objects.Submission.save') as save, \
|
||||
mock.patch('rtv.packages.praw.objects.Submission.unsave') as unsave:
|
||||
with mock.patch('tuir.packages.praw.objects.Submission.save') as save, \
|
||||
mock.patch('tuir.packages.praw.objects.Submission.unsave') as unsave:
|
||||
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
|
||||
@@ -370,8 +370,8 @@ def test_submission_comment_save(submission_page, terminal, refresh_token):
|
||||
submission_page.controller.trigger('j')
|
||||
|
||||
# Test save on the comment submission
|
||||
with mock.patch('rtv.packages.praw.objects.Comment.save') as save, \
|
||||
mock.patch('rtv.packages.praw.objects.Comment.unsave') as unsave:
|
||||
with mock.patch('tuir.packages.praw.objects.Comment.save') as save, \
|
||||
mock.patch('tuir.packages.praw.objects.Comment.unsave') as unsave:
|
||||
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
|
||||
@@ -398,7 +398,7 @@ def test_submission_comment(submission_page, terminal, refresh_token):
|
||||
submission_page.oauth.authorize()
|
||||
|
||||
# Leave a comment
|
||||
with mock.patch('rtv.packages.praw.objects.Submission.add_comment') as add_comment, \
|
||||
with mock.patch('tuir.packages.praw.objects.Submission.add_comment') as add_comment, \
|
||||
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
||||
mock.patch('time.sleep'):
|
||||
open_editor.return_value.__enter__.return_value = 'comment text'
|
||||
@@ -430,7 +430,7 @@ def test_submission_delete(submission_page, terminal, refresh_token):
|
||||
# Spoof the author and try to delete again
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
data['author'] = submission_page.reddit.user.name
|
||||
with mock.patch('rtv.packages.praw.objects.Comment.delete') as delete, \
|
||||
with mock.patch('tuir.packages.praw.objects.Comment.delete') as delete, \
|
||||
mock.patch.object(terminal.stdscr, 'getch') as getch, \
|
||||
mock.patch('time.sleep'):
|
||||
getch.return_value = ord('y')
|
||||
@@ -454,7 +454,7 @@ def test_submission_edit(submission_page, terminal, refresh_token):
|
||||
# Spoof the submission and try to edit again
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
data['author'] = submission_page.reddit.user.name
|
||||
with mock.patch('rtv.packages.praw.objects.Submission.edit') as edit, \
|
||||
with mock.patch('tuir.packages.praw.objects.Submission.edit') as edit, \
|
||||
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
||||
mock.patch('time.sleep'):
|
||||
open_editor.return_value.__enter__.return_value = 'submission text'
|
||||
@@ -470,7 +470,7 @@ def test_submission_edit(submission_page, terminal, refresh_token):
|
||||
# Spoof the author and edit the comment
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
data['author'] = submission_page.reddit.user.name
|
||||
with mock.patch('rtv.packages.praw.objects.Comment.edit') as edit, \
|
||||
with mock.patch('tuir.packages.praw.objects.Comment.edit') as edit, \
|
||||
mock.patch.object(terminal, 'open_editor') as open_editor, \
|
||||
mock.patch('time.sleep'):
|
||||
open_editor.return_value.__enter__.return_value = 'comment text'
|
||||
|
||||
@@ -7,9 +7,9 @@ from collections import OrderedDict
|
||||
import six
|
||||
import pytest
|
||||
|
||||
from rtv import __version__
|
||||
from rtv.subreddit_page import SubredditPage
|
||||
from rtv.packages.praw.errors import NotFound, HTTPException
|
||||
from tuir import __version__
|
||||
from tuir.subreddit_page import SubredditPage
|
||||
from tuir.packages.praw.errors import NotFound, HTTPException
|
||||
from requests.exceptions import ReadTimeout
|
||||
|
||||
try:
|
||||
@@ -103,13 +103,13 @@ def test_subreddit_title(subreddit_page, terminal, capsys):
|
||||
subreddit_page.draw()
|
||||
out, _ = capsys.readouterr()
|
||||
assert isinstance(out, six.text_type)
|
||||
assert out == '\x1b]2;hello ? - rtv {}\x07'.format(__version__)
|
||||
assert out == '\x1b]2;hello ? - tuir {}\x07'.format(__version__)
|
||||
|
||||
terminal.config['ascii'] = False
|
||||
subreddit_page.draw()
|
||||
out, _ = capsys.readouterr()
|
||||
assert isinstance(out, six.text_type)
|
||||
assert out == '\x1b]2;hello ❤ - rtv {}\x07'.format(__version__)
|
||||
assert out == '\x1b]2;hello ❤ - tuir {}\x07'.format(__version__)
|
||||
|
||||
with mock.patch.dict('os.environ', {'DISPLAY': ''}):
|
||||
subreddit_page.draw()
|
||||
@@ -313,7 +313,7 @@ def test_subreddit_open(subreddit_page, terminal, config):
|
||||
assert terminal.open_link.called
|
||||
config.history.add.assert_called_with(data['url_full'])
|
||||
|
||||
# Open the selected link within rtv
|
||||
# Open the selected link within tuir
|
||||
data = subreddit_page.content.get(subreddit_page.nav.absolute_index)
|
||||
with mock.patch.object(subreddit_page, 'open_submission'), \
|
||||
mock.patch.object(config.history, 'add'):
|
||||
@@ -404,7 +404,7 @@ def test_subreddit_open_subscriptions(subreddit_page, refresh_token):
|
||||
assert subreddit_page.selected_page
|
||||
assert subreddit_page.active
|
||||
|
||||
with mock.patch('rtv.page.Page.loop') as loop:
|
||||
with mock.patch('tuir.page.Page.loop') as loop:
|
||||
subreddit_page.handle_selected_page()
|
||||
assert loop.called
|
||||
|
||||
@@ -435,7 +435,7 @@ def test_subreddit_open_multireddits(subreddit_page, refresh_token):
|
||||
assert subreddit_page.selected_page
|
||||
assert subreddit_page.active
|
||||
|
||||
with mock.patch('rtv.page.Page.loop') as loop:
|
||||
with mock.patch('tuir.page.Page.loop') as loop:
|
||||
subreddit_page.handle_selected_page()
|
||||
assert loop.called
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import curses
|
||||
|
||||
import pytest
|
||||
|
||||
from rtv.subscription_page import SubscriptionPage
|
||||
from tuir.subscription_page import SubscriptionPage
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
@@ -56,7 +56,7 @@ def test_subscription_page_construct(reddit, terminal, config, oauth,
|
||||
|
||||
def test_subscription_refresh(subscription_page):
|
||||
|
||||
with mock.patch('rtv.terminal.Terminal.flash') as flash:
|
||||
with mock.patch('tuir.terminal.Terminal.flash') as flash:
|
||||
# Refresh content - invalid order
|
||||
subscription_page.refresh_content(order='top')
|
||||
assert flash.called
|
||||
|
||||
@@ -10,10 +10,10 @@ from textwrap import dedent
|
||||
import six
|
||||
import pytest
|
||||
|
||||
from rtv.theme import Theme
|
||||
from rtv.docs import (HELP, REPLY_FILE, COMMENT_EDIT_FILE, TOKEN,
|
||||
from tuir.theme import Theme
|
||||
from tuir.docs import (HELP, REPLY_FILE, COMMENT_EDIT_FILE, TOKEN,
|
||||
SUBMISSION_FILE, SUBMISSION_EDIT_FILE, MESSAGE_FILE)
|
||||
from rtv.exceptions import TemporaryFileError, BrowserError
|
||||
from tuir.exceptions import TemporaryFileError, BrowserError
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
@@ -29,13 +29,13 @@ def test_terminal_properties(terminal, config):
|
||||
assert isinstance(terminal.gilded, six.text_type)
|
||||
|
||||
terminal._display = None
|
||||
with mock.patch('rtv.terminal.sys') as sys, \
|
||||
with mock.patch('tuir.terminal.sys') as sys, \
|
||||
mock.patch.dict('os.environ', {'DISPLAY': ''}):
|
||||
sys.platform = 'linux'
|
||||
assert terminal.display is False
|
||||
|
||||
terminal._display = None
|
||||
with mock.patch('rtv.terminal.sys') as sys, \
|
||||
with mock.patch('tuir.terminal.sys') as sys, \
|
||||
mock.patch('os.environ', {'DISPLAY': ''}), \
|
||||
mock.patch('webbrowser._tryorder', new=[]):
|
||||
sys.platform = 'darwin'
|
||||
@@ -367,7 +367,7 @@ def test_terminal_open_link_mailcap(terminal):
|
||||
mock_mime_parser = MockMimeParser()
|
||||
|
||||
with mock.patch.object(terminal, 'open_browser'), \
|
||||
mock.patch('rtv.terminal.mime_parsers') as mime_parsers:
|
||||
mock.patch('tuir.terminal.mime_parsers') as mime_parsers:
|
||||
mime_parsers.parsers = [mock_mime_parser]
|
||||
|
||||
# Pass through to open_browser if media is disabled
|
||||
@@ -490,7 +490,7 @@ def test_terminal_open_browser_display(terminal):
|
||||
def test_terminal_open_browser_display_no_response(terminal):
|
||||
|
||||
terminal._display = True
|
||||
with mock.patch('rtv.terminal.Process', autospec=True) as Process:
|
||||
with mock.patch('tuir.terminal.Process', autospec=True) as Process:
|
||||
Process.return_value.is_alive.return_value = 1
|
||||
terminal.open_browser('http://www.test.com')
|
||||
assert isinstance(terminal.loader.exception, BrowserError)
|
||||
@@ -738,7 +738,7 @@ def test_terminal_get_link_page_text(terminal):
|
||||
{'href': 'https://www.reddit.com', 'text': 'Reddit Homepage'},
|
||||
{'href': 'https://www.duckduckgo.com', 'text': 'Search Engine'},
|
||||
{
|
||||
'href': 'https://gitlab.com/ajak/rtv',
|
||||
'href': 'https://gitlab.com/ajak/tuir',
|
||||
'text': 'This project\'s homepage'
|
||||
}
|
||||
]
|
||||
@@ -747,7 +747,7 @@ def test_terminal_get_link_page_text(terminal):
|
||||
assert text == dedent("""\
|
||||
[0] [Reddit Homepage](https://www.reddit.com)
|
||||
[1] [Search Engine](https://www.duckduckgo.com)
|
||||
[2] [This project's home…](https://gitlab.com/ajak/rtv)
|
||||
[2] [This project's home…](https://gitlab.com/ajak/tuir)
|
||||
""")
|
||||
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ from tempfile import mkdtemp, NamedTemporaryFile
|
||||
|
||||
import pytest
|
||||
|
||||
from rtv.theme import Theme
|
||||
from rtv.config import DEFAULT_THEMES
|
||||
from rtv.exceptions import ConfigError
|
||||
from tuir.theme import Theme
|
||||
from tuir.config import DEFAULT_THEMES
|
||||
from tuir.exceptions import ConfigError
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
|
||||
Reference in New Issue
Block a user