Fix another py3 test failure.
@@ -23,6 +23,8 @@ import requests
import argparse
import logging
+import six
+
from tests import base
from st2client import shell
from st2client.models.core import add_auth_token_to_kwargs_from_env
@@ -32,6 +34,14 @@ from st2client.utils.httpclient import add_auth_token_to_headers, add_json_conte
LOG = logging.getLogger(__name__)
+if six.PY3:
+ RULE = {
+ 'name': 'drule',
+ 'description': 'i am THE rule.',
+ 'pack': 'cli',
+ 'id': uuid.uuid4().hex
+ }
+else:
RULE = {
'id': uuid.uuid4().hex,
'description': 'i am THE rule.',
@@ -49,8 +59,6 @@ class TestLoginBase(base.BaseCLITestCase):
on duplicate code in each test class
"""
- capture_output = True
-
DOTST2_PATH = os.path.expanduser('~/.st2/')
CONFIG_FILE = tempfile.mkstemp(suffix='st2.conf')
CONFIG_CONTENTS = """
@@ -269,6 +277,8 @@ class TestLoginUncaughtException(TestLoginBase):
class TestAuthToken(base.BaseCLITestCase):
+ capture_output = False
+
def __init__(self, *args, **kwargs):
super(TestAuthToken, self).__init__(*args, **kwargs)
self.parser = argparse.ArgumentParser()
@@ -466,6 +476,7 @@ class TestAuthToken(base.BaseCLITestCase):
kwargs = {'headers': {'X-Auth-Token': token}}
requests.get.assert_called_with(get_url, **kwargs)
kwargs = {'headers': {'content-type': 'application/json', 'X-Auth-Token': token}}
+
requests.put.assert_called_with(put_url, json.dumps(RULE), **kwargs)
# Test with token from env.
@@ -474,6 +485,9 @@ class TestAuthToken(base.BaseCLITestCase):
self.shell.run(['rule', 'update', rule_ref, path])
kwargs = {'headers': {'X-Auth-Token': token}}
requests.get.assert_called_with(get_url, **kwargs)
+
+ # Note: We parse the payload because data might not be in the same
+ # order as the fixture
kwargs = {'headers': {'content-type': 'application/json', 'X-Auth-Token': token}}
requests.put.assert_called_with(put_url, json.dumps(RULE), **kwargs)
finally:
