I've got lots of comments, but they're all fairly minor.
[1]
+ * Launchpad.login_securely, for programs that are run with user
+ interaction.
+ * Launchpad.login_insecurely, for programs that must run with no
+ user interaction.
These names worry me. I don't want to debate these names if they have
already been discussed. I just want to say: if I am the only person to
have seen them then I think they need some discussion, though not a
lot.
[2]
+
+
+ def do_load(self, unique_key):
Dangerous extra blank line.
[3]
Some lint:
credentials.py:29: 'base64' imported but unused
credentials.py:34: 'sys' imported but unused
credentials.py:35: 'textwrap' imported but unused
credentials.py:37: 'quote' imported but unused
launchpad.py:25: 'socket' imported but unused
launchpad.py:26: 'stat' imported but unused
launchpad.py:29: 'HostedFile' imported but unused
launchpad.py:29: 'ScalarValue' imported but unused
launchpad.py:36: 'SystemWideConsumer' imported but unused
launchpad.py:52: 'STAGING_SERVICE_ROOT' imported but unused
launchpad.py:52: 'EDGE_SERVICE_ROOT' imported but unused
testing/helpers.py:37: 'simplejson' imported but unused
testing/helpers.py:41: 'AuthorizeRequestTokenWithBrowser' imported but unused
testing/helpers.py:41: 'Credentials' imported but unused
tests/test_launchpad.py:21: 'StringIO' imported but unused
tests/test_launchpad.py:27: 'textwrap' imported but unused
tests/test_launchpad.py:226: local variable 'launchpad' is assigned to but never used
tests/test_launchpad.py:253: local variable 'launchpad' is assigned to but never used
tests/test_launchpad.py:263: local variable 'launchpad' is assigned to but never used
tests/test_launchpad.py:320: local variable 'launchpad' is assigned to but never used
tests/test_launchpad.py:534: local variable 'launchpad' is assigned to but never used
tests/test_launchpad.py:618: local variable 'service_root' is assigned to but never used
Because file() is a builtin function/type consider using filename or
filepath instead, or something like that.
[5]
+ This method is deprecated as of launchpadlib version
+ 1.9.0. You should use Launchpad.login_anonymously() for
+ anonymous access, Launchpad.login_insecurely() for scripts
+ that need to run without any user interaction, and
+ Launchpad.login_securely() for all other purposes, possibly
+ specifying a custom authorization_engine or credential_store.
Perhaps it's worth putting some or all of this into a deprecation
warning, warnings.warn("...", DeprecationWarning)?
+ launchpad = NoNetworkLaunchpad.login_insecurely(
+ filename, application_name='not important')
+
+ # The credentials are stored unencrypted in the file you
+ # specify.
+ credentials = Credentials.load_from_path(filename)
+ self.assertEquals(credentials.consumer.key,
+ launchpad.credentials.consumer.key)
+ os.remove(filename)
This won't get run if there's an earlier exception.
If you're happy to make launchpadlib depend on testtools, and inherit
from testtools.TestCase, you could use self.addCleanup(os.remove,
filename) immediately after calling mkstemp() to avoid this (small)
problem.
[10]
+ def test_credential_save_failed(self):
+ # Verify that credential_save_failed is called if there's a
+ # problem writing the file.
+ #stub_file = StringIO()
+ #launchpad = NoNetworkLaunchpad.login_insecurely(
+ # stub_file, application_name='not important')
+ pass
Did you mean to do something with this?
[11]
+ def test_login_with_with_credentials_file(self):
+ # If you pass credentials_file into login_with, the
+ # credentials are stored in that file.
+ filename = tempfile.mktemp()
The new CredentialStore stuff is cool.
I've got lots of comments, but they're all fairly minor.
[1]
+ * Launchpad. login_securely, for programs that are run with user login_insecurel y, for programs that must run with no
+ interaction.
+ * Launchpad.
+ user interaction.
These names worry me. I don't want to debate these names if they have
already been discussed. I just want to say: if I am the only person to
have seen them then I think they need some discussion, though not a
lot.
[2]
+
+
+ def do_load(self, unique_key):
Dangerous extra blank line.
[3]
Some lint:
credentials.py:29: 'base64' imported but unused umer' imported but unused SERVICE_ ROOT' imported but unused helpers. py:37: 'simplejson' imported but unused helpers. py:41: 'AuthorizeReque stTokenWithBrow ser' imported but unused helpers. py:41: 'Credentials' imported but unused launchpad. py:21: 'StringIO' imported but unused launchpad. py:27: 'textwrap' imported but unused launchpad. py:226: local variable 'launchpad' is assigned to but never used launchpad. py:253: local variable 'launchpad' is assigned to but never used launchpad. py:263: local variable 'launchpad' is assigned to but never used launchpad. py:320: local variable 'launchpad' is assigned to but never used launchpad. py:534: local variable 'launchpad' is assigned to but never used launchpad. py:618: local variable 'service_root' is assigned to but never used
credentials.py:34: 'sys' imported but unused
credentials.py:35: 'textwrap' imported but unused
credentials.py:37: 'quote' imported but unused
launchpad.py:25: 'socket' imported but unused
launchpad.py:26: 'stat' imported but unused
launchpad.py:29: 'HostedFile' imported but unused
launchpad.py:29: 'ScalarValue' imported but unused
launchpad.py:36: 'SystemWideCons
launchpad.py:52: 'STAGING_
launchpad.py:52: 'EDGE_SERVICE_ROOT' imported but unused
testing/
testing/
testing/
tests/test_
tests/test_
tests/test_
tests/test_
tests/test_
tests/test_
tests/test_
tests/test_
[4]
+ def __init__(self, file, credential_ save_failed= None): edFileCredentia lStore, self).__init__( save_failed)
+ super(Unencrypt
+ credential_
+ self.file = file
Because file() is a builtin function/type consider using filename or
filepath instead, or something like that.
[5]
+ This method is deprecated as of launchpadlib version login_anonymous ly() for login_insecurel y() for scripts login_securely( ) for all other purposes, possibly engine or credential_store.
+ 1.9.0. You should use Launchpad.
+ anonymous access, Launchpad.
+ that need to run without any user interaction, and
+ Launchpad.
+ specifying a custom authorization_
Perhaps it's worth putting some or all of this into a deprecation warn(". ..", DeprecationWarn ing)?
warning, warnings.
[6]
+@contextmanager credentials. keyring credentials. keyring = fake credentials. keyring = original_keyring
+def fake_keyring(fake):
+ original_keyring = launchpadlib.
+ launchpadlib.
+ yield
+ launchpadlib.
This will break when a test fails because the yield can raise an
exception. Something like the following would work better I think:
@contextmanager keyring = launchpadlib. credentials. keyring b.credentials. keyring = fake
launchpadlib. credentials. keyring = original_keyring
def fake_keyring(fake):
original_
launchpadli
try:
yield
finally:
[7]
+ self.filename = tempfile.mktemp()
mkstemp() should be used instead of mktemp().
The docstring says it's "unsafe and should not be used". Why it's
still in the standard library I don't really know!
[8]
+ def test_filename( self):
+ filename = tempfile.mktemp()
Again, mkstemp().
[9]
+ launchpad = NoNetworkLaunch pad.login_ insecurely( name='not important') load_from_ path(filename) ls(credentials. consumer. key, credentials. consumer. key)
+ filename, application_
+
+ # The credentials are stored unencrypted in the file you
+ # specify.
+ credentials = Credentials.
+ self.assertEqua
+ launchpad.
+ os.remove(filename)
This won't get run if there's an earlier exception.
If you're happy to make launchpadlib depend on testtools, and inherit (os.remove,
from testtools.TestCase, you could use self.addCleanup
filename) immediately after calling mkstemp() to avoid this (small)
problem.
[10]
+ def test_credential _save_failed( self): save_failed is called if there's a pad.login_ insecurely( name='not important')
+ # Verify that credential_
+ # problem writing the file.
+ #stub_file = StringIO()
+ #launchpad = NoNetworkLaunch
+ # stub_file, application_
+ pass
Did you mean to do something with this?
[11]
+ def test_login_ with_with_ credentials_ file(self) :
+ # If you pass credentials_file into login_with, the
+ # credentials are stored in that file.
+ filename = tempfile.mktemp()
Another mktemp().
[12]
+ launchpad = NoNetworkLaunch pad.login_ with( file=filename) launchpad. credential_ store, CredentialStore ))
+ 'not important', credentials_
+ self.assertTrue(
+ isinstance(
+ UnencryptedFile
+ os.remove(filename)
Same as [9].