From 54471569ab287677ed731b728801bfd4c50fd32b Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 31 Mar 2013 14:53:21 +0400 Subject: [PATCH] Check whether it switches configuration fine --- tests/test_config_reload.py | 50 +++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/tests/test_config_reload.py b/tests/test_config_reload.py index 57c47c63..8db2ff70 100644 --- a/tests/test_config_reload.py +++ b/tests/test_config_reload.py @@ -89,6 +89,12 @@ config = { "str2": {"fg": "col3", "bg": "col4", "attr": ["underline"]}, }, }, + 'colorschemes/test/2': { + 'groups': { + "str1": {"fg": "col2", "bg": "col3", "attr": ["bold"]}, + "str2": {"fg": "col1", "bg": "col4", "attr": ["underline"]}, + }, + }, 'themes/test/default': { 'segments': { "left": [ @@ -107,6 +113,24 @@ config = { ], }, }, + 'themes/test/2': { + 'segments': { + "left": [ + { + "type": "string", + "contents": "t", + "highlight_group": ["str1"], + }, + { + "type": "string", + "contents": "b", + "highlight_group": ["str2"], + }, + ], + "right": [ + ], + }, + }, } @@ -216,12 +240,12 @@ class TestConfigReload(TestCase): self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>>') self.assertEqual(p.logger._pop_msgs(), []) - config['config']['ext']['test']['theme'] = 'new' + config['config']['ext']['test']['theme'] = 'nonexistent' add_watcher_events(p, 'config') - self.assertAccessEvents('config', 'themes/test/new') + self.assertAccessEvents('config', 'themes/test/nonexistent') self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>>') # It should normally handle file missing error - self.assertEqual(p.logger._pop_msgs(), ['test:Failed to create renderer: themes/test/new']) + self.assertEqual(p.logger._pop_msgs(), ['test:Failed to create renderer: themes/test/nonexistent']) config['config']['ext']['test']['theme'] = 'default' add_watcher_events(p, 'config') @@ -229,24 +253,30 @@ class TestConfigReload(TestCase): self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>>') self.assertEqual(p.logger._pop_msgs(), []) - config['config']['ext']['test']['colorscheme'] = 'new' + config['config']['ext']['test']['colorscheme'] = 'nonexistent' add_watcher_events(p, 'config') - self.assertAccessEvents('config', 'colorschemes/test/new') + self.assertAccessEvents('config', 'colorschemes/test/nonexistent') self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>>') # It should normally handle file missing error - self.assertEqual(p.logger._pop_msgs(), ['test:Failed to create renderer: colorschemes/test/new']) + self.assertEqual(p.logger._pop_msgs(), ['test:Failed to create renderer: colorschemes/test/nonexistent']) - config['config']['ext']['test']['colorscheme'] = 'default' + config['config']['ext']['test']['colorscheme'] = '2' add_watcher_events(p, 'config') - self.assertAccessEvents('config', 'colorschemes/test/default') - self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>>') + self.assertAccessEvents('config', 'colorschemes/test/2') + self.assertEqual(p.render(), '<2 3 1> s <3 4 False>>><1 4 4>g <4 False False>>>') + self.assertEqual(p.logger._pop_msgs(), []) + + config['config']['ext']['test']['theme'] = '2' + add_watcher_events(p, 'config') + self.assertAccessEvents('config', 'themes/test/2') + self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>>') self.assertEqual(p.logger._pop_msgs(), []) self.assertEqual(p.renderer.local_themes, None) config['config']['ext']['test']['local_themes'] = 'something' add_watcher_events(p, 'config') self.assertAccessEvents('config') - self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>>') + self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>>') self.assertEqual(p.logger._pop_msgs(), []) self.assertEqual(p.renderer.local_themes, 'something')