Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests about parameters #280

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions test/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,37 @@

# standard
import unittest
from pathlib import Path

# Project
from qgispluginci.exceptions import ConfigurationNotFound
from qgispluginci.parameters import Parameters


class TestParameters(unittest.TestCase):
def test_changelog_parameters(self):
"""Test parameters for changelog command."""
# For the changelog command, the configuration file is optional.
parameters = Parameters.make_from(args={}, optional_configuration=True)
self.assertEqual("CHANGELOG.md", parameters.changelog_path)
# It mustn't raise an exception
parameters = Parameters.make_from(
args={},
path_to_config_file=Path("does-not-exist.yml"),
optional_configuration=True,
)
self.assertIsNone(parameters.plugin_path)
self.assertEqual("CHANGELOG.md", parameters.changelog_path)

def test_global_parameters(self):
"""Test global parameters."""
# A configuration file must exist.
with self.assertRaises(ConfigurationNotFound):
Parameters.make_from(
args={}, path_to_config_file=Path("does-not-exist.yml")
)

# Existing configuration file
parameters = Parameters.make_from(
args={}, path_to_config_file=Path("test/fixtures/pyproject.toml")
)
self.assertEqual("qgis_plugin_CI_testing", parameters.plugin_path)
self.assertEqual("CHANGELOG.md", parameters.changelog_path)