1234567891011121314151617181920212223242526272829303132333435 |
- from __future__ import division
- import unittest
- from monitor import Env, DetailProcess, ProcessCounter, Sandbox
- import os
- class TestMonitorServer(unittest.TestCase):
-
- def test_Environment(self):
- """
- This test case is designed to test the existance of a resource set as an environment variable. This applies to files, folders (not values)
- """
- p = Env(['PATH','HOME','SHELL'])
- r = p.composite()
- value = r['value']
-
- self.assertTrue(value > 0 and value == 2/3)
- self.assertTrue(p.evaluate('PATH') == 0)
- def test_RunningProcess(self):
- p = DetailProcess(['rabbitmq-server','python','apache2'])
- r = p.composite()
- print r
- self.assertTrue(r)
-
- def test_ProcessCount(self):
- p= ProcessCounter(['apache2','VBoxClient','rabbitmq-server','foo'])
- r = p.composite()
-
- self.assertTrue( sum(r.values()) > 0 )
- self.assertTrue( r['foo'] == 0)
- def test_VirtualEnv(self):
- requirements_path = os.sep.join([os.environ['PYTHONPATH'],"..","requirements.txt"])
- sandbox_path = os.sep.join([os.environ['PYTHONPATH'],"..",'sandbox'])
- p = Sandbox({"sandbox":sandbox_path,"requirements":requirements_path})
- print p.composite()
- if __name__ == '__main__' :
- unittest.main()
|