forked from Katello/katello
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Katello#69 from parthaa/version-feature
808172 - Added code to show version information for katello cli
- Loading branch information
Showing
9 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright © 2011 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
# along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
# | ||
# Red Hat trademarks are not licensed under GPLv2. No permission is | ||
# granted to use or replicate Red Hat trademarks that are incorporated | ||
# in this software or its documentation. | ||
|
||
from katello.client.api.base import KatelloAPI | ||
|
||
class VersionAPI(KatelloAPI): | ||
""" | ||
Connection class to access version information | ||
""" | ||
def version(self): | ||
path = "/api/version" | ||
return self.server.GET(path)[1] | ||
|
||
def version_formatted(self): | ||
v = self.version() | ||
return v['name'] + ' ' + v['version'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Katello Organization actions | ||
# Copyright (c) 2010 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
# along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
# | ||
# Red Hat trademarks are not licensed under GPLv2. No permission is | ||
# granted to use or replicate Red Hat trademarks that are incorporated | ||
# in this software or its documentation. | ||
# | ||
|
||
from gettext import gettext as _ | ||
|
||
from katello.client.api.version import VersionAPI | ||
from katello.client.config import Config | ||
from katello.client.core.base import Action, Command | ||
|
||
Config() | ||
|
||
# base ping action -------------------------------------------------------- | ||
|
||
class VersionAction(Action): | ||
|
||
def __init__(self): | ||
super(VersionAction, self).__init__() | ||
self.api = VersionAPI() | ||
|
||
|
||
|
||
# version actions ------------------------------------------------------------ | ||
|
||
class Info(VersionAction): | ||
|
||
description = _('get the version of the katello server') | ||
|
||
def setup_parser(self): | ||
return 0 | ||
|
||
def check_options(self): | ||
return 0 | ||
|
||
def run(self): | ||
return self.api.version_formatted() | ||
|
||
|
||
# ping command ------------------------------------------------------------ | ||
|
||
class Version(Command): | ||
description = _('Check the version of the server') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -752,6 +752,7 @@ | |
"key": "ACME_Corporation" | ||
} | ||
} | ||
VERSION_INFO = "Foo 10000" | ||
|
||
PING_STATUS = { | ||
'result': 'failed', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import unittest | ||
import os | ||
from mock import Mock | ||
|
||
from cli_test_utils import CLIOptionTestCase, CLIActionTestCase | ||
import test_data | ||
|
||
import katello.client.core.version | ||
from katello.client.core.version import Info | ||
|
||
|
||
|
||
class VersionTest(CLIActionTestCase): | ||
|
||
def setUp(self): | ||
self.set_action(Info()) | ||
self.set_module(katello.client.core.version) | ||
self.mock(self.action.api, 'version_formatted', test_data.VERSION_INFO) | ||
|
||
def test_calls_the_api(self): | ||
self.action.run() | ||
self.action.api.version_formatted.assert_called_once() | ||
|
||
def test_call_returns_correct_value(self): | ||
self.assertEqual(self.action.run(),test_data.VERSION_INFO ) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters