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_wrap_up_noop(self, config_mock): config_mock().command = None config_mock().console = None keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar', '-a', 'baz']) keyman.log = mock.MagicMock() keyman.wrap_up(None) keyman.log.assert_has_calls([mock.call.info('All done! 👍')])
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_wrap_up_noop(self, config_mock): config_mock().command = None config_mock().console = None keyman = Keyman(["foo", "-o", "foo", "-u", "bar", "-a", "baz"]) keyman.log = mock.MagicMock() keyman.wrap_up(None) keyman.log.assert_has_calls( [ mock.call.info("All done! 👍"), ], )
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"]), ], )