Blob Blame History Raw
From 4ea99ff3056abf3dc3f4488609ab33b3de272386 Mon Sep 17 00:00:00 2001
From: Randy Barlow <randy@electronsweatshop.com>
Date: Wed, 26 Sep 2018 19:45:51 -0400
Subject: [PATCH 2/2] Adjust two unit tests to work with Click 6 and 7.

Click 6 uses lowercase letters in an error message in a spot that
Click 7 uses uppercase letters. This commit adjusts the tests based
on the detected Click version.

fixes #2621

Signed-off-by: Randy Barlow <randy@electronsweatshop.com>
---
 bodhi/tests/client/test___init__.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/bodhi/tests/client/test___init__.py b/bodhi/tests/client/test___init__.py
index 37cd98da..14c44b46 100644
--- a/bodhi/tests/client/test___init__.py
+++ b/bodhi/tests/client/test___init__.py
@@ -25,6 +25,7 @@ import unittest
 import copy
 
 from click import testing
+import click
 import fedora.client
 import mock
 import munch
@@ -1399,9 +1400,15 @@ class TestEdit(unittest.TestCase):
                           '--password', 's3kr3t', '--notes', 'this is an edited note',
                           '--url', 'http://localhost:6543'])
         self.assertEqual(result.exit_code, 2)
+        # Click 7.0 capitalizes UPDATE, and < 7 does not.
+        if [int(n) for n in click.__version__.split('.')] < [7, 0]:
+            label = 'update'
+        else:
+            label = 'UPDATE'
         expected = u'Usage: edit [OPTIONS] UPDATE\n\n' \
-                   u'Error: Invalid value for "update": ' \
+                   u'Error: Invalid value for "{}": ' \
                    u'Please provide an Update ID or an Update Title\n'
+        expected = expected.format(label)
 
         self.assertEqual(result.output, expected)
 
@@ -1417,9 +1424,15 @@ class TestEdit(unittest.TestCase):
                           '--password', 's3kr3t', '--notes', 'this is an edited note',
                           '--url', 'http://localhost:6543'])
         self.assertEqual(result.exit_code, 2)
+        # Click 7.0 capitalizes UPDATE, and < 7 does not.
+        if [int(n) for n in click.__version__.split('.')] < [7, 0]:
+            label = 'update'
+        else:
+            label = 'UPDATE'
         expected = u'Usage: edit [OPTIONS] UPDATE\n\n' \
-                   u'Error: Invalid value for "update": ' \
+                   u'Error: Invalid value for "{}": ' \
                    u'Please provide an Update ID or an Update Title\n'
+        expected = expected.format(label)
 
         self.assertEqual(result.output, expected)
 
-- 
2.19.1