[ckan-changes] commit/ckanext-dgu: dread: [bin]: #1135 Script to remove National Statistics flag if it is not sourced from ONSHUB.
Bitbucket
commits-noreply at bitbucket.org
Mon Aug 8 16:52:19 UTC 2011
1 new changeset in ckanext-dgu:
http://bitbucket.org/okfn/ckanext-dgu/changeset/5d14f589967f/
changeset: 5d14f589967f
user: dread
date: 2011-08-08 18:51:04
summary: [bin]: #1135 Script to remove National Statistics flag if it is not sourced from ONSHUB.
affected #: 4 files (941 bytes)
--- a/ckanext/dgu/tests/__init__.py Fri Aug 05 12:39:06 2011 +0100
+++ b/ckanext/dgu/tests/__init__.py Mon Aug 08 17:51:04 2011 +0100
@@ -180,6 +180,24 @@
extra_keys = set(dict_to_check.keys()) - set(expected_dict.keys())
assert not extra_keys, 'Keys that should not be there: %r. All unmatching keys: %r' % (extra_keys, unmatching_keys)
+ @classmethod
+ def assert_subset(cls, dict_to_check, expected_dict):
+ '''Takes a package dict_to_check and an expected package dict(expected_dict).
+ Returns ok if the items in the expected_dict are in the dict_to_check. If there
+ are other keys in the dict_to_check then these are ignored.
+
+ '''
+ for key, value in expected_dict.items():
+ if key == 'extras':
+ cls.assert_subset(dict_to_check['extras'], value)
+ else:
+ if value:
+ assert dict_to_check[key] == value, 'Key \'%s\' should be %r not: %r' % (key, value, dict_to_check[key])
+ else:
+ assert not dict_to_check.get(key), 'Key \'%s\' should have no value, not: %s' % (key, dict_to_check[key])
+ missing_keys = set(expected_dict.keys()) - set(dict_to_check.keys())
+ assert not missing_keys, 'Missing keys: %r' % (missing_keys)
+
class DrupalSetupError(Exception):
pass
Repository URL: https://bitbucket.org/okfn/ckanext-dgu/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list