def test_LedgerSerivce_Get_id( stub: alice_pb2_grpc.LedgerStub, mock_worker_bee: alice_pb2.String, mock_run_request: alice_pb2.RunRequest, ): stub.RegisterWorkerBee(mock_worker_bee) ledger_id = stub.Add(mock_run_request) entry = stub.Get(ledger_id) assert ledger_id.id == entry.id
def test_LedgerSerivce_Update_returncode( stub: alice_pb2_grpc.LedgerStub, mock_worker_bee: alice_pb2.String, mock_run_request: alice_pb2.RunRequest, ): """Check that returncode can be set and got.""" stub.RegisterWorkerBee(mock_worker_bee) ledger_id = stub.Add(mock_run_request) stub.Update(alice_pb2.LedgerEntry(id=ledger_id.id, returncode=123)) entry = stub.Get(ledger_id) assert entry.returncode == 123
def test_LedgerService_Add_sequential_ids( stub: alice_pb2_grpc.LedgerStub, mock_worker_bee: alice_pb2.String, mock_run_request: alice_pb2.RunRequest, ): """Ledger entry IDs are sequential.""" stub.RegisterWorkerBee(mock_worker_bee) ledger_id = stub.Add(mock_run_request) assert ledger_id.id == 1 ledger_id = stub.Add(mock_run_request) assert ledger_id.id == 2 ledger_id = stub.Add(mock_run_request) assert ledger_id.id == 3
def test_LedgerService_Add_no_worker_bees( stub: alice_pb2_grpc.LedgerStub, mock_run_request: alice_pb2.RunRequest): """Test that Ledger add fails when no worker bees are registered.""" with test.Raises(Exception) as e_ctx: stub.Add(mock_run_request) assert "No worker bees available" in str(e_ctx.value)
def test_LedgerSerivce_Update_stderr( stub: alice_pb2_grpc.LedgerStub, mock_worker_bee: alice_pb2.String, mock_run_request: alice_pb2.RunRequest, ): """Check that stderr can be set and got.""" stub.RegisterWorkerBee(mock_worker_bee) ledger_id = stub.Add(mock_run_request) stub.Update(alice_pb2.LedgerEntry(id=ledger_id.id, stderr="Hello, stderr!")) entry = stub.Get(ledger_id) assert entry.stderr == "Hello, stderr!" stub.Update(alice_pb2.LedgerEntry(id=ledger_id.id, stderr="abcd")) entry = stub.Get(ledger_id) assert entry.stderr == "abcd"
def test_LedgerService_RegisterWorkerBee_smoke_test( stub: alice_pb2_grpc.LedgerStub, mock_worker_bee: alice_pb2.String): """Worker bee can be registered.""" stub.RegisterWorkerBee(mock_worker_bee) stub.RegisterWorkerBee(mock_worker_bee)