Exemplo n.º 1
0
    def test_read_config(self):
        fake_config = (
            "client_id: foo\n"
            "api_key: bar\n"
            "auth_key: ~/.ssh/foo\n"
            "auth_key_name: foo"
        ).encode('UTF-8')

        _open.side_effect = lambda *args, **kwargs: io.BytesIO(fake_config)
        assert configure.read_config() == {
            'client_id': 'foo',
            'api_key': 'bar',
            'auth_key': '~/.ssh/foo',
            'auth_key_name': 'foo',
        }
        fake_config = (
            "client_id: foo\n"
            "api_key: bar\n"
            "auth_key: ~/.ssh/foo\n"
        ).encode('UTF-8')

        _open.side_effect = lambda *args, **kwargs: io.BytesIO(fake_config)
        assert configure.read_config() == {
            'client_id': 'foo',
            'api_key': 'bar',
            'auth_key': '~/.ssh/foo',
            'auth_key_name': None,
        }
        _open.side_effect = lambda x: (_raise(IOError))
        configure.read_config() == {
            'client_id': 'foo',
            'api_key': 'bar',
            'auth_key': '~/.ssh/foo',
            'auth_key_name': None,
        }
Exemplo n.º 2
0
    def test_read_config(self):
        fake_config = (
            "api_token: foobar\n"
            "auth_key: ~/.ssh/foo\n"
            "auth_key_name: foo"
        ).encode('UTF-8')

        _open.side_effect = lambda *args, **kwargs: io.BytesIO(fake_config)
        assert configure.read_config() == {
            'api_token': 'foobar',
            'auth_key': '~/.ssh/foo',
            'auth_key_name': 'foo',
        }
        fake_config = (
            "api_token: foobar\n"
            "auth_key: ~/.ssh/foo\n"
        ).encode('UTF-8')

        _open.side_effect = lambda *args, **kwargs: io.BytesIO(fake_config)
        assert configure.read_config() == {
            'api_token': 'foobar',
            'auth_key': '~/.ssh/foo',
            'auth_key_name': None,
        }
        _open.side_effect = lambda x: (_raise(IOError))
        configure.read_config() == {
            'api_token': 'foobar',
            'auth_key': '~/.ssh/foo',
            'auth_key_name': None,
        }
Exemplo n.º 3
0
    def test_ssh_tools(self):
        _Popen.side_effect = ["/usr/bin/ssh-keygen", "/usr/bin/openssl"]
        assert configure.ssh_tools() is True

        _Popen.side_effect = lambda *args, **kwargs: (
            _raise(CalledProcessError("foo", "bar")))
        assert configure.ssh_tools() is False
Exemplo n.º 4
0
    def test_ssh_tools(self):
        _Popen.side_effect = ["/usr/bin/ssh-keygen", "/usr/bin/openssl"]
        assert configure.ssh_tools() is True

        _Popen.side_effect = lambda *args, **kwargs: (
            _raise(CalledProcessError("foo", "bar")))
        assert configure.ssh_tools() is False