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 0f5d8d4 commit 1fdd8c6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,31 @@ def test_handle_error_without_status():
handle_error(call)

assert excinfo.value == call
def test_get_grid_points():
client, local = make_bmi_classes(True)
varname = local.get_output_var_names()[0]
grid_id = local.get_var_grid(varname)
local_x = [] if local.get_grid_x(grid_id) is None else numpy.array(local.get_grid_x(grid_id))
local_y = [] if local.get_grid_y(grid_id) is None else numpy.array(local.get_grid_y(grid_id))
local_z = [] if local.get_grid_z(grid_id) is None else numpy.array(local.get_grid_z(grid_id))
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 1fdd8c6

Please sign in to comment.