简体   繁体   English

AppEngine python 单元测试任务队列

[英]AppEngine python unittest task queue

I have a AppEngine application that exposes some APIs.我有一个公开一些 API 的 AppEngine 应用程序。 Right now I'm writing tests for those APIs but some of them enqueue tasks.现在我正在为这些 API 编写测试,但其中一些将任务排入队列。 I'm not sure how I can write a test case that waits for all the tasks that certain API call enqueued to finish.我不确定如何编写一个测试用例来等待某些 API 调用排队完成的所有任务。

Any ideas how within a test itself I can verify that certain tasks have finished?任何想法如何在测试本身中验证某些任务是否已完成?

I assume you are using testbed .我假设您正在使用testbed

Within testbed, enqueued tasks sit there until you execute them yourself.在 testbed 中,排队的任务会一直存在,直到您自己执行它们。 Since the test environment is single threaded, you manually execute the tasks in the queue and you know exactly when they are done.由于测试环境是单线程的,您手动执行队列中的任务并且您确切知道它们何时完成。

This answer shows you how to manually execute tasks.答案向您展示了如何手动执行任务。

The SDK comes with a testbed for some APIs , taskqueue is one of them. SDK 带有一些 API的测试平台,taskqueue 就是其中之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM