Commit 8fd3bb40 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

tests: Migrate test for load_ref() unsupporting plugins into format/project.py

The tests/format/project.py test already has some tests about how
we error gracefully for bad plugins and bad plugin configurations,
lets put it there rather than tests/pipeline/load.py which we
will remove.
parent e5fd96d4
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -155,6 +155,38 @@ def test_project_plugin_load_forbidden(cli, datafiles):
    result.assert_main_error(ErrorDomain.PLUGIN, None)


@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
def test_project_plugin_no_load_ref(cli, datafiles, ref_storage):
    project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-no-load-ref')

    # Generate project with access to the noloadref plugin and project.refs enabled
    #
    config = {
        'name': 'test',
        'ref-storage': ref_storage,
        'plugins': [
            {
                'origin': 'local',
                'path': 'plugins',
                'sources': {
                    'noloadref': 0
                }
            }
        ]
    }
    _yaml.dump(config, os.path.join(project, 'project.conf'))

    result = cli.run(project=project, silent=True, args=['show', 'noloadref.bst'])

    # There is no error if project.refs is not in use, otherwise we
    # assert our graceful failure
    if ref_storage == 'inline':
        result.assert_success()
    else:
        result.assert_main_error(ErrorDomain.SOURCE, 'unsupported-load-ref')


@pytest.mark.datafiles(DATA_DIR)
def test_project_conf_duplicate_plugins(cli, datafiles):
    project = os.path.join(datafiles.dirname, datafiles.basename, 'duplicate-plugins')
+0 −32
Original line number Diff line number Diff line
@@ -16,35 +16,3 @@ def test_load_simple(cli, datafiles):
    result = cli.get_element_config(basedir, 'simple.bst')

    assert(result['configure-commands'][0] == 'pony')


@pytest.mark.datafiles(os.path.join(DATA_DIR, 'noloadref'))
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
def test_unsupported_load_ref(cli, datafiles, ref_storage):
    basedir = os.path.join(datafiles.dirname, datafiles.basename)

    # Generate project with access to the noloadref plugin and project.refs enabled
    #
    config = {
        'name': 'test',
        'ref-storage': ref_storage,
        'plugins': [
            {
                'origin': 'local',
                'path': 'plugins',
                'sources': {
                    'noloadref': 0
                }
            }
        ]
    }
    _yaml.dump(config, os.path.join(basedir, 'project.conf'))

    result = cli.run(project=basedir, silent=True, args=['show', 'noloadref.bst'])

    # There is no error if project.refs is not in use, otherwise we
    # assert our graceful failure
    if ref_storage == 'inline':
        result.assert_success()
    else:
        result.assert_main_error(ErrorDomain.SOURCE, 'unsupported-load-ref')