Skip to content
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
13 changes: 13 additions & 0 deletions gcloud/bigtable/happybase/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"""Google Cloud Bigtable HappyBase connection module."""


import six


# Constants reproduced here for HappyBase compatibility, though values
# are all null.
COMPAT_MODES = None
Expand Down Expand Up @@ -97,6 +100,16 @@ def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, timeout=None,
raise ValueError('Protocol cannot be set for gcloud '
'HappyBase module')

if table_prefix is not None:
if not isinstance(table_prefix, six.string_types):

This comment was marked as spam.

This comment was marked as spam.

raise TypeError('table_prefix must be a string', 'received',
table_prefix, type(table_prefix))

if not isinstance(table_prefix_separator, six.string_types):
raise TypeError('table_prefix_separator must be a string',
'received', table_prefix_separator,
type(table_prefix_separator))

self.timeout = timeout
self.autoconnect = autoconnect
self.table_prefix = table_prefix
Expand Down
14 changes: 14 additions & 0 deletions gcloud/bigtable/happybase/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,17 @@ def test_constructor_with_transport(self):
def test_constructor_with_protocol(self):
with self.assertRaises(ValueError):
self._makeOne(protocol=object())

def test_constructor_non_string_prefix(self):
table_prefix = object()

with self.assertRaises(TypeError):
self._makeOne(autoconnect=False,
table_prefix=table_prefix)

def test_constructor_non_string_prefix_separator(self):
table_prefix_separator = object()

with self.assertRaises(TypeError):
self._makeOne(autoconnect=False,
table_prefix_separator=table_prefix_separator)