@@ -53,6 +53,26 @@ def test_constructor_non_default(self):
5353 self .assertEqual (cluster .serve_nodes , serve_nodes )
5454 self .assertTrue (cluster ._client is client )
5555
56+ def test_copy (self ):
57+ project = 'PROJECT'
58+ zone = 'zone'
59+ cluster_id = 'cluster-id'
60+ display_name = 'display_name'
61+ serve_nodes = 8
62+
63+ client = _Client (project )
64+ cluster = self ._makeOne (zone , cluster_id , client ,
65+ display_name = display_name ,
66+ serve_nodes = serve_nodes )
67+ new_cluster = cluster .copy ()
68+
69+ # Make sure the client copy succeeded.
70+ self .assertFalse (new_cluster ._client is client )
71+ self .assertEqual (new_cluster ._client , client )
72+ # Make sure the client got copied to a new instance.
73+ self .assertFalse (cluster is new_cluster )
74+ self .assertEqual (cluster , new_cluster )
75+
5676 def test_table_factory (self ):
5777 from gcloud .bigtable .table import Table
5878
@@ -80,7 +100,7 @@ def test_from_pb_success(self):
80100 cluster_pb = data_pb2 .Cluster (
81101 name = cluster_name ,
82102 display_name = cluster_id ,
83- serve_nodes = 3 ,
103+ serve_nodes = 331 ,
84104 )
85105
86106 klass = self ._getTargetClass ()
@@ -541,3 +561,12 @@ def __init__(self, project, timeout_seconds=None):
541561 self .project = project
542562 self .project_name = 'projects/' + self .project
543563 self .timeout_seconds = timeout_seconds
564+
565+ def copy (self ):
566+ from copy import deepcopy
567+ return deepcopy (self )
568+
569+ def __eq__ (self , other ):
570+ return (other .project == self .project and
571+ other .project_name == self .project_name and
572+ other .timeout_seconds == self .timeout_seconds )
0 commit comments