示例#1
0
def guiDelete():
    logging.basicConfig(level=logging.DEBUG)
    with grpc.insecure_channel("localhost:50051") as channel:
        stub = task_pb2_grpc.TaskapiStub(channel)
        i = int(e2.get())
        response = stub.delTask(task_pb2.Id(id=i))
        response1 = stub.listTasks(task_pb2.Empty())
        l3.configure(text=str(f"Task list \n{response1.tasks}"))
示例#2
0
def guiAdd():
    logging.basicConfig(level=logging.DEBUG)
    with grpc.insecure_channel("localhost:50051") as channel:
        stub = task_pb2_grpc.TaskapiStub(channel)
        # Code to add widgets will go here...
        desc = e1.get()
        response = stub.addTask(task_pb2.TaskDesc(description=desc))
        response1 = stub.listTasks(task_pb2.Empty())
        l3.configure(text=str(f"Task list \n{response1.tasks}"))
        tasks[response.id] = [name1, name2, tanks]
        print("\n")
    return tasks


# Test that will be used to grade listTask
def test_list(stub, tasks) -> None:
    response = stub.listClients(task_pb2.Empty())

    for t in response.clients:
        # Is the proper task desc is returned for this id?
        print(t)


# Test that will be used to grade delTask
def test_del(stub, task_ids) -> None:
    print("Deleting Clients\n")
    for i in task_ids:
        stub.delClient(task_pb2.Id(id=i))


if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    with grpc.insecure_channel("54.84.225.29:8080") as channel:
        stub = task_pb2_grpc.TaskapiStub(channel)

        tasks = test_add(stub, 3)
        logging.info(f"added tasks {tasks}")
        test_list(stub, tasks)
        test_del(stub, tasks.keys())