Skip to content

Commit 1fd90d1

Browse files
fix tests
1 parent 0796810 commit 1fd90d1

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

dojo/product/signals.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from dojo.models import Product
1414
from dojo.notifications.helper import create_notification
1515
from dojo.pghistory_models import DojoEvents
16+
from dojo.utils import get_current_user
1617

1718
labels = get_labels()
1819

@@ -61,9 +62,14 @@ def product_post_delete(sender, instance, **kwargs):
6162
).order_by("-id").first():
6263
user = le.actor
6364

65+
if not user:
66+
current_user = get_current_user()
67+
user = current_user
68+
6469
# Update description with user if found
6570
if user:
66-
description = labels.ASSET_DELETE_WITH_NAME_WITH_USER_SUCCESS_MESSAGE % {"name": instance.name, "user": le.actor}
71+
description = labels.ASSET_DELETE_WITH_NAME_WITH_USER_SUCCESS_MESSAGE % {"name": instance.name, "user": user}
72+
6773
create_notification(event="product_deleted", # template does not exists, it will default to "other" but this event name needs to stay because of unit testing
6874
title=_("Deletion of %(name)s") % {"name": instance.name},
6975
description=description,

dojo/product_type/signals.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def product_type_post_delete(sender, instance, **kwargs):
7070

7171
# Update description with user if found
7272
if user:
73-
description = labels.ORG_DELETE_WITH_NAME_SUCCESS_MESSAGE % {"name": instance.name}
73+
description = labels.ORG_DELETE_WITH_NAME_WITH_USER_SUCCESS_MESSAGE % {"name": instance.name, "user": user}
74+
7475
create_notification(event="product_type_deleted", # template does not exists, it will default to "other" but this event name needs to stay because of unit testing
7576
title=_("Deletion of %(name)s") % {"name": instance.name},
7677
description=description,

unittests/test_importers_performance.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ def test_import_reimport_reimport_performance_pghistory_async(self):
198198
configure_pghistory_triggers()
199199

200200
self.import_reimport_performance(
201-
expected_num_queries1=646,
201+
expected_num_queries1=559,
202202
expected_num_async_tasks1=10,
203-
expected_num_queries2=599,
203+
expected_num_queries2=491,
204204
expected_num_async_tasks2=22,
205205
expected_num_queries3=284,
206206
expected_num_async_tasks3=20,
@@ -244,9 +244,9 @@ def test_import_reimport_reimport_performance_pghistory_no_async(self):
244244
testuser.usercontactinfo.save()
245245

246246
self.import_reimport_performance(
247-
expected_num_queries1=646,
247+
expected_num_queries1=559,
248248
expected_num_async_tasks1=10,
249-
expected_num_queries2=604,
249+
expected_num_queries2=496,
250250
expected_num_async_tasks2=22,
251251
expected_num_queries3=289,
252252
expected_num_async_tasks3=20,
@@ -293,9 +293,9 @@ def test_import_reimport_reimport_performance_pghistory_no_async_with_product_gr
293293
self.system_settings(enable_product_grade=True)
294294

295295
self.import_reimport_performance(
296-
expected_num_queries1=647,
296+
expected_num_queries1=560,
297297
expected_num_async_tasks1=11,
298-
expected_num_queries2=605,
298+
expected_num_queries2=497,
299299
expected_num_async_tasks2=23,
300300
expected_num_queries3=290,
301301
expected_num_async_tasks3=21,

0 commit comments

Comments
 (0)