Merge lp:~ddstreet/launchpadlib/sudotests into lp:launchpadlib

Proposed by Dan Streetman
Status: Merged
Merged at revision: 182
Proposed branch: lp:~ddstreet/launchpadlib/sudotests
Merge into: lp:launchpadlib
Diff against target: 61 lines (+16/-0)
1 file modified
src/launchpadlib/tests/test_launchpad.py (+16/-0)
To merge this branch: bzr merge lp:~ddstreet/launchpadlib/sudotests
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+382542@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dan Streetman (ddstreet) wrote :
Revision history for this message
Dan Streetman (ddstreet) wrote :
Revision history for this message
Colin Watson (cjwatson) wrote :

Ah, right, that makes sense. Will merge, thanks!

review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

The packaging change can be avoided by using the standard library unittest.mock instead in the Python 3 case. I'll do that as part of the merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/launchpadlib/tests/test_launchpad.py'
--- src/launchpadlib/tests/test_launchpad.py 2019-11-07 17:40:56 +0000
+++ src/launchpadlib/tests/test_launchpad.py 2020-04-18 20:15:43 +0000
@@ -19,6 +19,7 @@
19__metaclass__ = type19__metaclass__ = type
2020
21from contextlib import contextmanager21from contextlib import contextmanager
22from mock import patch
22import os23import os
23import shutil24import shutil
24import socket25import socket
@@ -612,6 +613,7 @@
612 launchpadlib.launchpad.socket = socket613 launchpadlib.launchpad.socket = socket
613 shutil.rmtree(self.temp_dir)614 shutil.rmtree(self.temp_dir)
614615
616 @patch.object(NoNetworkLaunchpad, '_is_sudo', lambda: False)
615 def test_credentials_save_failed(self):617 def test_credentials_save_failed(self):
616 # If saving the credentials did not succeed and a callback was618 # If saving the credentials did not succeed and a callback was
617 # provided, it is called.619 # provided, it is called.
@@ -631,6 +633,7 @@
631 credential_save_failed=callback)633 credential_save_failed=callback)
632 self.assertEqual(len(callback_called), 1)634 self.assertEqual(len(callback_called), 1)
633635
636 @patch.object(NoNetworkLaunchpad, '_is_sudo', lambda: False)
634 def test_default_credentials_save_failed_is_to_raise_exception(self):637 def test_default_credentials_save_failed_is_to_raise_exception(self):
635 # If saving the credentials did not succeed and no callback was638 # If saving the credentials did not succeed and no callback was
636 # provided, the underlying exception is raised.639 # provided, the underlying exception is raised.
@@ -643,6 +646,17 @@
643 'not important', service_root=service_root,646 'not important', service_root=service_root,
644 launchpadlib_dir=launchpadlib_dir)647 launchpadlib_dir=launchpadlib_dir)
645648
649 @patch.object(NoNetworkLaunchpad, '_is_sudo', lambda: True)
650 def test_credentials_save_fail_under_sudo_does_not_raise_exception(self):
651 # When running under sudo, Launchpad will not attempt to use
652 # the keyring, so credential save failure will never happen
653 launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')
654 service_root = "http://api.example.com/"
655 with fake_keyring(BadSaveKeyring()):
656 NoNetworkLaunchpad.login_with(
657 'not important', service_root=service_root,
658 launchpadlib_dir=launchpadlib_dir)
659
646660
647class TestMultipleSites(unittest.TestCase):661class TestMultipleSites(unittest.TestCase):
648 # If the same application name (consumer name) is used to access more than662 # If the same application name (consumer name) is used to access more than
@@ -660,6 +674,7 @@
660 launchpadlib.launchpad.socket = socket674 launchpadlib.launchpad.socket = socket
661 shutil.rmtree(self.temp_dir)675 shutil.rmtree(self.temp_dir)
662676
677 @patch.object(NoNetworkLaunchpad, '_is_sudo', lambda: False)
663 def test_components_of_application_key(self):678 def test_components_of_application_key(self):
664 launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')679 launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')
665 keyring = InMemoryKeyring()680 keyring = InMemoryKeyring()
@@ -684,6 +699,7 @@
684 # "forgotten").699 # "forgotten").
685 self.assertEqual(application_key, consumer_name + '@' + service_root)700 self.assertEqual(application_key, consumer_name + '@' + service_root)
686701
702 @patch.object(NoNetworkLaunchpad, '_is_sudo', lambda: False)
687 def test_same_app_different_servers(self):703 def test_same_app_different_servers(self):
688 launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')704 launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')
689 keyring = InMemoryKeyring()705 keyring = InMemoryKeyring()

Subscribers

People subscribed via source and target branches