示例#1
0
    def test__get_version_info_loggers(self):
        mock_loggers = {
            'versionfinder': Mock(),
            'pip': Mock(),
            'git': Mock()
        }

        def se_getLogger(lname):
            return mock_loggers[lname]

        with patch('awslimitchecker.version.logging.getLogger') as mock_logger:
            mock_logger.side_effect = se_getLogger
            with patch.dict(
                'awslimitchecker.version.os.environ', {}, clear=True
            ):
                with patch('awslimitchecker.version.find_version'):
                    version._get_version_info()
        assert mock_logger.mock_calls == [
            call('versionfinder'),
            call('pip'),
            call('git')
        ]
        assert mock_loggers['versionfinder'].mock_calls == [
            call.setLevel(CRITICAL)
        ]
        assert mock_loggers['pip'].mock_calls == [
            call.setLevel(CRITICAL)
        ]
        assert mock_loggers['git'].mock_calls == [
            call.setLevel(CRITICAL)
        ]
示例#2
0
 def test__get_version_info_py32(self):
     with patch('awslimitchecker.version.logger') as mock_logger:
         version._get_version_info()
     assert mock_logger.mock_calls == [
         call.exception(
             'Error checking installed version; this installation'
             ' may not be in compliance with the AGPLv3 license:')
     ]
示例#3
0
    def test__get_version_info_loggers_enabled(self):
        mock_loggers = {'versionfinder': Mock(), 'pip': Mock(), 'git': Mock()}

        def se_getLogger(lname):
            return mock_loggers[lname]

        with patch('awslimitchecker.version.logging.getLogger') as mock_logger:
            mock_logger.side_effect = se_getLogger
            with patch.dict('awslimitchecker.version.os.environ',
                            {'VERSIONCHECK_DEBUG': 'true'},
                            clear=True):
                with patch('awslimitchecker.version.find_version'):
                    version._get_version_info()
        assert mock_logger.mock_calls == []
        assert mock_loggers['versionfinder'].mock_calls == []
        assert mock_loggers['pip'].mock_calls == []
        assert mock_loggers['git'].mock_calls == []
示例#4
0
 def test__get_version_info_long_commit(self):
     with patch('awslimitchecker.version.find_version') as mock_ver:
         mock_ver.return_value = VersionInfo(pip_url=version._PROJECT_URL,
                                             pip_version=version._VERSION,
                                             git_commit='12345678abcdef')
         v = version._get_version_info()
     assert v.release == version._VERSION
     assert v.url == version._PROJECT_URL
     assert v.commit == '12345678'
     assert mock_ver.mock_calls == [call('awslimitchecker')]
示例#5
0
 def test__get_version_info(self):
     with patch('awslimitchecker.version.find_version') as mock_ver:
         mock_ver.return_value = VersionInfo(pip_url=version._PROJECT_URL,
                                             pip_version=version._VERSION,
                                             git_tag='foobar')
         v = version._get_version_info()
     assert v.release == version._VERSION
     assert v.url == version._PROJECT_URL
     assert v.tag == 'foobar'
     assert mock_ver.mock_calls == [call('awslimitchecker')]
示例#6
0
    def test__get_version_info_loggers(self):
        mock_loggers = {'versionfinder': Mock(), 'pip': Mock(), 'git': Mock()}

        def se_getLogger(lname):
            return mock_loggers[lname]

        with patch('awslimitchecker.version.logging.getLogger') as mock_logger:
            mock_logger.side_effect = se_getLogger
            with patch.dict('awslimitchecker.version.os.environ', {},
                            clear=True):
                with patch('awslimitchecker.version.find_version'):
                    version._get_version_info()
        assert mock_logger.mock_calls == [
            call('versionfinder'),
            call('pip'), call('git')
        ]
        assert mock_loggers['versionfinder'].mock_calls == [
            call.setLevel(CRITICAL)
        ]
        assert mock_loggers['pip'].mock_calls == [call.setLevel(CRITICAL)]
        assert mock_loggers['git'].mock_calls == [call.setLevel(CRITICAL)]
