Skip to content

Commit

Permalink
Adding families()/regions() methods to HappyBase table.
Browse files Browse the repository at this point in the history
Also adding __repr__. __repr__ is complete, but the other two
are just interfaces. regions() will never be implemented because
it has no equivalent in Cloud Bigtable.
  • Loading branch information
dhermes committed Sep 4, 2015
1 parent b8b5e97 commit fce9338
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gcloud_bigtable/happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,27 @@ class Table(object):
def __init__(self, name, connection):
self.name = name
self.connection = connection

def __repr__(self):
return '<table.Table name=%r>' % (self.name,)

def families(self):
"""Retrieve the column families for this table.
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
temporarily until the method is implemented.
"""
raise NotImplementedError('Temporarily not implemented.')

def regions(self):
"""Retrieve the regions for this table.
Cloud Bigtable does not give information about how a table is laid
out in memory, so regions so this method does not work. It is
provided simply for compatibility.
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
always
"""
raise NotImplementedError('The Cloud Bigtable API does not have a '
'concept of splitting a table into regions.')
22 changes: 22 additions & 0 deletions gcloud_bigtable/happybase/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,25 @@ def test_constructor(self):
table = self._makeOne(name, connection)
self.assertEqual(table.name, name)
self.assertEqual(table.connection, connection)

def test___repr__(self):
name = 'table-name'
connection = object()
table = self._makeOne(name, connection)
self.assertEqual(repr(table), '<table.Table name=\'table-name\'>')

def test_families(self):
name = 'table-name'
connection = object()
table = self._makeOne(name, connection)

with self.assertRaises(NotImplementedError):
table.families()

def test_regions(self):
name = 'table-name'
connection = object()
table = self._makeOne(name, connection)

with self.assertRaises(NotImplementedError):
table.regions()

0 comments on commit fce9338

Please sign in to comment.