Added tests for the open_link method.

This commit is contained in:
Michael Lazar
2016-07-26 00:43:42 -07:00
parent fdb46f8ec7
commit 0dbb3459ed
5 changed files with 126 additions and 15 deletions

View File

@@ -264,20 +264,19 @@ def test_submission_urlview(submission_page, terminal, refresh_token):
submission_page.config.refresh_token = refresh_token
submission_page.oauth.authorize()
# Positive Case
# Submission case
data = submission_page.content.get(submission_page.nav.absolute_index)
data['body'] = 'test comment body'
data['body'] = 'test comment body'
with mock.patch.object(terminal, 'open_urlview') as open_urlview, \
mock.patch('subprocess.Popen'):
submission_page.controller.trigger('b')
open_urlview.assert_called_with('test comment body')
open_urlview.assert_called_with('test comment body')
# Negative Case
# Subreddit case
data = submission_page.content.get(submission_page.nav.absolute_index)
data['text'] = ''
data['body'] = ''
data['url_full'] = 'http://test.url.com'
data['url_full'] = 'http://test.url.com'
with mock.patch.object(terminal, 'open_urlview') as open_urlview, \
mock.patch('subprocess.Popen'):
submission_page.controller.trigger('b')
open_urlview.assert_called_with('http://test.url.com')
open_urlview.assert_called_with('http://test.url.com')