Skip to content

Commit

Permalink
Improve tests about parameters (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry authored Jan 22, 2024
1 parent 58bddb2 commit a66e65c
Showing 1 changed file with 24 additions and 2 deletions.
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)

0 comments on commit a66e65c

Please sign in to comment.