Skip to content

Commit

Permalink
Add: Add a get_commands function to return all VersionCommand classes
Browse files Browse the repository at this point in the history
Better abstract the available VersionCommand classes by providing a
function to get access to them.
  • Loading branch information
bjoernricks committed Mar 2, 2023
1 parent 7658b22 commit 74efacd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pontos/version/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from typing import Tuple, Type
from typing import Iterable, Tuple, Type

from pontos.version.errors import ProjectError

Expand Down Expand Up @@ -47,3 +47,7 @@ def gather_project() -> VersionCommand:
return command

raise ProjectError("No project settings file found")


def get_commands() -> Iterable[Type[VersionCommand]]:
return _COMMANDS
7 changes: 6 additions & 1 deletion tests/version/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pontos.testing import temp_directory, temp_python_module
from pontos.version.cmake import CMakeVersionCommand
from pontos.version.commands import gather_project
from pontos.version.commands import gather_project, get_commands
from pontos.version.errors import ProjectError
from pontos.version.go import GoVersionCommand
from pontos.version.javascript import JavaScriptVersionCommand
Expand Down Expand Up @@ -71,3 +71,8 @@ def test_cmake_project_version(self):
version_file.write_text("project(VERSION 1.2.3)", encoding="utf8")

self.assertIsInstance(gather_project(), CMakeVersionCommand)


class GetCommandsTestCase(unittest.TestCase):
def test_available_commands(self):
self.assertEqual(len(get_commands()), 4)

0 comments on commit 74efacd

Please sign in to comment.