Commit 9c007088 authored by abuddenberg's avatar abuddenberg
Browse files

Fixed subtle property accessor bug in Gcisbase class stemming from excessive...

Fixed subtle property accessor bug in Gcisbase class stemming from excessive cleverness creating attributes and properties on subclasses.
Added assertions to test suite
parent 04bdbd7c
...@@ -47,7 +47,7 @@ class Gcisbase(object): ...@@ -47,7 +47,7 @@ class Gcisbase(object):
def as_json(self, indent=0, omit_fields=[]): def as_json(self, indent=0, omit_fields=[]):
out_fields = set(self.gcis_fields) - (set(['uri', 'href']) | set(omit_fields)) out_fields = set(self.gcis_fields) - (set(['uri', 'href']) | set(omit_fields))
return json.dumps({f: self.__dict__[f] for f in out_fields}, indent=indent) return json.dumps({f: getattr(self, f) for f in out_fields}, indent=indent)
class Figure(Gcisbase): class Figure(Gcisbase):
......
...@@ -84,6 +84,11 @@ def test_dataset_special_properties(): ...@@ -84,6 +84,11 @@ def test_dataset_special_properties():
ds.publication_year = 'TBD' ds.publication_year = 'TBD'
assert ds.publication_year is None assert ds.publication_year is None
assert ds.access_dt == '2011-12-31T00:00:00'
#This one was subtle. Make sure as_json() still works with properties.
ds_json_out = json.loads(ds.as_json())
assert ds_json_out['access_dt'] == '2011-12-31T00:00:00'
if __name__ == '__main__': if __name__ == '__main__':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment