Skip to content

Commit d807ee8

Browse files
committed
Fix add_message bug
1 parent 137edab commit d807ee8

5 files changed

Lines changed: 42 additions & 22 deletions

File tree

.travis.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,30 @@ language: python
44

55
matrix:
66
include:
7-
- python: "2.7"
8-
env: "DJANGO_VERSION=1.11"
9-
- python: "3.5"
10-
env: "DJANGO_VERSION=1.11"
11-
- python: "3.5"
12-
env: "DJANGO_VERSION=2.0"
13-
- python: "3.5"
14-
env: "DJANGO_VERSION=2.1"
157
- python: "3.6"
16-
env: "DJANGO_VERSION=1.11"
8+
env: "DJANGO_VERSION=2.2"
179
- python: "3.6"
18-
env: "DJANGO_VERSION=2.0"
10+
env: "DJANGO_VERSION=3.1"
1911
- python: "3.6"
20-
env: "DJANGO_VERSION=2.1"
12+
env: "DJANGO_VERSION=3.2"
2113
- python: "3.7"
22-
env: "DJANGO_VERSION=2.0"
14+
env: "DJANGO_VERSION=2.2"
2315
- python: "3.7"
24-
env: "DJANGO_VERSION=2.1"
16+
env: "DJANGO_VERSION=3.1"
17+
- python: "3.7"
18+
env: "DJANGO_VERSION=3.2"
19+
- python: "3.8"
20+
env: "DJANGO_VERSION=2.2"
21+
- python: "3.8"
22+
env: "DJANGO_VERSION=3.1"
23+
- python: "3.8"
24+
env: "DJANGO_VERSION=3.2"
25+
- python: "3.9"
26+
env: "DJANGO_VERSION=2.2"
27+
- python: "3.9"
28+
env: "DJANGO_VERSION=3.1"
29+
- python: "3.9"
30+
env: "DJANGO_VERSION=3.2"
2531

2632

2733
install:

docs/source/start.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Install the Python library with pip::
88

99
$ pip install django-task-api
1010

11-
Django Task API is compatible and tested with Python versions 2.7, 3.5, 3.6, and 3.7, and with Django versions 1.11,
12-
2.0, and 2.1.
11+
Django Task API is compatible and tested with Python versions 3.6 through 3.9, and with Django versions 2.2, 3.1, and
12+
3.2.
1313

1414
Set up Celery
1515
-------------

setup.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def run(self):
7474
package_data={'task_api': ['static/*.js']},
7575
install_requires=install_requires,
7676
tests_require=['pytest-django', 'mock'],
77-
python_requires='>=2.7, >=3.4',
77+
python_requires='>=3.6',
7878
url='https://github.com/nikmolnar/django-task-api',
7979
license='MIT',
8080
cmdclass={
@@ -84,12 +84,10 @@ def run(self):
8484
'develop': DevelopCommand
8585
},
8686
classifiers=[
87-
'Programming Language :: Python',
88-
'Programming Language :: Python :: 2',
89-
'Programming Language :: Python :: 2.7',
9087
'Programming Language :: Python :: 3',
91-
'Programming Language :: Python :: 3.5',
9288
'Programming Language :: Python :: 3.6',
93-
'Programming Language :: Python :: 3.7'
89+
'Programming Language :: Python :: 3.7',
90+
'Programming Language :: Python :: 3.8',
91+
'Programming Language :: Python :: 3.9',
9492
]
9593
)

task_api/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def add_message(self, message):
6767

6868
messages = json.loads(self.info.messages)
6969
messages.append(message)
70-
self.info.message = json.dumps(messages)
70+
self.info.messages = json.dumps(messages)
7171
self.info.save()
7272

7373
def set_target(self, target):

tests/test_tasks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def run(self, str=None, num=None):
2222
print('Success!')
2323

2424

25+
class MessageTask(Task):
26+
def run(self):
27+
self.add_message('Test')
28+
29+
2530
def test_copy_inputs_outputs():
2631
task = Task()
2732
assert task.inputs is not Task.inputs
@@ -73,3 +78,14 @@ def test_task_execute_exception(run_mock):
7378
SomeTask().execute(info)
7479
run_mock.assert_called_with(num=5)
7580
assert TaskInfo.objects.get(pk=info.pk).status == 'failed'
81+
82+
83+
@pytest.mark.django_db(transaction=True)
84+
def test_task_message():
85+
info = TaskInfo.objects.create(
86+
task='tests.test_task.MessageTask',
87+
inputs=json.dumps({}),
88+
created=now()
89+
)
90+
MessageTask().execute(info)
91+
assert TaskInfo.objects.filter(pk=info.pk, messages='["Test"]').exists()

0 commit comments

Comments
 (0)