def test_write_config(cleandir): config = TransistionDict() prod_config = ProdConfig() config.from_object(prod_config) l = Loader() l.write_config_py(config) assert 'client_config.py' in os.listdir(os.getcwd())
def test_process_packages(self, db): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir t_config.UPDATE_PATCHES = False config = TransistionDict() config.from_object(t_config) p = PackageHandler(config, db) p.process_packages()
def test_init(self, db): data_dir = os.getcwd() t_config = TConfig() t_config.DATA_DIR = data_dir config = TransistionDict() config.from_object(t_config) p = PackageHandler(config, db) assert p.files_dir == os.path.join(data_dir, s_dir, 'files') assert p.deploy_dir == os.path.join(data_dir, s_dir, 'deploy')
def test_prod_bad_atter(): config = TransistionDict() prod_config = ProdConfig() config.from_object(prod_config) assert config.get('DEBUG', None) is not None
def test_prod_config(): config = TransistionDict() prod_config = ProdConfig() config.from_object(prod_config) assert config['MORE_INFO'] == 'Yes Please'
def test_dev_config_bad_attr(): config = TransistionDict() test_config = DevConfig() config.from_object(test_config) assert config.get('BAD_ATTR', None) is None
def test_dev_config(): config = TransistionDict() test_config = DevConfig() config.from_object(test_config) assert config['TESTING'] is True
def test_dev_dir_none(self): myconfig = TConfig() myconfig.APP_NAME = None updater = TransistionDict() updater.from_object(myconfig) assert updater['APP_NAME'] == 'PyUpdater App'
def __init__(self, config=None, db=None): self.config = TransistionDict() # Important to keep this before updating config if config is not None: self.update_config(config, db)
def init_app(self, obj, refresh=False, test=False): """Sets up client with config values from obj Args: obj (instance): config object Kwargs: refresh (bool) Meaning: True: Refresh update manifest on object initialization False: Don't refresh update manifest on object initialization """ # Used to add missing required information # i.e. APP_NAME pyi_config = TransistionDict() pyi_config.from_object(obj) config = pyi_config.copy() self.FROZEN = jms_utils.app.FROZEN # Grabbing config information update_url = config.get('UPDATE_URL') update_urls = config.get('UPDATE_URLS') # Here we combine all urls & add trailing / if one isn't present self.update_urls = self._sanatize_update_url(update_url, update_urls) self.app_name = config.get('APP_NAME', 'PyUpdater') self.company_name = config.get('COMPANY_NAME', 'Digital Sapphire') if test: # Making platform deterministic for tests. # No need to test for other platforms at the moment self.data_dir = obj.DATA_DIR self.platform = 'mac' else: # pragma: no cover # Getting platform specific application directory self.data_dir = appdirs.user_data_dir(self.app_name, self.company_name, roaming=True) # Setting the platform to pass when requesting updates self.platform = jms_utils.system.get_system() # Creating update folder. Using settings to ease change in future self.update_folder = os.path.join(self.data_dir, settings.UPDATE_FOLDER) # Attempting to sanitize incorrect inputs types self.public_keys = convert_to_list(config.get('PUBLIC_KEYS'), default=list()) if len(self.public_keys) == 0: log.warning('May have passed an incorrect data type to ' 'PUBLIC_KEYS or an empty list was passed') # Ensuring only one occurrence of a public key is present # Would be a waste to test a bad key twice self.public_keys = list(set(self.public_keys)) # Config option to disable tls cert verification self.verify = config.get('VERIFY_SERVER_CERT', True) self.version_file = settings.VERSION_FILE self._setup() if refresh is True: self.refresh()