20 lines
855 B
Python
20 lines
855 B
Python
import unittest
|
|
from channel_context import load_channels
|
|
|
|
class ChannelContextTests(unittest.TestCase):
|
|
def test_no_implicit_default_or_permission(self):
|
|
value = load_channels()
|
|
self.assertIsNone(value['selected_channel'])
|
|
self.assertFalse(value['authority_granted'])
|
|
self.assertEqual(len(value['channels']), 5)
|
|
|
|
def test_every_explicit_private_channel_resolves(self):
|
|
for id in ['ICE-CH-HB001', 'ICE-CH-LB001', 'ICE-CH-ZC001', 'ICE-CH-DK001']:
|
|
self.assertEqual(load_channels(id)['selected_channel']['id'], id)
|
|
|
|
def test_public_and_unknown_not_silently_routed_private(self):
|
|
for id in ['CH-ZERO-CORE-LPM', 'not-a-channel']:
|
|
with self.assertRaisesRegex(ValueError, 'UNKNOWN_PRIVATE_CHANNEL'):
|
|
load_channels(id)
|
|
|
|
if __name__ == '__main__': unittest.main()
|