def test_start_stop_collection(self, _periodic_cls):
        mock_thread = MagicMock()
        _periodic_cls.return_value = mock_thread
        collector = StatsCollector(self._mock_db)

        collector.start_collection()

        assert_that(mock_thread.daemon, is_(True))
        mock_thread.start.assert_called_once_with()
        _periodic_cls.assert_called_once_with(
            collector.collect, StatsCollector.DEFAULT_COLLECT_INTERVAL_SECS)

        collector.stop_collection()

        mock_thread.stop.assert_called_once_with()
    def test_start_stop_collection(self, _periodic_cls):
        mock_thread = MagicMock()
        _periodic_cls.return_value = mock_thread
        collector = StatsCollector(self._mock_db)

        collector.start_collection()

        assert_that(mock_thread.daemon, is_(True))
        mock_thread.start.assert_called_once_with()
        _periodic_cls.assert_called_once_with(
            collector.collect,
            StatsCollector.DEFAULT_COLLECT_INTERVAL_SECS)

        collector.stop_collection()

        mock_thread.stop.assert_called_once_with()