blob: 52dff4e2ce7a58ed0cbf947d6c624598cf5fe2aa [file] [log] [blame]
# -*- coding: utf-8 -*-
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unit tests for osinfo_metrics."""
# pylint: disable=protected-access
from __future__ import absolute_import
from __future__ import print_function
import mock
from chromite.lib import cros_test_lib
from chromite.scripts.sysmon import osinfo_metrics
class TestOSInfoMetrics(cros_test_lib.TestCase):
"""Tests for osinfo_metrics."""
def setUp(self):
patcher = mock.patch('',
autospec=True) = patcher.start()
def test_collect(self):
with mock.patch('platform.system', autospec=True) as system, \
mock.patch('platform.dist', autospec=True) as dist, \
mock.patch('sys.maxsize', 2**64):
system.return_value = 'Linux'
dist.return_value = ('Ubuntu', '14.04', 'trusty')
setter =
calls = ['proc/os/name', (), None, 'ubuntu', enforce_ge=mock.ANY),'proc/os/version', (), None, '14.04', enforce_ge=mock.ANY),'proc/os/arch', (), None, 'x86_64', enforce_ge=mock.ANY),'proc/python/arch', (), None, '64', enforce_ge=mock.ANY),
self.assertEqual(len(setter.mock_calls), len(calls))