Exemple #1
0
    def test_action_format_message(self):
        # All new logs should pass our validation, but older logs or logs that were added in bulk
        # may be invalid.
        # Using LogEntry.objects.update, we can bypass the on save validation.
        log_entry = PageLogEntry.objects.log_action(self.root_page, action='wagtail.create')
        PageLogEntry.objects.update(action='test.custom_action')
        log_entry.refresh_from_db()

        log_actions = LogActionRegistry()
        self.assertEqual(log_entry.message, "Unknown test.custom_action")
        self.assertFalse(log_actions.action_exists('test.custom_action'))

        with self.register_hook('register_log_actions', test_hook):
            log_actions = LogActionRegistry()
            self.assertTrue(log_actions.action_exists('test.custom_action'))
            self.assertEqual(log_actions.get_formatter(log_entry).format_message(log_entry), "Tested!")
            self.assertEqual(log_actions.get_action_label('test.custom_action'), 'Custom action')
Exemple #2
0
 def test_register_log_actions_hook(self):
     log_actions = LogActionRegistry()
     self.assertTrue(log_actions.action_exists('wagtail.create'))