def test_install_update_prereleases(httpserver, alfred4):
    """Auto-update installs update with pre-releases enabled"""
    def fake(wf):
        return

    # Mock subprocess.call etc. so the script doesn't try to
    # update the workflow in Alfred
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        update_settings = UPDATE_SETTINGS.copy()
        update_settings['prereleases'] = True
        with ctx(['workflow:update'], update_settings, clear=False) as (wf, c):
            wf.run(fake)
            wf.args

            print('Magic update command : {!r}'.format(c.cmd))

            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_install'

        with env(alfred_workflow_version='v10.0-beta'):
            update_settings = UPDATE_SETTINGS.copy()
            update_settings['version'] = 'v10.0-beta'
            update_settings['prereleases'] = True
            with ctx(['workflow:update'], update_settings) as (wf, c):
                wf.run(fake)
                wf.args
                dump_env()
                # Update command wasn't called
                assert c.cmd == ()
Exemplo n.º 2
0
def test_update(httpserver):
    """Auto-update installs update"""
    def fake(wf):
        return

    # Mock subprocess.call etc. so the script doesn't try to
    # update the workflow in Alfred
    with fakeresponse(httpserver, DATA_JSON, HTTP_HEADERS_JSON):
        with ctx(['workflow:update'], clear=False) as (wf, c):
            wf.run(fake)
            wf.args

            print('Magic update command : {0!r}'.format(c.cmd))

            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_install'

        update_settings = UPDATE_SETTINGS.copy()
        update_settings['version'] = 'v6.0'
        with ctx(['workflow:update'], update_settings) as (wf, c):
            wf.run(fake)
            wf.args

            # Update command wasn't called
            assert c.cmd == ()
def test_install_update_prereleases(httpserver, alfred4):
    """Auto-update installs update with pre-releases enabled"""
    def fake(wf):
        return

    # Mock subprocess.call etc. so the script doesn't try to
    # update the workflow in Alfred
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        update_settings = UPDATE_SETTINGS.copy()
        update_settings['prereleases'] = True
        with ctx(['workflow:update'], update_settings, clear=False) as (wf, c):
            wf.run(fake)
            wf.args

            print('Magic update command : {!r}'.format(c.cmd))

            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_install'

        with env(alfred_workflow_version='v10.0-beta'):
            update_settings = UPDATE_SETTINGS.copy()
            update_settings['version'] = 'v10.0-beta'
            update_settings['prereleases'] = True
            with ctx(['workflow:update'], update_settings) as (wf, c):
                wf.run(fake)
                wf.args
                dump_env()
                # Update command wasn't called
                assert c.cmd == ()
Exemplo n.º 4
0
def test_update_available(httpserver):
    """update_available property works"""
    slug = UPDATE_SETTINGS['github_slug']
    v = UPDATE_SETTINGS['version']
    with fakeresponse(httpserver, DATA_JSON, HTTP_HEADERS_JSON):
        with ctx() as (wf, c):
            assert wf.update_available is False
            update.check_update(slug, v)
            assert wf.update_available is True
def test_update_available(httpserver, alfred4):
    """update_available property works"""
    repo = UPDATE_SETTINGS['github_slug']
    v = os.getenv('alfred_workflow_version')
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        with ctx() as (wf, _):
            wf.reset()
            assert wf.update_available is False
            update.check_update(repo, v)
            assert wf.update_available is True
def test_update_available(httpserver, alfred4):
    """update_available property works"""
    repo = UPDATE_SETTINGS['github_slug']
    v = os.getenv('alfred_workflow_version')
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        with ctx() as (wf, _):
            wf.reset()
            assert wf.update_available is False
            update.check_update(repo, v)
            assert wf.update_available is True
def test_install_update(httpserver, alfred4):
    """Auto-update installs update"""
    def fake(wf):
        return

    # Mock subprocess.call etc. so the script doesn't try to
    # update the workflow in Alfred
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        with ctx(['workflow:update'], clear=False) as (wf, c):
            wf.run(fake)
            wf.args

            print('Magic update command : {0!r}'.format(c.cmd))

            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_install'

        update_settings = UPDATE_SETTINGS.copy()
        del update_settings['version']
        with env(alfred_workflow_version='v9.0'):
            with ctx(['workflow:update'], update_settings,
                     clear=False) as (wf, c):
                wf.run(fake)
                wf.args
                # Update command wasn't called
                assert c.cmd == (), "unexpected command call"

        # via update settings
        with env(alfred_workflow_version=None):
            update_settings['version'] = 'v9.0'
            with ctx(['workflow:update'], update_settings,
                     clear=False) as (wf, c):
                wf.run(fake)
                wf.args
                # Update command wasn't called
                assert c.cmd == (), "unexpected command call"

        # unversioned
        with env(alfred_workflow_version=None):
            del update_settings['version']
            with ctx(['workflow:update'], update_settings) as (wf, c):
                wf.run(fake)
                with pytest.raises(ValueError):
                    wf.args
def test_install_update(httpserver, alfred4):
    """Auto-update installs update"""
    def fake(wf):
        return

    # Mock subprocess.call etc. so the script doesn't try to
    # update the workflow in Alfred
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        with ctx(['workflow:update'], clear=False) as (wf, c):
            wf.run(fake)
            wf.args

            print('Magic update command : {0!r}'.format(c.cmd))

            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_install'

        update_settings = UPDATE_SETTINGS.copy()
        del update_settings['version']
        with env(alfred_workflow_version='v9.0'):
            with ctx(['workflow:update'],
                     update_settings, clear=False) as (wf, c):
                wf.run(fake)
                wf.args
                # Update command wasn't called
                assert c.cmd == (), "unexpected command call"

        # via update settings
        with env(alfred_workflow_version=None):
            update_settings['version'] = 'v9.0'
            with ctx(['workflow:update'],
                     update_settings, clear=False) as (wf, c):
                wf.run(fake)
                wf.args
                # Update command wasn't called
                assert c.cmd == (), "unexpected command call"

        # unversioned
        with env(alfred_workflow_version=None):
            del update_settings['version']
            with ctx(['workflow:update'], update_settings) as (wf, c):
                wf.run(fake)
                with pytest.raises(ValueError):
                    wf.args
def test_check_update(httpserver, alfred4):
    """Auto-update installs update"""
    def update(wf):
        wf.check_update()

    # Mock subprocess.call etc. so the script doesn't try to
    # update the workflow in Alfred
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        with ctx() as (wf, c):
            wf.run(update)
            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_check'

        update_settings = UPDATE_SETTINGS.copy()
        update_settings['prereleases'] = True
        with ctx(update_settings=update_settings) as (wf, c):
            wf.run(update)
            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_check'
def test_check_update(httpserver, alfred4):
    """Auto-update installs update"""
    def update(wf):
        wf.check_update()

    # Mock subprocess.call etc. so the script doesn't try to
    # update the workflow in Alfred
    with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON):
        with ctx() as (wf, c):
            wf.run(update)
            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_check'

        update_settings = UPDATE_SETTINGS.copy()
        update_settings['prereleases'] = True
        with ctx(update_settings=update_settings) as (wf, c):
            wf.run(update)
            assert c.cmd[0] == '/usr/bin/python'
            assert c.cmd[2] == '__workflow_update_check'