Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] The Guardian, Twitter, NYT: Error credentials #253

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions orangecontrib/text/widgets/owguardian.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def __init__(self, parent):
self.load_credentials()

def load_credentials(self):
if self.cm_key.key:
self.key_edit.setText(self.cm_key.key)
key = self.cm_key.key
if key:
self.key_edit.setText(key)

def save_credentials(self):
self.cm_key.key = self.key_input
Expand All @@ -62,6 +63,7 @@ def accept(self, silent=False):
if not silent: self.Error.invalid_credentials.clear()
self.check_credentials()
if self.api:

self.parent.update_api(self.api)
super().accept()
elif not silent:
Expand Down
4 changes: 3 additions & 1 deletion orangecontrib/text/widgets/ownyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def __init__(self, parent):
self.load_credentials()

def load_credentials(self):
self.key_edit.setText(self.cm_key.key)
key = self.cm_key.key
if key:
self.key_edit.setText(key)

def save_credentials(self):
self.cm_key.key = self.key_input
Expand Down
8 changes: 6 additions & 2 deletions orangecontrib/text/widgets/owtwitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ def __init__(self, parent):
self.load_credentials()

def load_credentials(self):
self.key_edit.setText(self.cm_key.key)
self.secret_edit.setText(self.cm_secret.key)
key = self.cm_key.key
secret_key = self.cm_secret.key
if key:
self.key_edit.setText(key)
if secret_key:
self.secret_edit.setText(secret_key)

def save_credentials(self):
self.cm_key.key = self.key_input
Expand Down
21 changes: 21 additions & 0 deletions orangecontrib/text/widgets/tests/test_owguardian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import unittest

from Orange.widgets.tests.base import WidgetTest

from orangecontrib.text.widgets.owguardian import OWGuardian


class TestGuardian(WidgetTest):
def test_error_credentials(self):
"""
Handling error due to password credentials.
GH-253
"""
with unittest.mock.patch(
"keyring.get_password",
side_effect=ValueError):
self.create_widget(OWGuardian)


if __name__ == "__main__":
unittest.main()
21 changes: 21 additions & 0 deletions orangecontrib/text/widgets/tests/test_ownyt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import unittest

from Orange.widgets.tests.base import WidgetTest

from orangecontrib.text.widgets.ownyt import OWNYT


class TestGuardian(WidgetTest):
def test_error_credentials(self):
"""
Handling error due to password credentials.
GH-253
"""
with unittest.mock.patch(
"Orange.widgets.credentials.CredentialManager.__getattr__",
side_effect=Exception):
self.create_widget(OWNYT)


if __name__ == "__main__":
unittest.main()
21 changes: 21 additions & 0 deletions orangecontrib/text/widgets/tests/test_owtwitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import unittest

from Orange.widgets.tests.base import WidgetTest

from orangecontrib.text.widgets.owtwitter import OWTwitter


class TestGuardian(WidgetTest):
def test_error_credentials(self):
"""
Handling error due to password credentials.
GH-253
"""
with unittest.mock.patch(
"Orange.widgets.credentials.CredentialManager.__getattr__",
side_effect=Exception):
self.create_widget(OWTwitter)


if __name__ == "__main__":
unittest.main()