Removing platform dependent tests because they're hard to keep up to date and not that useful
This commit is contained in:
@@ -497,93 +497,6 @@ def test_submission_urlview(submission_page, terminal, refresh_token):
|
||||
open_urlview.assert_called_with('http://test.url.com ❤')
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform != 'darwin', reason='Test uses osx clipboard')
|
||||
def test_copy_to_clipboard_osx(submission_page, terminal, refresh_token):
|
||||
|
||||
def get_clipboard_content():
|
||||
p = subprocess.Popen(['pbpaste', 'r'],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
close_fds=True)
|
||||
stdout, stderr = p.communicate()
|
||||
return stdout.decode('utf-8')
|
||||
|
||||
window = terminal.stdscr.subwin
|
||||
|
||||
# Log in
|
||||
submission_page.config.refresh_token = refresh_token
|
||||
submission_page.oauth.authorize()
|
||||
|
||||
# Get submission
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
|
||||
# Trigger copy command for permalink
|
||||
submission_page.controller.trigger('y')
|
||||
assert data.get('permalink') == get_clipboard_content()
|
||||
window.addstr.assert_called_with(1, 1, b'Copied permalink to clipboard')
|
||||
|
||||
# Trigger copy command for submission
|
||||
submission_page.controller.trigger('Y')
|
||||
assert data.get('url_full') == get_clipboard_content()
|
||||
window.addstr.assert_called_with(1, 1, b'Copied url to clipboard')
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform == 'darwin', reason='Test uses linux clipboard')
|
||||
def test_copy_to_clipboard_linux(submission_page, terminal, refresh_token):
|
||||
|
||||
def get_clipboard_content():
|
||||
paste_cmd = None
|
||||
for cmd in ['xsel', 'xclip']:
|
||||
cmd_exists = subprocess.call(
|
||||
['which', cmd],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
|
||||
if cmd_exists:
|
||||
paste_cmd = cmd
|
||||
break
|
||||
|
||||
if paste_cmd is not None:
|
||||
cmd_args = {'xsel': ['xsel', '-b', '-o'],
|
||||
'xclip': ['xclip', '-selection', 'c', '-o']}
|
||||
p = subprocess.Popen(cmd_args.get(paste_cmd),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
close_fds=True)
|
||||
stdout, stderr = p.communicate()
|
||||
return stdout.decode('utf-8')
|
||||
|
||||
window = terminal.stdscr.subwin
|
||||
|
||||
# Log in
|
||||
submission_page.config.refresh_token = refresh_token
|
||||
submission_page.oauth.authorize()
|
||||
|
||||
# Get submission
|
||||
data = submission_page.content.get(submission_page.nav.absolute_index)
|
||||
|
||||
# Trigger copy command for permalink
|
||||
submission_page.controller.trigger('y')
|
||||
content = get_clipboard_content()
|
||||
if content is not None:
|
||||
assert data.get('permalink') == content
|
||||
window.addstr.assert_called_with(1, 1, b'Copied permalink to clipboard')
|
||||
else:
|
||||
# Neither xclip or xsel installed, this is what happens on Travis CI
|
||||
text = b'Failed to copy permalink: External copy application not found'
|
||||
window.addstr.assert_called_with(1, 1, text)
|
||||
|
||||
# Trigger copy command for url
|
||||
submission_page.controller.trigger('Y')
|
||||
content = get_clipboard_content()
|
||||
if content is not None:
|
||||
assert data.get('url_full') == content
|
||||
window.addstr.assert_called_with(1, 1, b'Copied url to clipboard')
|
||||
else:
|
||||
# Neither xclip or xsel installed, this is what happens on Travis CI
|
||||
text = b'Failed to copy url: External copy application not found'
|
||||
window.addstr.assert_called_with(1, 1, text)
|
||||
|
||||
|
||||
def test_submission_prompt_and_select_link(submission_page, terminal):
|
||||
|
||||
# A link submission should return the URL that it's pointing to
|
||||
|
||||
Reference in New Issue
Block a user