'Tests that the client stats are collected automatically.'

def testClientStatsCollection(self):

    now = 1000000
    self.client_communicator.client_worker.last_stats_sent_time = rdfvalue.RDFDatetime().FromSecondsFromEpoch(now)
    with test_lib.FakeTime(now):
        self.client_communicator.client_worker.CheckStats()
    runs = []
    with utils.Stubber(admin.GetClientStatsAuto, 'Run', (lambda cls, _: runs.append(1))):
        with test_lib.FakeTime((now + 600)):
            self.client_communicator.client_worker.CheckStats()
            self.assertEqual(len(runs), 0)
        with test_lib.FakeTime((now + 3600)):
            self.client_communicator.client_worker.CheckStats()
            self.assertEqual(len(runs), 1)
        with test_lib.FakeTime(((now + 3600) + 600)):
            self.client_communicator.client_worker.CheckStats()
            self.assertEqual(len(runs), 1)
