#476 fedpkg update --suggest-logout option added
Merged by onosek. Opened by drumian.
drumian/fedpkg suggest-logout_command  into  master

Download 476.patch

Option --suggest-logout was not implemented although it
is supported by Bodhi. This commit adds this option.

Jira: RHELCMP-8704
Fixes: https://pagure.io/fedpkg/issue/472

Signed-off-by: Dominik Rumian drumian@redhat.com

Fix the comment. Maybe show possible values in it.

Fix the comment. Maybe show possible values in it.

Of course. I will do it.

You could use this code for basic unit-testing.

diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py
index a52c70d..c69f757 100644
--- a/fedpkg/__init__.py
+++ b/fedpkg/__init__.py
@@ -62,6 +62,7 @@ if _BodhiClient is not None:
         UPDATE_TYPES = ['bugfix', 'security', 'enhancement', 'newpackage']
         REQUEST_TYPES = ['testing', 'stable']
+        SUGGEST_TYPES = ['unspecified', 'reboot', 'logout']
         @clear_csrf_and_retry
         def save(self, *args, **kwargs):
@@ -359,7 +360,9 @@ class Commands(pyrpkg.Commands):
             if detail['request'] not in BodhiClient.REQUEST_TYPES:
                 raise ValueError(
                     'Incorrect request type {0}'.format(detail['request']))
-
+            if detail['suggest'] not in BodhiClient.SUGGEST_TYPES:
+                raise ValueError(
+                    'Incorrect suggest type {0}'.format(detail['suggest']))
             try:
                 self.log.info(bodhi.update_str(bodhi.save(**detail), minimal=False))
             # Only because tests do not return a valid bodhi.save value
diff --git a/test/test_cli.py b/test/test_cli.py
index 957cefe..63e0876 100644
--- a/test/test_cli.py
+++ b/test/test_cli.py
@@ -169,7 +169,8 @@ class TestUpdate(CliTestCase):
     @patch('fedora.client.OpenIdBaseClient._load_cookies')
     def assert_bodhi_update(self, cli, _load_cookies, send_request, csrf,
                             update_type=None, request_type=None, notes=None,
-                            stable_karma=None, unstable_karma=None):
+                            stable_karma=None, unstable_karma=None,
+                            suggest=None):
         csrf.return_value = '123456'
         def run_command_side_effect(command, shell):
@@ -189,6 +190,10 @@ class TestUpdate(CliTestCase):
                     content = re.sub('request=[a-z]+\n',
                                      'request={0}\n'.format(request_type),
                                      content)
+                if suggest:
+                    content = re.sub('suggest=[a-z]+\n',
+                                     'suggest={0}\n'.format(suggest),
+                                     content)
                 f.write(content)
         self.mock_run_command.side_effect = run_command_side_effect
@@ -327,6 +332,14 @@ class TestUpdate(CliTestCase):
                               update_type='enhancement',
                               request_type='xxx')
+    def test_incorrect_suggest_in_template(self):
+        cli_cmd = ['fedpkg-stage', '--path', self.cloned_repo_path, 'update']
+        cli = self.get_cli(cli_cmd)
+        six.assertRaisesRegex(self, rpkgError, 'Incorrect suggest',
+                              self.assert_bodhi_update, cli,
+                              suggest='xxx',
+                              update_type='enhancement')
+
     def test_create_with_cli_options(self):
         cli_cmd = [
             'fedpkg-stage', '--path', self.cloned_repo_path,

You could use this code for basic unit-testing.

~~~~~
diff --git a/fedpkg/init.py b/fedpkg/init.py

thank you, I will try it

rebased onto 07e7c53b1471bfc2e45c82d5975433848d7f1e83

Looks like it's working.

Pull-Request has been merged by onosek

Metadata