Esempio n. 1
0
    def __getattribute__(self, name):
        # attempt to use any attributes first
        value = object.__getattribute__(self, name)
        if value:
            LOG.debug("Retrieved '{}' setting from cache".format(name))
            return value

        # fallback to reading from git config otherwise
        value = utils.git_config('pw.{}'.format(name))
        if value:
            LOG.debug("Retrieved '{}' setting from git-config".format(name))

        setattr(self, name, value)

        return value
Esempio n. 2
0
    def __getattribute__(self, name):
        # attempt to use any attributes first
        try:
            value = super(Config, self).__getattribute__(name)
        except AttributeError:
            value = None
        if value:
            LOG.debug("Retrieved '{}' setting from cache".format(name))
            return value

        # fallback to reading from git config otherwise
        value = utils.git_config('pw.{}'.format(name))
        if value:
            LOG.debug("Retrieved '{}' setting from git-config".format(name))

        setattr(self, name, value)

        return value
Esempio n. 3
0
def test_git_config_error(mock_subprocess):
    value = utils.git_config('foo')

    assert value == ''
Esempio n. 4
0
def test_git_config_unicode(mock_subprocess):
    value = utils.git_config('foo')

    assert value == u'\U0001f937'
    mock_subprocess.assert_called_once_with(['git', 'config', 'foo'])
Esempio n. 5
0
def test_git_config(mock_subprocess):
    value = utils.git_config('foo')

    assert value == 'bar'
    mock_subprocess.assert_called_once_with(['git', 'config', 'foo'])