コード例 #1
0
    def test_exception():
        error = Exception("Spurious error.")
        rpc = tasklets.Future()
        rpc.set_exception(error)

        future1, future2 = tasklets.Future(), tasklets.Future()
        _api._process_commit(rpc, [future1, future2])
        assert future1.exception() is error
        assert future2.exception() is error
コード例 #2
0
    def test_exception_some_already_done():
        error = Exception("Spurious error.")
        rpc = tasklets.Future()
        rpc.set_exception(error)

        future1, future2 = tasklets.Future(), tasklets.Future()
        future2.set_result("hi mom")
        _api._process_commit(rpc, [future1, future2])
        assert future1.exception() is error
        assert future2.result() == "hi mom"
コード例 #3
0
    def test_success():
        key1 = mock.Mock(path=["one", "two"], spec=("path", ))
        mutation1 = mock.Mock(key=key1, spec=("key", ))
        key2 = mock.Mock(path=[], spec=("path", ))
        mutation2 = mock.Mock(key=key2, spec=("key", ))
        response = mock.Mock(mutation_results=(mutation1, mutation2),
                             spec=("mutation_results", ))

        rpc = tasklets.Future()
        rpc.set_result(response)

        future1, future2 = tasklets.Future(), tasklets.Future()
        _api._process_commit(rpc, [future1, future2])
        assert future1.result() is key1
        assert future2.result() is None