Esempio n. 1
0
def test_nsis_options(pack, mocker):

    mocker.patch('pyci.api.utils.is_windows')

    mocker.patch(target='pyci.api.package.packager.Packager.nsis',
                 new=test_utils.MagicMock())

    pack.run('nsis '
             '--binary-path binary-path '
             '--version version '
             '--output output '
             '--author author '
             '--url url '
             '--copyright copyright '
             '--license license '
             '--program-files-dir pf')

    # noinspection PyUnresolvedReferences
    Packager.nsis.assert_called_once_with(
        'binary-path',  # pylint: disable=no-member
        version='version',
        output='output',
        author='author',
        url='url',
        copyright_string='copyright',
        license_path='license',
        program_files_dir='pf')
Esempio n. 2
0
def test_release_not_fast_forward(pyci, repo, mocker):

    ci_provider = ci.detect(environ={
        'TRAVIS': 'True',
        'TRAVIS_REPO_SLUG': REPO_UNDER_TEST,
        'TRAVIS_BRANCH': 'release',
        'TRAVIS_COMMIT': '5b0aa87aac95cc24d24684f30daab44d2cc61d5d',
        'TRAVIS_TAG': None,
        'TRAVIS_PULL_REQUEST': 'false'
    })

    detect = test_utils.MagicMock(return_value=ci_provider)

    mocker.patch(target='pyci.api.ci.ci.detect', new=detect)

    result = pyci.run('github --repo {} release --force --branch release'
                      .format(REPO_UNDER_TEST),
                      catch_exceptions=True)

    expected_output = 'is not a fast-forward'
    expected_number_of_releases = 0
    expected_number_of_tags = 0
    releases = repo.get_releases()
    tags = repo.get_tags()

    assert expected_output in result.std_out
    assert expected_number_of_releases == len(list(releases))
    assert expected_number_of_tags == len(list(tags))
Esempio n. 3
0
def test_validate_build_pull_request():

    ci_system = test_utils.MagicMock()

    ci_system.pull_request = 5

    with pytest.raises(exceptions.BuildIsAPullRequestException):
        # noinspection PyTypeChecker
        ci.validate_build(ci_provider=ci_system, release_branch='release')
Esempio n. 4
0
def test_validate_build():

    ci_system = test_utils.MagicMock()

    ci_system.pull_request = None
    ci_system.tag = None
    ci_system.branch = 'release'

    # noinspection PyTypeChecker
    ci.validate_build(ci_provider=ci_system, release_branch='release')
Esempio n. 5
0
def test_wheel_options(pack, mocker):

    mocker.patch(target='pyci.api.package.packager.Packager.wheel',
                 new=test_utils.MagicMock())

    pack.run('wheel --universal --wheel-version 0.33.4')

    # noinspection PyUnresolvedReferences
    Packager.wheel.assert_called_once_with(
        universal=True,  # pylint: disable=no-member
        wheel_version='0.33.4')
Esempio n. 6
0
def test_validate_build_branch():

    ci_system = test_utils.MagicMock()

    ci_system.pull_request = None
    ci_system.tag = None
    ci_system.branch = 'branch'

    with pytest.raises(
            exceptions.BuildBranchDiffersFromReleaseBranchException):
        # noinspection PyTypeChecker
        ci.validate_build(ci_provider=ci_system, release_branch='release')
Esempio n. 7
0
def test_binary_options(pack, mocker):

    mocker.patch(target='pyci.api.package.packager.Packager.binary',
                 new=test_utils.MagicMock())

    pack.run('binary '
             '--base-name name '
             '--entrypoint entrypoint '
             '--pyinstaller-version 3.4')

    # noinspection PyUnresolvedReferences
    Packager.binary.assert_called_once_with(
        base_name='name',  # pylint: disable=no-member
        entrypoint='entrypoint',
        pyinstaller_version='3.4')
Esempio n. 8
0
def test_upload(pypi, pyci, mocker):

    mocker.patch(target='twine.commands.upload.main',
                 new=test_utils.MagicMock())

    pypi.api.upload(wheel=pyci.wheel_path)

    expected_args = [
        '--username',
        secrets.twine_username(), '--password',
        secrets.twine_password(), '--repository-url',
        'https://test.pypi.org/legacy/', pyci.wheel_path
    ]

    # noinspection PyUnresolvedReferences
    upload.main.assert_called_once_with(expected_args)  # pylint: disable=no-member
Esempio n. 9
0
def test_validate_build(pyci, mocker):

    ci_provider = ci.detect(
        environ={
            'TRAVIS': 'True',
            'TRAVIS_REPO_SLUG': 'repo',
            'TRAVIS_BRANCH': 'release',
            'TRAVIS_COMMIT': None,
            'TRAVIS_TAG': None,
            'TRAVIS_PULL_REQUEST': 'false'
        })

    detect = test_utils.MagicMock(return_value=ci_provider)

    mocker.patch(target='pyci.api.ci.ci.detect', new=detect)

    result = pyci.run('ci validate-build --release-branch release')

    expected_output = 'Validation passed'

    assert expected_output in result.std_out