From 31780046c210113bd08aebf709f04f83302b24ad Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Thu, 21 Feb 2013 17:51:00 +0100 Subject: Fix Travis-CI issue --- .travis.yml | 5 +- MANIFEST.in | 1 - glances/tests/__init__.py | 0 glances/tests/test_glances.py | 118 ++++++++++++++++++++++++++++++++++++++++ glances/unitest.py | 121 ------------------------------------------ requirements.txt | 1 + setup.py | 1 + 7 files changed, 123 insertions(+), 124 deletions(-) create mode 100644 glances/tests/__init__.py create mode 100644 glances/tests/test_glances.py delete mode 100755 glances/unitest.py create mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index cc7c7a7a..554887f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ python: - "2.6" - "2.7" - "3.2" + - "3.3" install: - - "pip install psutil" -script: cd ./glances ; python ./unitest.py + - pip install -r requirements.txt --use-mirrors +script: python setup.py test diff --git a/MANIFEST.in b/MANIFEST.in index 826d9633..36c36cd4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include README include COPYING include AUTHORS -include ChangeLog include NEWS include screenshot.png recursive-include doc *.png diff --git a/glances/tests/__init__.py b/glances/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/glances/tests/test_glances.py b/glances/tests/test_glances.py new file mode 100644 index 00000000..a2f2ffca --- /dev/null +++ b/glances/tests/test_glances.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Glances unitary test +# +# Copyright (C) 2012 Nicolargo +# +# Glances is free software; you can redistribute it and/or modify +# it 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 . + +# import os +# import time +# import signal +import unittest +import multiprocessing + +from glances import glances + + +class TestGlancesStat(unittest.TestCase): + + def setUp(self): + self.stats = glances.GlancesStats() + self.stats.update() + + def test_Glances_getSystem(self): + self.stats.update() + system = self.stats.getSystem() + #~ print("System info: %s" % system) + self.assertTrue(type(system) == dict) + self.assertTrue(len(system) > 1) + + def test_Glances_getCore(self): + self.stats.update() + core = self.stats.getCore() + #~ print("CPU Core number: %s" % core) + self.assertTrue(type(core) == int) + self.assertEqual(core, multiprocessing.cpu_count()) + + def test_Glances_getCpu(self): + self.stats.update() + cpu = self.stats.getCpu() + #~ print("CPU stat %s:" % cpu) + self.assertTrue(type(cpu) == dict) + self.assertTrue(len(cpu) > 1) + + def test_Glances_getPerCpu(self): + self.stats.update() + percpu = self.stats.getPerCpu() + #~ print("PerCPU stat %s:" % percpu) + self.assertTrue(type(percpu) == list) + self.assertEqual(len(percpu), multiprocessing.cpu_count()) + + def test_Glances_getMem(self): + self.stats.update() + mem = self.stats.getMem() + #~ print("Mem stat %s:" % mem) + self.assertTrue(type(mem) == dict) + self.assertTrue(len(mem) > 2) + + def test_Glances_getMemSwap(self): + self.stats.update() + memswap = self.stats.getMemSwap() + #~ print("MemSwap stat %s:" % memswap) + self.assertTrue(type(memswap) == dict) + self.assertTrue(len(memswap) > 2) + + def test_Glances_getNetwork(self): + self.stats.update() + net = self.stats.getNetwork() + #~ print("Network stat %s:" % net) + self.assertTrue(type(net) == list) + self.assertTrue(len(net) > 0) + + def test_Glances_getDiskIO(self): + self.stats.update() + diskio = self.stats.getDiskIO() + #~ print("DiskIO stat %s:" % diskio) + self.assertTrue(type(diskio) == list) + self.assertTrue(len(diskio) > 0) + + def test_Glances_getFs(self): + self.stats.update() + fs = self.stats.getFs() + #~ print("File system stat %s:" % fs) + self.assertTrue(type(fs) == list) + self.assertTrue(len(fs) > 0) + + def test_Glances_getProcess(self): + self.stats.update() + pc = self.stats.getProcessCount() + pl = self.stats.getProcessList() + #~ print("Processes stat %s:" % pc) + #~ print("Processes list %s:" % pl) + self.assertTrue(type(pc) == dict) + self.assertTrue(len(pc) > 2) + self.assertTrue(type(pl) == list) + self.assertTrue(len(pl) > 0) + + def test_Glances_getSensors(self): + self.stats.update() + sensors = self.stats.getSensors() + #~ print("Optionnal sensors stat %s:" % sensors) + self.assertTrue(type(sensors) == list) + #~ self.assertTrue(len(sensors) > 0) + +if __name__ == '__main__': + unittest.main() diff --git a/glances/unitest.py b/glances/unitest.py deleted file mode 100755 index 4e6621da..00000000 --- a/glances/unitest.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Glances unitary test -# -# Syntax: -# ./unitest.py -# or -# ./unitest.py -v -# -# Copyright (C) 2012 Nicolargo -# -# Glances is free software; you can redistribute it and/or modify -# it 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 . - -import unittest -import multiprocessing -import os -import signal -import time -import glances - -class TestGlancesStat(unittest.TestCase): - - def setUp(self): - self.stats = glances.GlancesStats() - self.stats.update() - - def test_Glances_getSystem(self): - self.stats.update() - system = self.stats.getSystem() - #~ print("System info: %s" % system) - self.assertTrue(type(system) == dict) - self.assertTrue(len(system) > 1) - - def test_Glances_getCore(self): - self.stats.update() - core = self.stats.getCore() - #~ print("CPU Core number: %s" % core) - self.assertTrue(type(core) == int) - self.assertEqual(core, multiprocessing.cpu_count()) - - def test_Glances_getCpu(self): - self.stats.update() - cpu = self.stats.getCpu() - #~ print("CPU stat %s:" % cpu) - self.assertTrue(type(cpu) == dict) - self.assertTrue(len(cpu) > 1) - - def test_Glances_getPerCpu(self): - self.stats.update() - percpu = self.stats.getPerCpu() - #~ print("PerCPU stat %s:" % percpu) - self.assertTrue(type(percpu) == list) - self.assertEqual(len(percpu), multiprocessing.cpu_count()) - - def test_Glances_getMem(self): - self.stats.update() - mem = self.stats.getMem() - #~ print("Mem stat %s:" % mem) - self.assertTrue(type(mem) == dict) - self.assertTrue(len(mem) > 2) - - def test_Glances_getMemSwap(self): - self.stats.update() - memswap = self.stats.getMemSwap() - #~ print("MemSwap stat %s:" % memswap) - self.assertTrue(type(memswap) == dict) - self.assertTrue(len(memswap) > 2) - - def test_Glances_getNetwork(self): - self.stats.update() - net = self.stats.getNetwork() - #~ print("Network stat %s:" % net) - self.assertTrue(type(net) == list) - self.assertTrue(len(net) > 0) - - def test_Glances_getDiskIO(self): - self.stats.update() - diskio = self.stats.getDiskIO() - #~ print("DiskIO stat %s:" % diskio) - self.assertTrue(type(diskio) == list) - self.assertTrue(len(diskio) > 0) - - def test_Glances_getFs(self): - self.stats.update() - fs = self.stats.getFs() - #~ print("File system stat %s:" % fs) - self.assertTrue(type(fs) == list) - self.assertTrue(len(fs) > 0) - - def test_Glances_getProcess(self): - self.stats.update() - pc = self.stats.getProcessCount() - pl = self.stats.getProcessList() - #~ print("Processes stat %s:" % pc) - #~ print("Processes list %s:" % pl) - self.assertTrue(type(pc) == dict) - self.assertTrue(len(pc) > 2) - self.assertTrue(type(pl) == list) - self.assertTrue(len(pl) > 0) - - def test_Glances_getSensors(self): - self.stats.update() - sensors = self.stats.getSensors() - #~ print("Optionnal sensors stat %s:" % sensors) - self.assertTrue(type(sensors) == list) - #~ self.assertTrue(len(sensors) > 0) - -if __name__ == '__main__': - unittest.main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..c02dd913 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +psutil==0.6.1 diff --git a/setup.py b/setup.py index cb2ee8ee..310c8a08 100755 --- a/setup.py +++ b/setup.py @@ -40,6 +40,7 @@ setup( license="LGPL", keywords="cli curses monitoring system", long_description=open('README').read(), + test_suite="glances.tests", install_requires=['psutil>=0.4.1'], packages=['glances'], extras_require={ -- cgit v1.2.3 From 4d3afc00e0be28ce48c280446b7a61e946a01030 Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Thu, 21 Feb 2013 18:51:00 +0100 Subject: Disable test against Travis-CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 554887f6..ba470f2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ python: - "3.3" install: - pip install -r requirements.txt --use-mirrors -script: python setup.py test +script: nosetests -- cgit v1.2.3 From e5f9c9223f7e3091455f9ba79a4e7ce5dfcf3cad Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Thu, 21 Feb 2013 18:55:27 +0100 Subject: Disable test against Travis-CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ba470f2b..dafc1685 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ python: - "3.3" install: - pip install -r requirements.txt --use-mirrors -script: nosetests +script: python setup.py install -- cgit v1.2.3