def test_run_analytics_sets_last_analysis(self, mock_now):
        """Tests that the analytics will set the last_analysis field."""
        mock_now.return_value = datetime.datetime(1970, 1, 1)

        class FakeTask(AnalyticsTask):
            _defaults = {
                "frequency": datetime.timedelta(hours=1),
                "type": "analytics",
                "description": "Dummy analytics",
                "enabled": True,
            }

            acts_on: list[str] = ["ipv4"]

            def each(self, observable):
                pass

        taskmanager.TaskManager.register_task(FakeTask)
        time.sleep(0.5)
        taskmanager.TaskManager.run_task("FakeTask", TaskParams())
        db_observable = Observable.get(self.observable4.id)
        assert db_observable is not None
        self.assertEqual(
            db_observable.last_analysis, {"FakeTask": datetime.datetime(1970, 1, 1)}
        )
Tests that the analytics will set the last_analysis field.
tests/core_tests/tasks.py