summaryrefslogtreecommitdiffstats
path: root/unitest.py
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2018-04-02 13:23:06 +0200
committernicolargo <nicolas@nicolargo.com>2018-04-02 13:23:06 +0200
commit476d441c0e0d224815064ed21ecbf568bdec6ef8 (patch)
treeba56fe7557063a612d02ab949b6df04cd76d3c83 /unitest.py
parenta7944969ce68c7add6efda78456f7170c9f54c09 (diff)
Subsample data for graph generation
Diffstat (limited to 'unitest.py')
-rwxr-xr-xunitest.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/unitest.py b/unitest.py
index 3ee52369..20df9eda 100755
--- a/unitest.py
+++ b/unitest.py
@@ -34,6 +34,7 @@ from glances.thresholds import GlancesThresholdWarning
from glances.thresholds import GlancesThresholdCritical
from glances.thresholds import GlancesThresholds
from glances.plugins.glances_plugin import GlancesPlugin
+from glances.compat import subsample
# Global variables
# =================
@@ -241,6 +242,18 @@ class TestGlances(unittest.TestCase):
self.assertEqual(sorted_stats[3]["key"], "key4")
self.assertEqual(sorted_stats[4]["key"], "key21")
+ def test_015_subsample(self):
+ """Test subsampling function."""
+ print('INFO: [TEST_015] Subsampling')
+ for l in [([1, 2, 3], 4),
+ ([1, 2, 3, 4], 4),
+ ([1, 2, 3, 4, 5, 6, 7], 4),
+ ([1, 2, 3, 4, 5, 6, 7, 8], 4),
+ (list(xrange(1, 800)), 4),
+ (list(xrange(1, 8000)), 800)]:
+ l_subsample = subsample(l[0], l[1])
+ self.assertLessEqual(len(l_subsample), l[1])
+
def test_094_thresholds(self):
"""Test thresholds classes"""
print('INFO: [TEST_094] Thresholds')