Skip to content

Commit

Permalink
Making _gc_rule_to_dict map null to empty dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Sep 7, 2015
1 parent 572190c commit ae9bc33
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gcloud_bigtable/happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def _gc_rule_to_dict(gc_rule):
Otherwise, just returns the input without change.
:type gc_rule: :class:`.GarbageCollectionRule`,
:type gc_rule: :data:`NoneType <types.NoneType>`,
:class:`.GarbageCollectionRule`,
:class:`.GarbageCollectionRuleIntersection`, or
:class:`.GarbageCollectionRuleUnion`
:param gc_rule: A garbae collection rule to convert to a dictionary
Expand All @@ -97,7 +98,9 @@ def _gc_rule_to_dict(gc_rule):
:returns: The converted garbage collection rule.
"""
result = gc_rule
if isinstance(gc_rule, GarbageCollectionRule):
if gc_rule is None:
result = {}
elif isinstance(gc_rule, GarbageCollectionRule):
result = {}
# We assume that the GC rule has a single value.
if gc_rule.max_num_versions is not None:
Expand Down
5 changes: 5 additions & 0 deletions gcloud_bigtable/happybase/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def _callFUT(self, gc_rule):
from gcloud_bigtable.happybase.table import _gc_rule_to_dict
return _gc_rule_to_dict(gc_rule)

def test_with_null(self):
gc_rule = None
result = self._callFUT(gc_rule)
self.assertEqual(result, {})

def test_with_max_versions(self):
from gcloud_bigtable.column_family import GarbageCollectionRule

Expand Down

0 comments on commit ae9bc33

Please sign in to comment.