def test_update_old_pip(self, subp_mock, plat_mock): keyman = Keyman(["foo", "-o", "foo", "-u", "bar"]) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = "100000" keyman.log = mock.MagicMock() plat_mock.system.return_value = "Linux" subp_mock.check_call.return_value = 0 keyman.update(__version__) keyman.log.info.assert_has_calls( [ mock.call("New version 100000. Updaing.."), ], ) subp_mock.assert_has_calls( [ mock.call.check_call( [ mock.ANY, "-m", "pip", "install", "--upgrade", "aws-okta-keyman", ], ), ], )
def test_update_current(self): keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar']) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = __version__ keyman.log = mock.MagicMock() keyman.update(__version__) keyman.log.info.assert_has_calls([mock.call('Keyman is up to date')])
def test_update_old_failed(self, subp_mock): keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar']) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = '100000' keyman.log = mock.MagicMock() subp_mock.check_call.return_value = 1 keyman.update(__version__) keyman.log.warning.assert_has_calls([ mock.call('Error updating Keyman. Please try updating manually.') ])
def test_update_current(self): keyman = Keyman(["foo", "-o", "foo", "-u", "bar"]) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = __version__ keyman.log = mock.MagicMock() keyman.update(__version__) keyman.log.info.assert_has_calls( [ mock.call("Keyman is up to date"), ], )
def test_update_old_brew(self, subp_mock, plat_mock): keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar']) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = '100000' keyman.log = mock.MagicMock() plat_mock.system.return_value = "Darwin" subp_mock.check_call.return_value = 0 keyman.update(__version__) keyman.log.info.assert_has_calls( [mock.call('New version 100000. Updaing..')]) subp_mock.assert_has_calls( [mock.call.check_call([u'brew', u'upgrade', u'aws_okta_keyman'])])
def test_update_old_failed(self, subp_mock): keyman = Keyman(["foo", "-o", "foo", "-u", "bar"]) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = "100000" keyman.log = mock.MagicMock() subp_mock.check_call.return_value = 1 keyman.update(__version__) keyman.log.warning.assert_has_calls( [ mock.call( "Error updating Keyman. Please try updating manually.", ), ], )
def test_update_old_pip(self, subp_mock, plat_mock): keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar']) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = '100000' keyman.log = mock.MagicMock() plat_mock.system.return_value = "Linux" subp_mock.check_call.return_value = 0 keyman.update(__version__) keyman.log.info.assert_has_calls( [mock.call('New version 100000. Updaing..')]) subp_mock.assert_has_calls([ mock.call.check_call([ mock.ANY, '-m', 'pip', 'install', '--upgrade', 'aws-okta-keyman' ]) ])
def test_update_old_brew(self, subp_mock, plat_mock): keyman = Keyman(["foo", "-o", "foo", "-u", "bar"]) keyman.get_pip_version = mock.MagicMock() keyman.get_pip_version.return_value = "100000" keyman.log = mock.MagicMock() plat_mock.system.return_value = "Darwin" subp_mock.check_call.return_value = 0 keyman.update(__version__) keyman.log.info.assert_has_calls( [ mock.call("New version 100000. Updaing.."), ], ) subp_mock.assert_has_calls( [ mock.call.check_call(["brew", "upgrade", "aws_okta_keyman"]), ], )
def test_main_update(self, config_mock): config_mock().update = True keyman = Keyman(["foo", "-o", "foo", "-u", "bar", "-a", "baz"]) keyman.update = mock.MagicMock() keyman.handle_appid_selection = mock.MagicMock() keyman.user_password = mock.MagicMock() keyman.user_password.return_value = "foo" keyman.init_okta = mock.MagicMock() keyman.auth_okta = mock.MagicMock() keyman.aws_auth_loop = mock.MagicMock() with self.assertRaises(SystemExit): keyman.main() keyman.update.assert_has_calls([mock.call(__version__)])