40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
import unittest
|
|
|
|
from fgai.cli import _configured_streams
|
|
|
|
|
|
class CliTests(unittest.TestCase):
|
|
def test_configured_streams_uses_enabled_streams_by_default(self):
|
|
config = {
|
|
"graylog_streams": [
|
|
{"id": "fortigate", "title": "Fortigate", "enabled": True},
|
|
{"id": "adguard", "title": "Adguard", "enabled": False},
|
|
]
|
|
}
|
|
self.assertEqual(_configured_streams(config), [{"id": "fortigate", "title": "Fortigate"}])
|
|
|
|
def test_configured_streams_can_select_disabled_stream(self):
|
|
config = {
|
|
"graylog_streams": [
|
|
{"id": "fortigate", "title": "Fortigate", "enabled": True},
|
|
{"id": "adguard", "title": "Adguard", "enabled": False},
|
|
]
|
|
}
|
|
self.assertEqual(_configured_streams(config, ["adguard"]), [{"id": "adguard", "title": "Adguard"}])
|
|
|
|
def test_configured_streams_preserves_selected_order(self):
|
|
config = {
|
|
"graylog_streams": [
|
|
{"id": "fortigate", "title": "Fortigate", "enabled": True},
|
|
{"id": "adguard", "title": "Adguard", "enabled": False},
|
|
]
|
|
}
|
|
self.assertEqual(
|
|
_configured_streams(config, ["adguard", "fortigate"]),
|
|
[{"id": "adguard", "title": "Adguard"}, {"id": "fortigate", "title": "Fortigate"}],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|