Skip to content

Commit

Permalink
Include unset keys in config obj keys
Browse files Browse the repository at this point in the history
Also add test to check unset fields
  • Loading branch information
dakoop committed Jan 7, 2015
1 parent 45c0610 commit 320073b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions vistrails/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import argparse
import ast
import copy
import itertools
import re
import shlex
import sys
Expand Down Expand Up @@ -1438,14 +1439,15 @@ def allkeys(self):
Returns all options stored in this object.
"""

return self.db_config_keys_name_index.keys()
return self.db_config_keys_name_index.keys() + self._unset_keys.keys()

def keys(self):
"""keys(self) -> list of strings
Returns all public options stored in this object.
Public options are keys that do not start with a _
"""
return [k for k in self.db_config_keys_name_index
return [k for k in itertools.chain(self.db_config_keys_name_index,
self._unset_keys)
if not k.startswith('_')]

# def default():
Expand Down Expand Up @@ -1665,6 +1667,11 @@ def test_update(self):
conf2.showWindow = False
self.assertTrue(conf1.showWindow)

def test_unset_params(self):
conf = ConfigurationObject(test_field=(None, str))
self.assertTrue(conf.is_unset("test_field"))
self.assertIn("test_field", conf.keys())

def test_type_mismatch(self):
conf = default()
with self.assertRaises(TypeError):
Expand Down

0 comments on commit 320073b

Please sign in to comment.