예제 #1
0
    def test_misconfigured_settings_file_fall_back_on_default(self):
        path = self.make_settings_tmp_dir()

        with open(os.path.join(path, 'settings.json'), 'w') as f:
            f.write("not proper json")

        settings = PodpacSettings()
        settings.load(path=path)
        assert isinstance(settings, dict)

        path = os.path.expanduser("~")
        assert settings.settings_path == os.path.join(path, '.podpac',
                                                      'settings.json')
예제 #2
0
    def test_misconfigured_settings_file_fall_back_on_default(self):
        path = self.make_settings_tmp_dir()

        with open(os.path.join(path, "settings.json"), "w") as f:
            f.write("not proper json")

        settings = PodpacSettings()
        settings.load(path=path)
        assert isinstance(settings, dict)

        path = os.environ.get("XDG_CACHE_HOME", os.path.expanduser("~"))
        assert settings.settings_path == os.path.join(path, ".config",
                                                      "podpac",
                                                      "settings.json")
예제 #3
0
 def test_settings_file_defaults_to_home_dir(self):
     self.make_settings_tmp_dir(
     )  # so teardown method has something ot tear down
     settings = PodpacSettings()
     path = os.path.expanduser("~")
     assert settings.settings_path == os.path.join(path, '.podpac',
                                                   'settings.json')
예제 #4
0
 def test_settings_file_defaults_to_home_dir(self):
     self.make_settings_tmp_dir(
     )  # so teardown method has something ot tear down
     settings = PodpacSettings()
     path = os.environ.get("XDG_CACHE_HOME", os.path.expanduser("~"))
     assert settings.settings_path == os.path.join(path, ".config",
                                                   "podpac",
                                                   "settings.json")
예제 #5
0
    def test_single_saved_setting_persists(self):
        path = self.make_settings_tmp_dir()

        key = "key"
        value = "value"
        settings = PodpacSettings()
        settings.load(path=path)
        settings["AUTOSAVE_SETTINGS"] = True
        settings[key] = value

        new_settings = PodpacSettings()
        new_settings.load(path=path)
        assert new_settings[key] == value
예제 #6
0
    def test_multiple_saved_settings_persist(self):
        path = self.make_settings_tmp_dir()

        key1 = "key1"
        value1 = "value1"
        settings = PodpacSettings()
        settings.load(path=path)
        settings["AUTOSAVE_SETTINGS"] = True
        settings[key1] = value1

        key2 = "key2"
        value2 = "value2"
        settings[key2] = value2

        new_settings = PodpacSettings()
        new_settings.load(path=path)
        assert new_settings[key1] == value1
        assert new_settings[key2] == value2