Example #1
0
    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",
                    ],
                ),
            ],
        )
Example #2
0
    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')])
Example #3
0
    def test_get_pip_version(self, requests_mock):
        resp = {'info': {'version': '1.0'}}
        resp_mock = mock.MagicMock()
        resp_mock.json.return_value = resp
        requests_mock.get.return_value = resp_mock

        ret = Keyman.get_pip_version()

        self.assertEqual(ret, '1.0')
        requests_mock.assert_has_calls(
            [mock.call.get(u'https://pypi.org/pypi/aws-okta-keyman/json')])
Example #4
0
    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.')
        ])
Example #5
0
    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"),
            ],
        )
Example #6
0
    def test_get_pip_version(self, requests_mock):
        resp = {"info": {"version": "1.0"}}
        resp_mock = mock.MagicMock()
        resp_mock.json.return_value = resp
        requests_mock.get.return_value = resp_mock

        ret = Keyman.get_pip_version()

        self.assertEqual(ret, "1.0")
        requests_mock.assert_has_calls(
            [
                mock.call.get("https://pypi.org/pypi/aws-okta-keyman/json"),
            ],
        )
Example #7
0
    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'])])
Example #8
0
    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.",
                ),
            ],
        )
Example #9
0
    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'
            ])
        ])
Example #10
0
    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"]),
            ],
        )