Skip to content

Commit

Permalink
Added tests for create_grpc_channel
Browse files Browse the repository at this point in the history
Refs #63
  • Loading branch information
sverhoeven committed Mar 13, 2020
1 parent 12d7414 commit 3c7c078
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,21 @@ def test_get_grid_points():
assert numpy.array_equal(client.get_grid_x(grid_id), local_x)
assert numpy.array_equal(client.get_grid_y(grid_id), local_y)
assert numpy.array_equal(client.get_grid_z(grid_id), local_z)


class TestCreateGrpcChannel:
def test_defaults(self):
with BmiClient.create_grpc_channel() as channel:
target = channel._channel.target()
assert target == b'localhost:50051'

def test_custom(self):
with BmiClient.create_grpc_channel(51234, 'somehost') as channel:
target = channel._channel.target()
assert target == b'somehost:51234'

def test_same_port_twice(self):
port = 51235
with BmiClient.create_grpc_channel(port) as channel1, BmiClient.create_grpc_channel(port) as channel2:
assert channel1._channel.target() == b'localhost:51235'
assert channel2._channel.target() == b'localhost:51235'

0 comments on commit 3c7c078

Please sign in to comment.