Decode content from django test client.

This commit is contained in:
Feanil Patel
2019-10-03 11:26:29 -04:00
parent 66382961a7
commit ef27928e67
4 changed files with 6 additions and 6 deletions

View File

@@ -295,8 +295,8 @@ class CertificatesListHandlerTestCase(
# in html response
result = self.client.get_html(self._url())
self.assertIn('Test certificate', result.content)
self.assertIn('Test description', result.content)
self.assertContains(result, 'Test certificate')
self.assertContains(result, 'Test description')
# in JSON response
response = self.client.get_json(self._url())
@@ -320,7 +320,7 @@ class CertificatesListHandlerTestCase(
# in html response
result = self.client.get_html(self._url())
self.assertNotIn('Test certificate', result.content)
self.assertNotContains(result, 'Test certificate')
def test_unsupported_http_accept_header(self):
"""

View File

@@ -62,7 +62,7 @@ class CourseUpdateTest(CourseTestCase):
# refetch using provided id
refetched = self.client.get_json(first_update_url)
self.assertHTMLEqual(
content, json.loads(refetched.content)['content'], "get w/ provided id"
content, json.loads(refetched.content.decode('utf-8'))['content'], "get w/ provided id"
)
# now put in an evil update

View File

@@ -137,7 +137,7 @@ class TestSubsectionGating(CourseTestCase):
{'namespace': '{}{}'.format(six.text_type(self.seq1.location), GATING_NAMESPACE_QUALIFIER)},
{'namespace': '{}{}'.format(six.text_type(self.seq2.location), GATING_NAMESPACE_QUALIFIER)}
]
resp = json.loads(self.client.get_json(self.seq2_url).content)
resp = json.loads(self.client.get_json(self.seq2_url).content.decode('utf-8'))
mock_is_prereq.assert_called_with(self.course.id, self.seq2.location)
mock_get_required_content.assert_called_with(self.course.id, self.seq2.location)
mock_get_prereqs.assert_called_with(self.course.id)

View File

@@ -211,7 +211,7 @@ class ImportTestCase(CourseTestCase):
Check that the response for a tar.gz import with a course.xml is
correct.
"""
with open(self.good_tar) as gtar:
with open(self.good_tar, 'rb') as gtar:
args = {"name": self.good_tar, "course-data": [gtar]}
resp = self.client.post(self.url, args)