diff options
author | Nicolas Hennion <nicolas@nicolargo.com> | 2012-07-26 18:01:33 +0200 |
---|---|---|
committer | Nicolas Hennion <nicolas@nicolargo.com> | 2012-07-26 18:01:33 +0200 |
commit | a1db8fe8e31a770a76c39af29d27d7885e13eff9 (patch) | |
tree | 079d7a4de0005f1b5393d3a1e14bb1a24fb83c53 | |
parent | ae12132ba111a89a00bdc4d38f67cd3756d3ecb5 (diff) |
Add unitest script
-rw-r--r-- | NEWS | 5 | ||||
-rwxr-xr-x | glances/unitest.py | 57 |
2 files changed, 62 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Version 1.4.1 +============= + + * Per core CPU stats (if space is available) + Version 1.4 =========== diff --git a/glances/unitest.py b/glances/unitest.py new file mode 100755 index 00000000..8d698b92 --- /dev/null +++ b/glances/unitest.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# Glances unitary test +# +# Syntax: +# ./unitest.py +# +# or ./unitest.py -v +# +# Copyright (C) Nicolargo 2012 <nicolas@nicolargo.com> +# +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Glances is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>."; +# + +import unittest +import glances +import multiprocessing + +class TestGlancesStat(unittest.TestCase): + + def setUp(self): + self.stats = glances.glancesStats() + self.stats.update() + + def test_Glances_getCore(self): + self.assertEqual(self.stats.getCore(), multiprocessing.cpu_count()) + + def test_Glances_getCpu(self): + self.stats.update() + self.assertEqual(len(self.stats.getCpu()), 4) + + def test_Glances_getPerCpu(self): + self.stats.update() + self.assertEqual(len(self.stats.getPerCpu()), multiprocessing.cpu_count()) + + def test_Glances_getMem(self): + self.stats.update() + self.assertTrue(len(self.stats.getMem()) > 2) + + def test_Glances_getMemSwap(self): + self.stats.update() + self.assertTrue(len(self.stats.getMemSwap()) > 2) + + +if __name__ == '__main__': + unittest.main() + |