Skip to content

Commit

Permalink
fix test asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
matmair committed Dec 26, 2024
1 parent 034470c commit caf0421
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/backend/InvenTree/InvenTree/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,14 +1357,17 @@ def test_daily_holdoff(self):
# First call should run without issue
result = InvenTree.tasks.check_daily_holdoff('dummy_task')
self.assertTrue(result)
self.assertIn("Logging task attempt for 'dummy_task'", str(cm.output))
self.assertIn(
'Logging task attempt for dummy_task', str(cm.output).replace("\\'", '')
)

with self.assertLogs(logger='inventree', level='INFO') as cm:
# An attempt has been logged, but it is too recent
result = InvenTree.tasks.check_daily_holdoff('dummy_task')
self.assertFalse(result)
self.assertIn(
"Last attempt for 'dummy_task' was too recent", str(cm.output)
'Last attempt for dummy_task was too recent',
str(cm.output).replace("\\'", ''),
)

# Mark last attempt a few days ago - should now return True
Expand All @@ -1385,7 +1388,8 @@ def test_daily_holdoff(self):
result = InvenTree.tasks.check_daily_holdoff('dummy_task')
self.assertFalse(result)
self.assertIn(
"Last attempt for 'dummy_task' was too recent", str(cm.output)
'Last attempt for dummy_task was too recent',
str(cm.output).replace("\\'", ''),
)

# Configure so a task was successful too recently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_run_event(self):
# Enable event testing
settings.PLUGIN_TESTING_EVENTS = True
# Check that an event is issued
with self.assertLogs(logger=logger, level='DEBUG') as cm:
with self.assertLogs(logger=logger.name, level='DEBUG') as cm:
trigger_event('test.event')
self.assertIn(
'DEBUG:inventree:Event `test.event` triggered in sample plugin', cm[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_run_event(self):
# Enable event testing
settings.PLUGIN_TESTING_EVENTS = True
# Check that an event is issued
with self.assertLogs(logger=logger, level='DEBUG') as cm:
with self.assertLogs(logger=logger.name, level='DEBUG') as cm:
trigger_event('test.event')
self.assertIn(
'DEBUG:inventree:Event `test.event` triggered in sample plugin', cm[1]
Expand All @@ -46,7 +46,7 @@ def test_ignore_event(self):
# Enable event testing
settings.PLUGIN_TESTING_EVENTS = True
# Check that an event is issued
with self.assertLogs(logger=logger, level='DEBUG') as cm:
with self.assertLogs(logger=logger.name, level='DEBUG') as cm:
trigger_event('test.some.other.event')
self.assertNotIn(
'DEBUG:inventree:Event `test.some.other.event` triggered in sample plugin',
Expand Down

0 comments on commit caf0421

Please sign in to comment.