You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
966 B
Python
43 lines
966 B
Python
8 years ago
|
from utils import transport
|
||
|
from utils.ml import ML
|
||
|
import unittest
|
||
|
import json
|
||
|
import os
|
||
|
|
||
|
|
||
|
path = os.environ['MONITOR_CONFIG_PATH']
|
||
|
f = open(path)
|
||
|
CONFIG = json.loads( f.read())
|
||
|
f.close()
|
||
|
factory = transport.DataSourceFactory()
|
||
|
#greader = factory.instance(type=ref,args=p)
|
||
|
|
||
|
class TestML(unittest.TestCase):
|
||
|
def setUp(self):
|
||
|
|
||
|
ref = CONFIG['store']['class']['read']
|
||
|
p = CONFIG['store']['args']
|
||
|
p['qid'] = ['apps']
|
||
|
self.greader = factory.instance(type=ref,args=p)
|
||
|
def test_has_date(self):
|
||
|
r = self.greader.read()
|
||
|
|
||
|
self.assertTrue(r)
|
||
|
def test_Filter(self):
|
||
|
r = self.greader.read()
|
||
|
r = r['apps']
|
||
|
x = ML.Filter('label','Google Chrome',r)
|
||
|
for row in x:
|
||
|
self.assertTrue(row['label'] == 'Google Chrome')
|
||
|
def test_Extract(self):
|
||
|
r = self.greader.read()
|
||
|
r = r['apps']
|
||
|
x = ML.Filter('label','Google Chrome',r)
|
||
|
x_ = ML.Extract(['cpu_usage','memory_usage'], x)
|
||
|
print x[0]
|
||
|
print x_
|
||
|
pass
|
||
|
|
||
|
|
||
|
if __name__ == '__main__' :
|
||
|
unittest.main()
|