From ab46d45f932cfb8062c3d1e40bb402ee193b9578 Mon Sep 17 00:00:00 2001 From: David Read Date: Mon, 12 Oct 2015 16:25:55 +0100 Subject: [PATCH] Revert "[#2561] Add test to show issue with lazy json and the newer simplejson library." This reverts commit 301efbaa8040af7e9c75998f8e961aa51ac3fd73. --- ckan/lib/lazyjson.py | 9 +-------- ckan/logic/action/get.py | 2 +- ckan/tests/lib/test_lazyjson.py | 28 ---------------------------- 3 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 ckan/tests/lib/test_lazyjson.py diff --git a/ckan/lib/lazyjson.py b/ckan/lib/lazyjson.py index 67d8772402e..c4c29160b49 100644 --- a/ckan/lib/lazyjson.py +++ b/ckan/lib/lazyjson.py @@ -3,14 +3,7 @@ class LazyJSONObject(dict): - '''An object that behaves like a dict returned from json.loads, - however it will not actually do the expensive decoding from a JSON string - into a dict unless you start treating it like a dict. - - This is therefore useful for the situation where there's a good chance you - won't need to use the data in dict form, and all you're going to do is - json.dumps it again, for which your original string is returned. - ''' + '''An object that behaves like a dict returned from json.loads''' def __init__(self, json_string): self._json_string = json_string self._json_dict = None diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index a48df52d21a..16ddb29a494 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -1056,7 +1056,7 @@ def package_show(context, data_dict): package_dict_validated = False metadata_modified = pkg.metadata_modified.isoformat() search_metadata_modified = search_result['metadata_modified'] - # solr stores less precise datetime, + # solr stores less precice datetime, # truncate to 22 charactors to get good enough match if metadata_modified[:22] != search_metadata_modified[:22]: package_dict = None diff --git a/ckan/tests/lib/test_lazyjson.py b/ckan/tests/lib/test_lazyjson.py deleted file mode 100644 index 547e7a6b4ec..00000000000 --- a/ckan/tests/lib/test_lazyjson.py +++ /dev/null @@ -1,28 +0,0 @@ -from nose.tools import assert_equal - -from ckan.lib.lazyjson import LazyJSONObject -import ckan.lib.helpers as h - - -class TestLazyJson(object): - def test_dump_without_necessarily_going_via_a_dict(self): - json_string = '{"title": "test_2"}' - lazy_json_obj = LazyJSONObject(json_string) - dumped = h.json.dumps( - lazy_json_obj, - for_json=True) - assert_equal(dumped, json_string) - - def test_dump_without_needing_to_go_via_a_dict(self): - json_string = '"invalid" JSON to [{}] ensure it doesnt become a dict' - lazy_json_obj = LazyJSONObject(json_string) - dumped = h.json.dumps( - lazy_json_obj, - for_json=True) - assert_equal(dumped, json_string) - - def test_treat_like_a_dict(self): - json_string = '{"title": "test_2"}' - lazy_json_obj = LazyJSONObject(json_string) - assert_equal(lazy_json_obj.keys(), ['title']) - assert_equal(len(lazy_json_obj), 1)