2012-07-24 68 views
0

我剛剛通過我的功能測試沒有使用我的dev_appserver相同的設置。我目前使用require_indexes運行我的dev_appserver(非rel)。谷歌應用程序引擎要求測試索引

如何強制我的測試牀使用相同的設置?

我嘗試過使用SetupIndexes,但它沒有「要求」它們在我的index.yaml中定義。我沒有正確的設置,因此我可以做任何我想要的查詢。

clz.testbed = Testbed() 
clz.testbed.activate() 
clz.testbed.init_memcache_stub() 
clz.testbed.init_taskqueue_stub() 
clz.testbed.init_urlfetch_stub() 
clz.testbed.init_datastore_v3_stub(use_sqlite=True, datastore_file=somepath) 
SetupIndexes('','') 

model.objects().filter(x=1, y=2.....) #will work regardless of index defined. 

但在查詢服務器上執行我得到的

NeedIndexError: This query requires a composite index that is not defined. You must update the index.yaml file in your application root. The following index is the minimum index required:

+0

這聽起來像你有你的功能測試儀器dev_appserver代碼直接設置你的測試環境。是這樣嗎?如果是這樣,是否有一個原因,你不能使用ext.testbed? (我不確定如何根據索引配置獲得測試牀以引發NeedIndexError,雖然它可以配置爲使用特定的數據存儲數據文件,所以也許它可以在給定的情況下工作...)另外,通過「objects()」你的意思是ext.db的「all()」方法,還是這是一個不同的數據倉庫API? – 2012-07-24 01:33:55

+0

不確定關注?我只是ext測試,但它不需要索引。 – Nix 2012-07-24 01:34:38

+0

所以你使用'ext.testbed',但它會在每個查詢中引發'NeedIndexError'?你可以發佈一些你的測試設置代碼嗎? – 2012-07-24 01:37:42

回答

2

嘗試增加{ 「require_indexes」:真正}作爲關鍵字參數init_datastore_v3_stub()

您可以查看(並逐步完成)SDK代碼,以查看該參數最終如何傳遞到數據存儲區存根。

+0

您的建議可行,但需要注意的是您必須設置root_path,否則您將沒有定義索引。 – Nix 2012-07-24 16:42:41