def test_storeConfigInFile_createsNewFileIfNotExists(self): PathsManager.CONFIG_PATH = os.path.join(self.myTestFolder, "newConfig.json") self.assertFalse(os.path.exists(PathsManager.CONFIG_PATH)) Config.store_config_in_file() self.assertTrue(os.path.exists(PathsManager.CONFIG_PATH))
def test_storeConfigInFile_overWriteFileIfExist(self): PathsManager.CONFIG_PATH = os.path.join(self.myTestFolder, "newConfig.json") with open(PathsManager.CONFIG_PATH, "w") as f: f.write("Testing") Config.store_config_in_file() with open(PathsManager.CONFIG_PATH) as f: self.assertNotEqual(f.read(), "Testing")
def test_storeConfigInFile_createsAJsonWithAllConfigValues(self): PathsManager.CONFIG_PATH = os.path.join(self.myTestFolder, "newConfig.json") Config.store_config_in_file() with open(PathsManager.CONFIG_PATH) as f: obj = json.load(f) for k, v in self.originalConfigDict.items(): self.assertEqual(obj[k], v)
def set_values(self, config_dic): config_values = Config.get_config_values() if "libraries_path" in config_dic: libraries_path = config_dic.pop("libraries_path") self.set_libraries_path(libraries_path) for k in config_values.keys(): if k in config_dic: Config.__dict__[k] = config_dic[k] if Config.proxy is not None: utils.set_proxy(dict(http=Config.proxy, https=Config.proxy)) Config.store_config_in_file() return True
def set_proxy(self, proxy_url): Config.proxy = proxy_url Config.store_config_in_file()
def set_web_socket_info(self, IP, port): Config.web_socket_ip = IP Config.web_socket_port = port Config.store_config_in_file()