Skip to content

Commit dc0ca58

Browse files
committed
fix tests
1 parent 89fde45 commit dc0ca58

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

tests/test_celery.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ def add_with_task_args(self, a, b):
139139
create.assert_called_once_with(
140140
"new_name",
141141
value_max=10,
142-
data={"foo": "bar", "celery_task_args": (2, 2), "celery_task_kwargs": {}},
142+
data={"foo": "bar", "celery_task_args": [2, 2], "celery_task_kwargs": {}},
143143
status=StatusEnum.PENDING,
144144
)
145145

146146

147147
def test_celery_record_task_kwargs(celery_session_app, celery_session_worker, bind_settings):
148148
@celery_session_app.task(bind=True, base=Task)
149-
def add_with_task_args(self, a, b, c=0):
149+
def add_with_task_kwargs(self, a, b, c=0):
150150
assert self.taskbadger_task is not None
151151
return a + b + c
152152

@@ -160,7 +160,7 @@ def add_with_task_args(self, a, b, c=0):
160160
create.return_value = task_for_test()
161161

162162
actions = [Action("stale", integration=EmailIntegration(to="test@test.com"))]
163-
result = add_with_task_args.delay(
163+
result = add_with_task_kwargs.delay(
164164
2,
165165
2,
166166
c=3,
@@ -174,7 +174,7 @@ def add_with_task_args(self, a, b, c=0):
174174
create.assert_called_once_with(
175175
"new_name",
176176
value_max=10,
177-
data={"celery_task_args": (2, 2), "celery_task_kwargs": {"c": 3}},
177+
data={"celery_task_args": [2, 2], "celery_task_kwargs": {"c": 3}},
178178
actions=actions,
179179
status=StatusEnum.PENDING,
180180
)
@@ -189,7 +189,7 @@ def __init__(self, a, b):
189189
register_type(A, "A", lambda o: [o.a, o.b], lambda o: A(*o))
190190

191191
@celery_session_app.task(bind=True, base=Task)
192-
def add_with_task_args(self, a):
192+
def add_task_custom_serialization(self, a):
193193
assert self.taskbadger_task is not None
194194
return a.a + a.b
195195

@@ -202,14 +202,14 @@ def add_with_task_args(self, a):
202202
):
203203
create.return_value = task_for_test()
204204

205-
result = add_with_task_args.delay(
205+
result = add_task_custom_serialization.delay(
206206
A(2, 2),
207207
taskbadger_record_task_args=True,
208208
)
209209
assert result.get(timeout=10, propagate=True) == 4
210210

211211
create.assert_called_once_with(
212-
"tests.test_celery.add_with_task_args",
212+
"tests.test_celery.add_task_custom_serialization",
213213
data={"celery_task_args": [{"__type__": "A", "__value__": [2, 2]}], "celery_task_kwargs": {}},
214214
status=StatusEnum.PENDING,
215215
)

tests/test_celery_system_integration.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_celery_record_task_args_local_override(celery_session_app, celery_sessi
115115
"""Test that passing `taskbadger_record_task_args` overrides the integration value"""
116116

117117
@celery_session_app.task(bind=True, base=Task)
118-
def add_normal(self, a, b):
118+
def add_normal_with_override(self, a, b):
119119
assert self.request.get("taskbadger_task_id") is not None, "missing task in request"
120120
assert hasattr(self, "taskbadger_task")
121121
assert Badger.current.session().client is not None, "missing client"
@@ -133,11 +133,13 @@ def add_normal(self, a, b):
133133
):
134134
tb_task = task_for_test()
135135
create.return_value = tb_task
136-
result = add_normal.delay(2, 2, taskbadger_record_task_args=False)
136+
result = add_normal_with_override.delay(2, 2, taskbadger_record_task_args=False)
137137
assert result.info.get("taskbadger_task_id") == tb_task.id
138138
assert result.get(timeout=10, propagate=True) == 4
139139

140-
create.assert_called_once_with("tests.test_celery_system_integration.add_normal", status=StatusEnum.PENDING)
140+
create.assert_called_once_with(
141+
"tests.test_celery_system_integration.add_normal_with_override", status=StatusEnum.PENDING
142+
)
141143
assert get_task.call_count == 1
142144
assert update.call_count == 2
143145
assert Badger.current.session().client is None

0 commit comments

Comments
 (0)