Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding GC Rule to Bigtable Column Family class. #1302

Merged
merged 1 commit into from
Dec 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion gcloud/bigtable/column_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,23 @@ class ColumnFamily(object):

:type table: :class:`Table <gcloud.bigtable.table.Table>`
:param table: The table that owns the column family.

:type gc_rule: :class:`GarbageCollectionRule`
:param gc_rule: (Optional) The garbage collection settings for this
column family.
"""

def __init__(self, column_family_id, table):
def __init__(self, column_family_id, table, gc_rule=None):
self.column_family_id = column_family_id
self._table = table
self.gc_rule = gc_rule

def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
return (other.column_family_id == self.column_family_id and
other._table == self._table and
other.gc_rule == self.gc_rule)

def __ne__(self, other):
return not self.__eq__(other)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

35 changes: 34 additions & 1 deletion gcloud/bigtable/test_column_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,40 @@ def _makeOne(self, *args, **kwargs):
def test_constructor(self):
column_family_id = u'column-family-id'
table = object()
column_family = self._makeOne(column_family_id, table)
gc_rule = object()
column_family = self._makeOne(column_family_id, table, gc_rule=gc_rule)

self.assertEqual(column_family.column_family_id, column_family_id)
self.assertTrue(column_family._table is table)
self.assertTrue(column_family.gc_rule is gc_rule)

def test___eq__(self):
column_family_id = 'column_family_id'
table = object()
gc_rule = object()
column_family1 = self._makeOne(column_family_id, table,
gc_rule=gc_rule)
column_family2 = self._makeOne(column_family_id, table,
gc_rule=gc_rule)
self.assertEqual(column_family1, column_family2)

def test___eq__type_differ(self):
column_family1 = self._makeOne('column_family_id', None)
column_family2 = object()
self.assertNotEqual(column_family1, column_family2)

def test___ne__same_value(self):
column_family_id = 'column_family_id'
table = object()
gc_rule = object()
column_family1 = self._makeOne(column_family_id, table,
gc_rule=gc_rule)
column_family2 = self._makeOne(column_family_id, table,
gc_rule=gc_rule)
comparison_val = (column_family1 != column_family2)
self.assertFalse(comparison_val)

def test___ne__(self):
column_family1 = self._makeOne('column_family_id1', None)
column_family2 = self._makeOne('column_family_id2', None)
self.assertNotEqual(column_family1, column_family2)