aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-06-07 16:37:24 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-15 08:35:05 +0100
commitc28f918e5d0df775324da965f03b354a83e78920 (patch)
tree83a2a2a9ab949b0b8bf6b0a7c053448fd27c3ba5 /bitbake
parent1fd160016ddc8a3260545b73fc0b89ec42eb882f (diff)
downloadopenembedded-core-contrib-c28f918e5d0df775324da965f03b354a83e78920.tar.gz
bitbake: toaster: decode response content
Decoded response content to str to pass it to json.load as it breaks in Python 3 with this error: TypeError: expected bytes, bytearray or buffer compatible object [YOCTO #9584] (Bitbake rev: 3566ecc3ae682358d1fc58bdc0bed5cbed5e9608) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 9af101804f..722b383509 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -77,7 +77,7 @@ class ViewTests(TestCase):
self.assertEqual(response.status_code, 200)
self.assertTrue(response['Content-Type'].startswith('application/json'))
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertTrue("error" in data)
self.assertEqual(data["error"], "ok")
@@ -106,7 +106,7 @@ class ViewTests(TestCase):
self.assertEqual(response.status_code, 200)
self.assertTrue(response['Content-Type'].startswith('application/json'))
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertTrue("error" in data)
self.assertEqual(data["error"], "ok")
@@ -157,26 +157,26 @@ class ViewTests(TestCase):
'project_id': self.project.id,
'dir_path' : "/path/in/repository"}
response = self.client.post(reverse('xhr_importlayer'), args)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertEqual(response.status_code, 200)
self.assertEqual(data["error"], "ok")
#Test to verify import of a layer successful
args['name'] = "meta-oe"
response = self.client.post(reverse('xhr_importlayer'), args)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertTrue(data["error"], "ok")
#Test for html tag in the data
args['<'] = "testing html tag"
response = self.client.post(reverse('xhr_importlayer'), args)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertNotEqual(data["error"], "ok")
#Empty data passed
args = {}
response = self.client.post(reverse('xhr_importlayer'), args)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertNotEqual(data["error"], "ok")
def test_custom_ok(self):
@@ -186,7 +186,7 @@ class ViewTests(TestCase):
'base': self.recipe1.id}
response = self.client.post(url, params)
self.assertEqual(response.status_code, 200)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertEqual(data['error'], 'ok')
self.assertTrue('url' in data)
# get recipe from the database
@@ -202,7 +202,7 @@ class ViewTests(TestCase):
{'name': 'custom', 'project': self.project.id}]:
response = self.client.post(url, params)
self.assertEqual(response.status_code, 200)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertNotEqual(data["error"], "ok")
def test_xhr_custom_wrong_project(self):
@@ -211,7 +211,7 @@ class ViewTests(TestCase):
params = {'name': 'custom', 'project': 0, "base": self.recipe1.id}
response = self.client.post(url, params)
self.assertEqual(response.status_code, 200)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertNotEqual(data["error"], "ok")
def test_xhr_custom_wrong_base(self):
@@ -220,7 +220,7 @@ class ViewTests(TestCase):
params = {'name': 'custom', 'project': self.project.id, "base": 0}
response = self.client.post(url, params)
self.assertEqual(response.status_code, 200)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
self.assertNotEqual(data["error"], "ok")
def test_xhr_custom_details(self):
@@ -235,7 +235,7 @@ class ViewTests(TestCase):
'project_id': self.project.id,
}
}
- self.assertEqual(json.loads(response.content), expected)
+ self.assertEqual(json.loads(response.content.decode('utf-8')), expected)
def test_xhr_custom_del(self):
"""Test deleting custom recipe"""
@@ -248,12 +248,12 @@ class ViewTests(TestCase):
url = reverse('xhr_customrecipe_id', args=(recipe.id,))
response = self.client.delete(url)
self.assertEqual(response.status_code, 200)
- self.assertEqual(json.loads(response.content), {"error": "ok"})
+ self.assertEqual(json.loads(response.content.decode('utf-8')), {"error": "ok"})
# try to delete not-existent recipe
url = reverse('xhr_customrecipe_id', args=(recipe.id,))
response = self.client.delete(url)
self.assertEqual(response.status_code, 200)
- self.assertNotEqual(json.loads(response.content)["error"], "ok")
+ self.assertNotEqual(json.loads(response.content.decode('utf-8'))["error"], "ok")
def test_xhr_custom_packages(self):
"""Test adding and deleting package to a custom recipe"""
@@ -263,7 +263,7 @@ class ViewTests(TestCase):
self.cust_package.id)))
self.assertEqual(response.status_code, 200)
- self.assertEqual(json.loads(response.content),
+ self.assertEqual(json.loads(response.content.decode('utf-8')),
{"error": "ok"})
self.assertEqual(self.customr.appends_set.first().name,
self.cust_package.name)
@@ -274,7 +274,7 @@ class ViewTests(TestCase):
response = self.client.delete(del_url)
self.assertEqual(response.status_code, 200)
- self.assertEqual(json.loads(response.content), {"error": "ok"})
+ self.assertEqual(json.loads(response.content.decode('utf-8')), {"error": "ok"})
all_packages = self.customr.get_all_packages().values_list('pk',
flat=True)
@@ -286,7 +286,7 @@ class ViewTests(TestCase):
response = self.client.delete(del_url)
self.assertEqual(response.status_code, 200)
- self.assertNotEqual(json.loads(response.content)["error"], "ok")
+ self.assertNotEqual(json.loads(response.content.decode('utf-8'))["error"], "ok")
def test_xhr_custom_packages_err(self):
"""Test error conditions of xhr_customrecipe_packages"""
@@ -297,7 +297,7 @@ class ViewTests(TestCase):
for method in (self.client.put, self.client.delete):
response = method(url)
self.assertEqual(response.status_code, 200)
- self.assertNotEqual(json.loads(response.content),
+ self.assertNotEqual(json.loads(response.content.decode('utf-8')),
{"error": "ok"})
def test_download_custom_recipe(self):
@@ -316,7 +316,7 @@ class ViewTests(TestCase):
table = SoftwareRecipesTable()
request = RequestFactory().get('/foo/', {'format': 'json'})
response = table.get(request, pid=self.project.id)
- data = json.loads(response.content)
+ data = json.loads(response.content.decode('utf-8'))
recipes = Recipe.objects.filter(Q(is_image=False))
self.assertTrue(len(recipes) > 1,
@@ -372,7 +372,7 @@ class ViewTests(TestCase):
'target_id': 1}
response = table.get(request, **args)
- return json.loads(response.content)
+ return json.loads(response.content.decode('utf-8'))
def get_text_from_td(td):
"""If we have html in the td then extract the text portion"""