mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-02 21:18:12 +08:00
Model.__unicode__() has no effect
This commit is contained in:
+2
-2
@@ -97,7 +97,7 @@ class Task(models.Model):
|
|||||||
def short_result(self):
|
def short_result(self):
|
||||||
return truncatechars(self.result, 100)
|
return truncatechars(self.result, 100)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return f"{self.name or self.id}"
|
return f"{self.name or self.id}"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -215,7 +215,7 @@ class Schedule(models.Model):
|
|||||||
return format_html(f'<a href="{url}">[{task.name}]</a>')
|
return format_html(f'<a href="{url}">[{task.name}]</a>')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.func
|
return self.func
|
||||||
|
|
||||||
success.boolean = True
|
success.boolean = True
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ def test_enqueue(broker, admin_user):
|
|||||||
k = async_task('django_q.tests.tasks.get_user_id', admin_user,
|
k = async_task('django_q.tests.tasks.get_user_id', admin_user,
|
||||||
q_options={'broker': broker, 'group': 'test_k', 'save': False, 'timeout': 90})
|
q_options={'broker': broker, 'group': 'test_k', 'save': False, 'timeout': 90})
|
||||||
# test unicode
|
# test unicode
|
||||||
assert Task(name='Amalia').__unicode__()=='Amalia'
|
assert Task(name='Amalia').__str__()=='Amalia'
|
||||||
# check if everything has a task id
|
# check if everything has a task id
|
||||||
assert isinstance(a, str)
|
assert isinstance(a, str)
|
||||||
assert isinstance(b, str)
|
assert isinstance(b, str)
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ def test_scheduler(broker, monkeypatch):
|
|||||||
cron="0 22 * * 1-5")
|
cron="0 22 * * 1-5")
|
||||||
assert hasattr(cron_schedule, 'pk') is True
|
assert hasattr(cron_schedule, 'pk') is True
|
||||||
assert cron_schedule.full_clean() is None
|
assert cron_schedule.full_clean() is None
|
||||||
assert cron_schedule.__unicode__() == 'django_q.tests.tasks.word_multiply'
|
assert cron_schedule.__str__() == 'django_q.tests.tasks.word_multiply'
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(ValidationError):
|
||||||
create_schedule('django_q.tests.tasks.word_multiply',
|
create_schedule('django_q.tests.tasks.word_multiply',
|
||||||
2,
|
2,
|
||||||
|
|||||||
Reference in New Issue
Block a user