Skip to content

Commit

Permalink
Updating unit tests that failed after fixing system tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Dec 16, 2015
1 parent f168b90 commit 5c6680d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
28 changes: 14 additions & 14 deletions gcloud_bigtable/happybase/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def _makeOne(self, *args, **kwargs):

def test_constructor_defaults(self):
cluster = _Cluster() # Avoid implicit environ check.
self.assertEqual(cluster.client.start_calls, 0)
self.assertEqual(cluster._client.start_calls, 0)
connection = self._makeOne(cluster=cluster)
self.assertEqual(cluster.client.start_calls, 1)
self.assertEqual(cluster.client.stop_calls, 0)
self.assertEqual(cluster._client.start_calls, 1)
self.assertEqual(cluster._client.stop_calls, 0)

self.assertEqual(connection._cluster, cluster)
self.assertEqual(connection.table_prefix, None)
Expand Down Expand Up @@ -243,35 +243,35 @@ def test_constructor_with_timeout_and_cluster(self):
def test_open(self):
cluster = _Cluster() # Avoid implicit environ check.
connection = self._makeOne(autoconnect=False, cluster=cluster)
self.assertEqual(cluster.client.start_calls, 0)
self.assertEqual(cluster._client.start_calls, 0)
connection.open()
self.assertEqual(cluster.client.start_calls, 1)
self.assertEqual(cluster.client.stop_calls, 0)
self.assertEqual(cluster._client.start_calls, 1)
self.assertEqual(cluster._client.stop_calls, 0)

def test_close(self):
cluster = _Cluster() # Avoid implicit environ check.
connection = self._makeOne(autoconnect=False, cluster=cluster)
self.assertEqual(cluster.client.stop_calls, 0)
self.assertEqual(cluster._client.stop_calls, 0)
connection.close()
self.assertEqual(cluster.client.stop_calls, 1)
self.assertEqual(cluster.client.start_calls, 0)
self.assertEqual(cluster._client.stop_calls, 1)
self.assertEqual(cluster._client.start_calls, 0)

def test___del__good_initialization(self):
cluster = _Cluster() # Avoid implicit environ check.
connection = self._makeOne(autoconnect=False, cluster=cluster)
self.assertEqual(cluster.client.stop_calls, 0)
self.assertEqual(cluster._client.stop_calls, 0)
connection.__del__()
self.assertEqual(cluster.client.stop_calls, 1)
self.assertEqual(cluster._client.stop_calls, 1)

def test___del__bad_initialization(self):
cluster = _Cluster() # Avoid implicit environ check.
connection = self._makeOne(autoconnect=False, cluster=cluster)
# Fake that initialization failed.
del connection._initialized

self.assertEqual(cluster.client.stop_calls, 0)
self.assertEqual(cluster._client.stop_calls, 0)
connection.__del__()
self.assertEqual(cluster.client.stop_calls, 0)
self.assertEqual(cluster._client.stop_calls, 0)

def test__table_name_with_prefix_set(self):
table_prefix = 'table-prefix'
Expand Down Expand Up @@ -529,7 +529,7 @@ class _Cluster(object):
def __init__(self, copies=(), list_tables_result=()):
self.copies = list(copies)
# Included to support Connection.__del__
self.client = _Client()
self._client = _Client()
self.list_tables_result = list_tables_result

def copy(self):
Expand Down
2 changes: 1 addition & 1 deletion gcloud_bigtable/happybase/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class _Cluster(object):
def __init__(self, copies=()):
self.copies = list(copies)
# Included to support Connection.__del__
self.client = _Client()
self._client = _Client()

def copy(self):
if self.copies:
Expand Down
14 changes: 12 additions & 2 deletions gcloud_bigtable/test_column_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ def test_client_getter(self):

def test_timeout_seconds_getter(self):
timeout_seconds = 889
table = _Table(None, timeout_seconds=timeout_seconds)
client = _Client(timeout_seconds=timeout_seconds)
table = _Table(None, client=client)
column_family = self._makeOne(COLUMN_FAMILY_ID, table)
self.assertEqual(column_family.timeout_seconds, timeout_seconds)

Expand Down Expand Up @@ -573,10 +574,19 @@ class _Client(object):
operations_stub = None
table_stub = None

def __init__(self, timeout_seconds=None):
self.timeout_seconds = timeout_seconds


class _Cluster(object):

def __init__(self, client=None):
self._client = client


class _Table(object):

def __init__(self, name, client=None, timeout_seconds=None):
self.name = name
self.client = client
self._cluster = _Cluster(client)
self.timeout_seconds = timeout_seconds
14 changes: 12 additions & 2 deletions gcloud_bigtable/test_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def test_client_getter(self):

def test_timeout_seconds_getter(self):
timeout_seconds = 889
table = _Table(None, timeout_seconds=timeout_seconds)
client = _Client(timeout_seconds=timeout_seconds)
table = _Table(None, client=client)
row = self._makeOne(ROW_KEY, table)
self.assertEqual(row.timeout_seconds, timeout_seconds)

Expand Down Expand Up @@ -1526,10 +1527,19 @@ class _Client(object):

data_stub = None

def __init__(self, timeout_seconds=None):
self.timeout_seconds = timeout_seconds


class _Cluster(object):

def __init__(self, client=None):
self._client = client


class _Table(object):

def __init__(self, name, client=None, timeout_seconds=None):
self.name = name
self.client = client
self._cluster = _Cluster(client)
self.timeout_seconds = timeout_seconds
2 changes: 1 addition & 1 deletion pylintrc_default
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ no-space-check =
# Maximum number of lines in a module
# DEFAULT: max-module-lines=1000
# RATIONALE: API-mapping
max-module-lines=1540
max-module-lines=1545

# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
Expand Down

0 comments on commit 5c6680d

Please sign in to comment.