示例#7
0
 def test__get_version_info_long_commit(self):
     with patch('awslimitchecker.version.find_version') as mock_ver:
         mock_ver.return_value = VersionInfo(
             pip_url=version._PROJECT_URL,
             pip_version=version._VERSION,
             git_commit='12345678abcdef'
         )
         v = version._get_version_info()
     assert v.release == version._VERSION
     assert v.url == version._PROJECT_URL
     assert v.commit == '12345678'
     assert mock_ver.mock_calls == [call('awslimitchecker')]
示例#8
0
 def test__get_version_info(self):
     with patch('awslimitchecker.version.find_version') as mock_ver:
         mock_ver.return_value = VersionInfo(
             pip_url=version._PROJECT_URL,
             pip_version=version._VERSION,
             git_tag='foobar'
         )
         v = version._get_version_info()
     assert v.release == version._VERSION
     assert v.url == version._PROJECT_URL
     assert v.tag == 'foobar'
     assert mock_ver.mock_calls == [call('awslimitchecker')]
示例#9
0
    def test__get_version_info_loggers_enabled(self):
        mock_loggers = {
            'versionfinder': Mock(),
            'pip': Mock(),
            'git': Mock()
        }

        def se_getLogger(lname):
            return mock_loggers[lname]

        with patch('awslimitchecker.version.logging.getLogger') as mock_logger:
            mock_logger.side_effect = se_getLogger
            with patch.dict(
                'awslimitchecker.version.os.environ',
                {'VERSIONCHECK_DEBUG': 'true'}, clear=True
            ):
                with patch('awslimitchecker.version.find_version'):
                    version._get_version_info()
        assert mock_logger.mock_calls == []
        assert mock_loggers['versionfinder'].mock_calls == []
        assert mock_loggers['pip'].mock_calls == []
        assert mock_loggers['git'].mock_calls == []
示例#10
0
    def test__get_version_info_fallback(self):
        def se(foo):
            raise Exception("foo")

        with patch('awslimitchecker.version.find_version') as mock_ver:
            mock_ver.side_effect = se
            with patch('awslimitchecker.version.logger') as mock_logger:
                v = version._get_version_info()
        assert v.release == version._VERSION
        assert v.url == version._PROJECT_URL
        assert v.tag is None
        assert v.commit is None
        assert mock_ver.mock_calls == [call('awslimitchecker')]
        assert mock_logger.mock_calls == [
            call.exception('Error checking installed version; this installation'
                           ' may not be in compliance with the AGPLv3 license:')
        ]
示例#11
0
 def test__get_version_info(self):
     with patch('awslimitchecker.version.AGPLVersionChecker',
                spec_set=AGPLVersionChecker) as mock_checker:
         mock_checker.return_value.find_package_version.return_value = {
             'version': version._VERSION,
             'url': version._PROJECT_URL,
             'tag': 'foobar',
             'commit': None,
         }
         v = version._get_version_info()
     assert v.release == version._VERSION
     assert v.url == version._PROJECT_URL
     assert v.tag == 'foobar'
     assert mock_checker.mock_calls == [
         call(),
         call().find_package_version(),
     ]
示例#12
0
    def test__get_version_info_fallback(self):
        def se(foo):
            raise Exception("foo")

        with patch('awslimitchecker.version.find_version') as mock_ver:
            mock_ver.side_effect = se
            with patch('awslimitchecker.version.logger') as mock_logger:
                v = version._get_version_info()
        assert v.release == version._VERSION
        assert v.url == version._PROJECT_URL
        assert v.tag is None
        assert v.commit is None
        assert mock_ver.mock_calls == [call('awslimitchecker')]
        assert mock_logger.mock_calls == [
            call.exception(
                'Error checking installed version; this installation'
                ' may not be in compliance with the AGPLv3 license:')
        ]
示例#13
0
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'awslimitchecker'
copyright = u'2015, Jason Antman'
author = u'Jason Antman'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = _get_version_info().version_str
# The full version, including alpha/beta/rc tags.
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
示例#14
0
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'awslimitchecker'
copyright = u'2015, Jason Antman'
author = u'Jason Antman'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = _get_version_info().version_str
# The full version, including alpha/beta/rc tags.
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'