http://code.google.com/p/appengine-afterburner/source/detail?r=8
Added:
/trunk/python/src/afterburner/testing
/trunk/python/src/afterburner/testing/__init__.py
/trunk/python/src/afterburner/testing/test_base.py
Modified:
/trunk/python/src/afterburner/experimental/db/triggers.py
/trunk/python/src/afterburner/experimental/db/triggers_test.py
/trunk/python/src/afterburner/util.py
=======================================
--- /dev/null
+++ /trunk/python/src/afterburner/testing/__init__.py Mon Nov 8 03:14:27
2010
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+#
+# Copyright 2010 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
=======================================
--- /dev/null
+++ /trunk/python/src/afterburner/testing/test_base.py Mon Nov 8 03:14:27
2010
@@ -0,0 +1,24 @@
+import os
+import unittest
+
+from google.appengine.api.labs.taskqueue import taskqueue_stub
+from google.appengine.api import apiproxy_stub_map
+from google.appengine.api import datastore_file_stub
+
+class TestBase(unittest.TestCase):
+ """Base class for appengine tests."""
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+
+ self.appid = "testapp"
+ os.environ["APPLICATION_ID"] = self.appid
+ self.taskqueue = taskqueue_stub.TaskQueueServiceStub()
+ self.datastore = datastore_file_stub.DatastoreFileStub(
+ self.appid, "/dev/null", "/dev/null")
+
+ apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
+ apiproxy_stub_map.apiproxy.RegisterStub("taskqueue", self.taskqueue)
+ apiproxy_stub_map.apiproxy.RegisterStub("datastore_v3", self.datastore)
+
+
=======================================
--- /trunk/python/src/afterburner/experimental/db/triggers.py Fri Nov 5
21:22:06 2010
+++ /trunk/python/src/afterburner/experimental/db/triggers.py Mon Nov 8
03:14:27 2010
@@ -27,9 +27,9 @@
It is important to remember that:
-* Triggers won't be fired if you change your code not from the app itself
(e.g.
+* Triggers won't be fired if you change your data not from the app itself
(e.g.
admin console).
-* There might be a delay (sometimes significant) before actual data change
and
+* There might be a delay (sometimes even minute) between actual data
change and
trigger execution.
* Trigger executions for a single entity are batched. I.e. if you change
entity
quickly multiple times you'll most likely get your trigger function
called
@@ -253,6 +253,7 @@
@classmethod
def register_trigger(cls, entity_kind, function_name):
+ # TODO: double registration
cls.triggers[entity_kind] = (
cls.triggers.get(entity_kind, []) + [function_name])
=======================================
--- /trunk/python/src/afterburner/experimental/db/triggers_test.py Fri Nov
5 21:22:06 2010
+++ /trunk/python/src/afterburner/experimental/db/triggers_test.py Mon Nov
8 03:14:27 2010
@@ -20,10 +20,8 @@
import urllib
from afterburner.experimental.db import triggers
+from afterburner.testing import test_base
from google.appengine.ext import db
-from google.appengine.api.labs.taskqueue import taskqueue_stub
-from google.appengine.api import apiproxy_stub_map
-from google.appengine.api import datastore_file_stub
class Foo(db.Model):
@@ -50,22 +48,11 @@
return dict((key, urllib.unquote_plus(value)) for key, value in
key_values)
-class TriggersTestCase(unittest.TestCase):
+class TriggersTestCase(test_base.TestBase):
"""Base class for triggers tests."""
def setUp(self):
- unittest.TestCase.setUp(self)
- # TODO: extract setup code to some reusable module
- self.appid = "testapp"
- os.environ["APPLICATION_ID"] = self.appid
- self.taskqueue = taskqueue_stub.TaskQueueServiceStub()
- self.datastore = datastore_file_stub.DatastoreFileStub(
- self.appid, "/dev/null", "/dev/null")
-
- apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
- apiproxy_stub_map.apiproxy.RegisterStub("taskqueue", self.taskqueue)
- apiproxy_stub_map.apiproxy.RegisterStub("datastore_v3", self.datastore)
-
+ super(TriggersTestCase, self).setUp()
triggers.TriggerManager.init()
=======================================
--- /trunk/python/src/afterburner/util.py Fri Nov 5 21:22:06 2010
+++ /trunk/python/src/afterburner/util.py Mon Nov 8 03:14:27 2010
@@ -16,6 +16,8 @@
"""Set of generally usefull utilities."""
+import sys
+
def for_name(fq_name, recursive=False):
"""Find class/function/method specified by its fully qualified name.