Exemple #1
0
    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
        config = ConfigDict()
        config.from_object(obj)

        self.FROZEN = jms_utils.app.FROZEN
        # Grabbing config information
        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_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.root_key = config.get('PUBLIC_KEY', '')
        self.app_key = None

        # Config option to disable tls cert verification
        self.verify = config.get('VERIFY_SERVER_CERT', True)
        self.version_file = settings.VERSION_FILE
        self.key_file = settings.KEY_FILE

        self._setup()
        if refresh is True:
            self.refresh()
Exemple #2
0
def test_prod_bad_atter():
    config = ConfigDict()
    prod_config = ProdConfig()
    config.from_object(prod_config)
    assert config.get('DEBUG', None) is not None
Exemple #3
0
def test_dev_config_bad_attr():
    config = ConfigDict()
    test_config = DevConfig()
    config.from_object(test_config)
    assert config.get('BAD_ATTR', None) is None