def test_check_scancode_version():
    from unittest import mock
    pypi_mock_releases = {
        'releases': {
            '2.0.0': [],
            '2.0.0rc3': [],
            '2.0.1': [],
            '2.1.0': [],
            '3.4.1': [],
            '3.9.0rc3': [],
        }
    }
    def jget(*args, **kwargs):
        return pypi_mock_releases

    with mock.patch('requests.get') as mock_get:
        mock_get.return_value = mock.Mock(
            json=jget,
            status_code=200
        )
        expected1 = 'You are using ScanCode Toolkit version'
        expected2 = 'however the newer version 3.4.1 is available'
        result = outdated.check_scancode_version(force=True)
        assert expected1 in result
        assert expected2 in result
Exemplo n.º 2
0
def test_fetch_newer_version_local_git_version():
    from unittest import mock
    pypi_mock_releases = {
        'releases': {
            '2.0.0': [],
            '2.0.0rc3': [],
            '2.0.1': [],
            '2.1.0': [],
            '3.0.1': [],
            '3.1.2': [],
        }
    }

    def jget(*args, **kwargs):
        return pypi_mock_releases

    with mock.patch('requests.get') as mock_get:
        mock_get.return_value = mock.Mock(json=jget, status_code=200)

        result = outdated.fetch_newer_version(
            installed_version='3.1.2.post351.850399bc3',
            force=True,
        )
        assert not result

        result = outdated.check_scancode_version(
            installed_version='3.1.2.post351.850399bc3',
            force=True,
        )
        assert not result
Exemplo n.º 3
0
def test_check_scancode_version_no_new_version():
    from unittest import mock
    pypi_mock_releases = {
        'releases': {
            '2.0.0': [],
            '2.0.0rc3': [],
            '2.0.1': [],
            '2.1.0': [],
            '3.0.1': [],
            '3.9.0rc3': [],
        }
    }

    def jget(*args, **kwargs):
        return pypi_mock_releases

    with mock.patch('requests.get') as mock_get:
        mock_get.return_value = mock.Mock(json=jget, status_code=200)
        result = outdated.check_scancode_version(force=True)
        assert not result
Exemplo n.º 4
0
def test_check_scancode_version():
    from unittest import mock
    pypi_mock_releases = {
        'releases': {
            '2.0.0': [],
            '2.0.0rc3': [],
            '2.0.1': [],
            '2.1.0': [],
            '3.4.1': [],
            '22.1': [],
            '30.9.0rc3': [],
            '42.5.1': [],
        }
    }

    def jget(*args, **kwargs):
        return pypi_mock_releases

    with mock.patch('requests.get') as mock_get:
        mock_get.return_value = mock.Mock(json=jget, status_code=200)

        result = outdated.check_scancode_version(force=True)
        assert result.startswith('WARNING: Outdated ScanCode')
        assert 'A new version 42.5.1 is available' in result