forked from openwisp/openwisp-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added dashboard charts: geo, model, os, hardware
- Loading branch information
1 parent
3cc3be3
commit d81015b
Showing
15 changed files
with
211 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from django.test import TestCase | ||
|
||
from openwisp_utils.admin_theme.dashboard import DASHBOARD_CHARTS | ||
|
||
|
||
class TestApps(TestCase): | ||
def test_config_status_chart_registered(self): | ||
expected_config = { | ||
'name': 'Configuration Status', | ||
'query_params': { | ||
'app_label': 'config', | ||
'model': 'device', | ||
'group_by': 'config__status', | ||
}, | ||
'colors': {'applied': '#267126', 'modified': '#ffb442', 'error': '#a72d1d'}, | ||
'labels': {'applied': 'applied', 'error': 'error', 'modified': 'modified'}, | ||
} | ||
chart_config = DASHBOARD_CHARTS.get(1, None) | ||
self.assertIsNotNone(chart_config) | ||
self.assertDictEqual(chart_config, expected_config) | ||
|
||
def test_device_models_chart_registered(self): | ||
chart_config = DASHBOARD_CHARTS.get(10, None) | ||
self.assertIsNotNone(chart_config) | ||
self.assertEqual(chart_config['name'], 'Device Models') | ||
self.assertIn('labels', chart_config) | ||
self.assertDictEqual(chart_config['labels'], {'': 'undefined'}) | ||
self.assertNotIn('filters', chart_config) | ||
query_params = chart_config['query_params'] | ||
self.assertIn('group_by', query_params) | ||
self.assertEqual(query_params['group_by'], 'model') | ||
|
||
def test_firmware_version_chart_registered(self): | ||
chart_config = DASHBOARD_CHARTS.get(11, None) | ||
self.assertIsNotNone(chart_config) | ||
self.assertEqual(chart_config['name'], 'Firmware version') | ||
self.assertIn('labels', chart_config) | ||
self.assertDictEqual(chart_config['labels'], {'': 'undefined'}) | ||
self.assertNotIn('filters', chart_config) | ||
query_params = chart_config['query_params'] | ||
self.assertIn('group_by', query_params) | ||
self.assertEqual(query_params['group_by'], 'os') | ||
|
||
def test_system_type_chart_registered(self): | ||
chart_config = DASHBOARD_CHARTS.get(12, None) | ||
self.assertIsNotNone(chart_config) | ||
self.assertEqual(chart_config['name'], 'System type') | ||
self.assertIn('labels', chart_config) | ||
self.assertDictEqual(chart_config['labels'], {'': 'undefined'}) | ||
self.assertNotIn('filters', chart_config) | ||
query_params = chart_config['query_params'] | ||
self.assertIn('group_by', query_params) | ||
self.assertEqual(query_params['group_by'], 'system') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.test import TestCase | ||
|
||
from openwisp_utils.admin_theme.dashboard import DASHBOARD_CHARTS | ||
|
||
|
||
class TestApps(TestCase): | ||
def test_geo_chart_registered(self): | ||
chart_config = DASHBOARD_CHARTS.get(2, None) | ||
self.assertIsNotNone(chart_config) | ||
self.assertEqual(chart_config['name'], 'Geographic positioning') | ||
self.assertIn('labels', chart_config) | ||
query_params = chart_config['query_params'] | ||
self.assertIn('annotate', query_params) | ||
self.assertIn('aggregate', query_params) | ||
self.assertIn('filters', chart_config) | ||
filters = chart_config['filters'] | ||
self.assertIn('key', filters) | ||
self.assertIn('with_geo__sum', chart_config['filters']) | ||
self.assertIn('without_geo__sum', chart_config['filters']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.