def testJSON_08(self): opt = JSONOption(self.config, "Test", "json_test", None) newopt = JSONOption(self.config, "Test", "json_test", None) opt.value = {'x': 100, 'y': 200} self.assertEqual(newopt.value, {'x': 100, 'y': 200})
def testJSON_09(self): opt = JSONOption(self.config, "Test", "json_test", None) newopt = JSONOption(self.config, "Test", "json_test", None) opt.value = '111\n222\n333' self.assertEqual(newopt.value, '111\n222\n333')
def testJSON_07(self): opt = JSONOption(self.config, "Test", "json_test", None) newopt = JSONOption(self.config, "Test", "json_test", None) opt.value = [1, 2, 3] self.assertEqual(newopt.value, [1, 2, 3])
def saveCustomStylesToConfig(config: Config, section_name: str, option_name: str, styles: Dict[str, str]) -> None: ''' Save custom styles to config in JSON format ''' opt = JSONOption(config, section_name, option_name, None) opt.value = styles
def loadCustomStylesFromConfig(config: Config, section_name: str, option_name: str) -> Dict[str, str]: ''' Load saved styles from page config in JSON format. Return dictionary: key - style name, value - CSS style. ''' result = {} opt = JSONOption(config, section_name, option_name, None) styles = opt.value if not isinstance(styles, dict): return result result = { name: value for name, value in styles.items() if isinstance(name, str) and isinstance(value, str) } return result
def testJSON_06(self): opt = JSONOption(self.config, "Test", "jsonval_05", None) self.assertEqual(opt.value['x'], 100)
def testJSON_05(self): opt = JSONOption(self.config, "Test", "jsonval_04", None) self.assertEqual(opt.value, [1, 2, 3])
def testJSON_03(self): opt = JSONOption(self.config, "Test", "jsonval_02", None) self.assertEqual(opt.value, 'строка')
def testJSON_02(self): opt = JSONOption(self.config, "Test", "jsonval_01", None) self.assertEqual(opt.value, {})