예제 #1
0
class TestDashboardModel(unittest.TestCase):
    def setUp(self):
        self.model = DashboardModel()

    def test_get_last_process_check(self):
        active_checks = ['cron']

        cron = self.model.mongo.get_collection('cron')
        cron.remove()

        cron.insert({"memory": "10.8", "time": two_minutes_ago, "cpu": "0.0"})
        cron.insert({"memory": "10.8", "time": minute_ago, "cpu": "0.0"})
        cron.insert({"last": 1})

        result = self.model.get_last_process_check(active_checks)
        eq_(result['cron']['time'], minute_ago)

        cron.remove()

    def test_get_last_system_check(self):
        active_checks = ['cpu']

        cpu = self.model.mongo.get_collection('cpu')
        cpu.remove()

        cpu.insert({"system": "10", "time": two_minutes_ago})
        cpu.insert({"system": "10", "time": minute_ago})
        cpu.insert({"last": 1})

        result = self.model.get_last_system_check(active_checks)
        eq_(result['cpu']['time'], minute_ago)

        cpu.remove()
예제 #2
0
파일: models_test.py 프로젝트: pgrout/amon
class TestDashboardModel(unittest.TestCase):
    def setUp(self):
        self.model = DashboardModel()

    def test_get_last_process_check(self):
        active_checks = ["cron"]

        cron = self.model.mongo.get_collection("cron")
        cron.remove()

        cron.insert({"memory": "10.8", "time": two_minutes_ago, "cpu": "0.0"})
        cron.insert({"memory": "10.8", "time": minute_ago, "cpu": "0.0"})
        cron.insert({"last": 1})

        result = self.model.get_last_process_check(active_checks)
        eq_(result["cron"]["time"], minute_ago)

        cron.remove()

    def test_get_last_system_check(self):
        active_checks = ["cpu"]

        cpu = self.model.mongo.get_collection("cpu")
        cpu.remove()

        cpu.insert({"system": "10", "time": two_minutes_ago})
        cpu.insert({"system": "10", "time": minute_ago})
        cpu.insert({"last": 1})

        result = self.model.get_last_system_check(active_checks)
        eq_(result["cpu"]["time"], minute_ago)

        cpu.remove()
예제 #3
0
 def setUp(self):
     self.model = DashboardModel()
예제 #4
0
파일: models_test.py 프로젝트: pgrout/amon
 def setUp(self):
     self.model = DashboardModel()