Skip to content

Commit

Permalink
fix: tests.functional.test_vpc:test_deploy_vpc with json state -> Typ…
Browse files Browse the repository at this point in the history
…eError expected string or buffer
  • Loading branch information
srghma committed Jun 16, 2018
1 parent 59c33cd commit e1b9158
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nixops/state/state_helper.py
Expand Up @@ -25,12 +25,18 @@ def __setitem__(self, key, value):

def __getitem__(self, key):
value = self._state.get_resource_attr(self.uuid, self.id, key)
if value != nixops.util.undefined:

if value == nixops.util.undefined:
raise KeyError("couldn't find key {} in the state file".format(key))

if isinstance(value, str):
try:
return json.loads(value)
except ValueError:
return value
raise KeyError("couldn't find key {} in the state file".format(key))

return value


def __delitem__(self, key):
self._state.del_resource_attr(self.uuid, self.id, key)
Expand Down

0 comments on commit e1b9158

Please sign in to comment.