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

Testing cleanups #49

Merged
merged 4 commits into from
Oct 15, 2018
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
7 changes: 3 additions & 4 deletions src/google/cloud/happybase/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
_WAL_SENTINEL = object()
# Assumed granularity of timestamps in Cloud Bigtable.
_ONE_MILLISECOND = datetime.timedelta(microseconds=1000)
_WARN = warnings.warn
_WAL_WARNING = ('The wal argument (Write-Ahead-Log) is not '
'supported by Cloud Bigtable.')

Expand Down Expand Up @@ -76,7 +75,7 @@ class Batch(object):
def __init__(self, table, timestamp=None, batch_size=None,
transaction=False, wal=_WAL_SENTINEL):
if wal is not _WAL_SENTINEL:
_WARN(_WAL_WARNING)
warnings.warn(_WAL_WARNING)

if batch_size is not None:
if transaction:
Expand Down Expand Up @@ -156,7 +155,7 @@ def put(self, row, data, wal=_WAL_SENTINEL):
Write Ahead Log.
"""
if wal is not _WAL_SENTINEL:
_WARN(_WAL_WARNING)
warnings.warn(_WAL_WARNING)

row_object = self._get_row(row)
# Make sure all the keys are valid before beginning
Expand Down Expand Up @@ -227,7 +226,7 @@ def delete(self, row, columns=None, wal=_WAL_SENTINEL):
current batch, but a full row delete is attempted.
"""
if wal is not _WAL_SENTINEL:
_WARN(_WAL_WARNING)
warnings.warn(_WAL_WARNING)

row_object = self._get_row(row)

Expand Down
15 changes: 7 additions & 8 deletions src/google/cloud/happybase/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
DEFAULT_PROTOCOL = None

_LEGACY_ARGS = frozenset(('host', 'port', 'compat', 'transport', 'protocol'))
_WARN = warnings.warn
_BASE_DISABLE = 'Cloud Bigtable has no concept of enabled / disabled tables.'
_DISABLE_DELETE_MSG = ('The disable argument should not be used in '
'delete_table(). ') + _BASE_DISABLE
Expand Down Expand Up @@ -194,7 +193,7 @@ def _handle_legacy_args(arguments_dict):
all_args = ', '.join(common_args)
message = ('The HappyBase legacy arguments %s were used. These '
'arguments are unused by google-cloud.' % (all_args,))
_WARN(message)
warnings.warn(message)
for arg_name in common_args:
arguments_dict.pop(arg_name)
if arguments_dict:
Expand Down Expand Up @@ -356,7 +355,7 @@ def delete_table(self, name, disable=False):
of enabled / disabled tables.
"""
if disable:
_WARN(_DISABLE_DELETE_MSG)
warnings.warn(_DISABLE_DELETE_MSG)

name = self._table_name(name)
_LowLevelTable(name, self._instance).delete()
Expand All @@ -373,7 +372,7 @@ def enable_table(name):
:type name: str
:param name: The name of the table to be enabled.
"""
_WARN(_ENABLE_TMPL % (name,))
warnings.warn(_ENABLE_TMPL % (name,))

@staticmethod
def disable_table(name):
Expand All @@ -387,7 +386,7 @@ def disable_table(name):
:type name: str
:param name: The name of the table to be disabled.
"""
_WARN(_DISABLE_TMPL % (name,))
warnings.warn(_DISABLE_TMPL % (name,))

@staticmethod
def is_table_enabled(name):
Expand All @@ -405,7 +404,7 @@ def is_table_enabled(name):
:rtype: bool
:returns: The value :data:`True` always.
"""
_WARN(_IS_ENABLED_TMPL % (name,))
warnings.warn(_IS_ENABLED_TMPL % (name,))
return True

@staticmethod
Expand All @@ -424,7 +423,7 @@ def compact_table(name, major=False):
:type major: bool
:param major: Whether to perform a major compaction.
"""
_WARN(_COMPACT_TMPL % (name, major))
warnings.warn(_COMPACT_TMPL % (name, major))


def _parse_family_option(option):
Expand Down Expand Up @@ -452,7 +451,7 @@ def _parse_family_option(option):
warning_msg = ('Cloud Bigtable only supports max_versions and '
'time_to_live column family settings. '
'Received: %s' % (all_keys,))
_WARN(warning_msg)
warnings.warn(warning_msg)

max_num_versions = result.get('max_versions')
max_age = None
Expand Down
3 changes: 1 addition & 2 deletions src/google/cloud/happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from google.cloud.happybase.batch import Batch


_WARN = warnings.warn
_PACK_I64 = struct.Struct('>q').pack
_UNPACK_I64 = struct.Struct('>q').unpack
_SIMPLE_GC_RULES = (MaxAgeGCRule, MaxVersionsGCRule)
Expand Down Expand Up @@ -885,7 +884,7 @@ def _scan_filter_helper(row_start, row_stop, row_prefix, columns,
legacy_args = ', '.join(legacy_args)
message = ('The HappyBase legacy arguments %s were used. These '
'arguments are unused by google-cloud.' % (legacy_args,))
_WARN(message)
warnings.warn(message)
if kwargs:
raise TypeError('Received unexpected arguments', kwargs.keys())

Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ envlist =
[testing]
deps =
pytest
mock
covercmd =
py.test --quiet \
--cov=google.cloud.happybase \
Expand Down
Loading