Commit ba4b3b4c authored by Tristan Cavelier's avatar Tristan Cavelier

check_computer_memory: refactor getFreeMemory to fit code behavior

parent bd09f20e
......@@ -14,7 +14,7 @@ import datetime
from slapos.collect.db import Database
def getFreeMemory(database, time, date):
def getMemoryInfo(database, time, date):
mem = {}
database = Database(database)
......@@ -55,7 +55,7 @@ def main():
db_path = args.collectordb
if db_path.endswith("collector.db"):db_path=db_path[:-len("collector.db")]
memory, error = getFreeMemory(db_path, currenttime, currentdate)
memory, error = getMemoryInfo(db_path, currenttime, currentdate)
if error:
print error
return 0
......
......@@ -30,7 +30,7 @@ import os
import sqlite3
from slapos.test.promise import data
from slapos.promise.check_computer_memory import getFreeMemory
from slapos.promise.check_computer_memory import getMemoryInfo
total_memory_fetch_failure_message = "couldn't fetch total memory, collectordb is empty?"
......@@ -50,12 +50,12 @@ class TestComputerMemory(unittest.TestCase):
def test_check_memory(self):
self.assertEquals(({'total': 33705312256.0, 'used': 33139023872.0, 'free': 566288384.0}, ""),
getFreeMemory('/tmp', '00:02', '2017-09-15'))
getMemoryInfo('/tmp', '00:02', '2017-09-15'))
def test_check_memory_with_unavailable_dates(self):
self.assertEquals(
(None, total_memory_fetch_failure_message),
getFreeMemory('/tmp', '18:00', '2017-09-14'),
getMemoryInfo('/tmp', '18:00', '2017-09-14'),
)
def tearDown(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment