def test_load_repo_descriptor_unparseable(mocker): mocker.patch( 'connect.cli.plugins.report.helpers.json.load', side_effect=json.JSONDecodeError('test', 'json_doc', 1), ) with pytest.raises(ClickException) as cv: load_repo('./tests/fixtures/reports/basic_report') assert str(cv.value) == 'The reports project descriptor `reports.json` is not a valid json file.'
def test_load_repo_invalid_repo(mocker): mocker.patch( 'connect.cli.plugins.report.helpers.validate', return_value=['these are errors'], ) with pytest.raises(ClickException) as cv: load_repo('./tests/fixtures/reports/basic_report') assert str(cv.value) == 'Invalid `reports.json`: these are errors'
def test_load_repo_no_descriptor(): with pytest.raises(ClickException) as cv: load_repo('/tmp') assert str(cv.value) == 'The directory `/tmp` is not a reports project root directory.'
def test_load_repo_ok(): repo = load_repo('./tests/fixtures/reports/basic_report') assert repo is not None