diff --git a/YouVersion Suggest (Alfred 5).alfredworkflow b/YouVersion Suggest (Alfred 5).alfredworkflow index 121b339..b20d55f 100644 Binary files a/YouVersion Suggest (Alfred 5).alfredworkflow and b/YouVersion Suggest (Alfred 5).alfredworkflow differ diff --git a/tests/test_clear_cache.py b/tests/test_clear_cache.py index edf086f..570cc3e 100644 --- a/tests/test_clear_cache.py +++ b/tests/test_clear_cache.py @@ -7,11 +7,13 @@ import yvs.clear_cache as yvs from tests import YVSTestCase +from tests.decorators import redirect_stdout class TestClearCachw(YVSTestCase): - def test_clear_cache(self): + @redirect_stdout + def test_clear_cache(self, out): """should remove cache directory when cache is cleared""" yvs.main() self.assertFalse( @@ -19,7 +21,8 @@ def test_clear_cache(self): "local cache directory exists", ) - def test_clear_cache_silent_fail(self): + @redirect_stdout + def test_clear_cache_silent_fail(self, out): """should fail silently if cache directory does not exist""" shutil.rmtree(yvs.cache.LOCAL_CACHE_DIR_PATH) yvs.main() diff --git a/tests/test_set_pref.py b/tests/test_set_pref.py index 974195f..6ef75b9 100644 --- a/tests/test_set_pref.py +++ b/tests/test_set_pref.py @@ -56,6 +56,8 @@ def test_main(self, out): } yvs.main(alfred_variables) alfred_json = json.loads(out.getvalue()) - self.assertEqual(alfred_json["alfredworkflow"]["variables"], alfred_variables) + self.assertEqual( + alfred_json["alfredworkflow"]["variables"], {"did_set_pref": "True"} + ) user_prefs = yvs.core.get_user_prefs() self.assertEqual(user_prefs["version"], 107) diff --git a/yvs/clear_cache.py b/yvs/clear_cache.py index 16ebb27..5880d64 100644 --- a/yvs/clear_cache.py +++ b/yvs/clear_cache.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 # coding=utf-8 +import json + import yvs.cache as cache def main(): cache.clear_cache() + print(json.dumps({"alfredworkflow": {"variables": {"did_clear_cache": "True"}}})) if __name__ == "__main__": diff --git a/yvs/set_pref.py b/yvs/set_pref.py index 14fc759..415f97e 100644 --- a/yvs/set_pref.py +++ b/yvs/set_pref.py @@ -28,7 +28,7 @@ def main(variables): # value_id needs to be parsed as JSON so we can preserve type data for # proper serialization to the preferences file set_pref(variables["pref_id"], json.loads(variables["value_id"])) - print(json.dumps({"alfredworkflow": {"variables": variables}})) + print(json.dumps({"alfredworkflow": {"variables": {"did_set_pref": "True"}}})) if __name__ == "__main__":