Skip to content

Commit

Permalink
Fixing assertions on Python 3.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdlaird committed Oct 25, 2020
1 parent 916ddc2 commit 2071d5b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
11 changes: 11 additions & 0 deletions hookee/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import os
import sys
import xml.dom.minidom

import click
Expand Down Expand Up @@ -153,6 +154,16 @@ def print_basic(self, msg="", color=None, bold=False, print_when_logging=False):
print(msg)


def python36_gte():
"""
Check if running on a Python 3.6 or higher interpreter.
:return: ``True`` if Python 3.6 or higher.
:rtype: bool
"""
return sys.version_info >= (3, 6)


def get_functions(mod):
"""
Get a list of functions for the given module.
Expand Down
22 changes: 19 additions & 3 deletions tests/test_hookee_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests

from hookee import util
from tests.managedtestcase import ManagedTestCase

__author__ = "Alex Laird"
Expand All @@ -17,9 +18,16 @@ def test_http_get_query_params(self):
response = requests.get(self.webhook_url, params=params)

self.assertEqual(response.status_code, 200)
self.assertIn("""Query Params: {
if util.python36_gte():
self.assertIn("""Query Params: {
"param_1": "param_value_1"
}""", out.getvalue())
else:
self.assertIn("""Query Params: {
"param_1": [
"param_value_1"
]
}""", out.getvalue())

def test_http_post_form_data(self):
# GIVEN
Expand All @@ -32,10 +40,18 @@ def test_http_post_form_data(self):
self.assertEqual(response.status_code, 200)
self.assertIn("\"Content-Type\": \"application/x-www-form-urlencoded\"", out.getvalue())
self.assertEqual(response.headers.get("Content-Type"), "application/json")
self.assertIn("""Body: {
if util.python36_gte():
self.assertIn("""Body: {
"form_data_1": "form_data_value_1"
}""", out.getvalue())
self.assertEqual(response.json(), data)
self.assertEqual(response.json(), data)
else:
self.assertIn("""Body: {
"form_data_1": [
"form_data_value_1"
]
}""", out.getvalue())
self.assertEqual(response.json(), {"form_data_1": ["form_data_value_1"]})

def test_http_post_json_data(self):
# GIVEN
Expand Down

0 comments on commit 2071d5b

Please sign in to comment.