Skip to content

Commit

Permalink
feat: use json
Browse files Browse the repository at this point in the history
  • Loading branch information
Srynetix committed Apr 11, 2024
1 parent 99bf386 commit 0d5ed6e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion djcelery/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import, unicode_literals

from anyjson import loads
from json import loads

from django import forms
from django.conf import settings
Expand Down
2 changes: 1 addition & 1 deletion djcelery/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from multiprocessing.util import Finalize

from anyjson import loads, dumps
from json import loads, dumps
from celery import current_app
from celery import schedules
from celery.beat import Scheduler, ScheduleEntry
Expand Down
10 changes: 5 additions & 5 deletions djcelery/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.test.testcases import TestCase as DjangoTestCase
from django.template import TemplateDoesNotExist

from anyjson import deserialize
from json import loads

from celery import current_app
from celery import states
Expand Down Expand Up @@ -72,7 +72,7 @@ class ViewTestCase(DjangoTestCase):
def assertJSONEqual(self, json, py):
json = isinstance(json, HttpResponse) and json.content or json
try:
self.assertEqual(deserialize(json.decode('utf-8')), py)
self.assertEqual(loads(json.decode('utf-8')), py)
except TypeError as exc:
raise TypeError('{0}: {1}'.format(exc, json))

Expand Down Expand Up @@ -122,7 +122,7 @@ class test_registered_tasks(ViewTestCase):

def test_list_registered_tasks(self):
json = self.client.get(registered_tasks())
tasks = deserialize(json.content.decode('utf-8'))
tasks = loads(json.content.decode('utf-8'))
self.assertIn('celery.backend_cleanup', tasks['regular'])


Expand All @@ -140,7 +140,7 @@ def add_webhook(request):
response = add_webhook(request)
self.assertDictContainsSubset(
{'status': 'success', 'retval': 20},
deserialize(response.content.decode('utf-8')))
loads(response.content.decode('utf-8')))

def test_failed_request(self):

Expand All @@ -155,7 +155,7 @@ def error_webhook(request):
self.assertDictContainsSubset(
{'status': 'failure',
'reason': '<MyError: (20,)>'},
deserialize(response.content.decode('utf-8')))
loads(response.content.decode('utf-8')))


class test_task_status(ViewTestCase):
Expand Down
4 changes: 2 additions & 2 deletions djcelery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.http import HttpResponse, Http404

from anyjson import serialize
from json import dumps

from celery import states
from celery.five import keys, items
Expand All @@ -18,7 +18,7 @@


def JsonResponse(response):
return HttpResponse(serialize(response), content_type='application/json')
return HttpResponse(dumps(response), content_type='application/json')


def task_view(task):
Expand Down

0 comments on commit 0d5ed6e

Please sign in to comment.