Returning a JSON response on successfully storing the found duplicates.
[Melange.git] / tests / run.py
bloba83f7619a3fa5e31862b5e11a7f6562dafabc2da
1 #!/usr/bin/env python
2 import sys
3 import os
5 HERE = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
6 '..'))
7 appengine_location = os.path.join(HERE, 'thirdparty', 'google_appengine')
8 extra_paths = [HERE,
9 os.path.join(appengine_location, 'lib', 'django'),
10 os.path.join(appengine_location, 'lib', 'webob'),
11 os.path.join(appengine_location, 'lib', 'yaml', 'lib'),
12 appengine_location,
13 os.path.join(HERE, 'app'),
14 os.path.join(HERE, 'thirdparty', 'coverage'),
17 import nose
18 from nose import plugins
20 class AppEngineDatastoreClearPlugin(plugins.Plugin):
21 """Nose plugin to clear the AppEngine datastore between tests.
22 """
23 name = 'AppEngineDatastoreClearPlugin'
24 enabled = True
25 def options(self, parser, env):
26 return plugins.Plugin.options(self, parser, env)
28 def configure(self, parser, env):
29 plugins.Plugin.configure(self, parser, env)
30 self.enabled = True
32 def afterTest(self, test):
33 from google.appengine.api import apiproxy_stub_map
34 datastore = apiproxy_stub_map.apiproxy.GetStub('datastore')
35 datastore.Clear()
38 def main():
39 sys.path = extra_paths + sys.path
40 os.environ['SERVER_SOFTWARE'] = 'Development via nose'
41 os.environ['SERVER_NAME'] = 'Foo'
42 os.environ['SERVER_PORT'] = '8080'
43 os.environ['APPLICATION_ID'] = 'test-app-run'
44 os.environ['USER_EMAIL'] = 'test@example.com'
45 os.environ['CURRENT_VERSION_ID'] = 'testing-version'
46 import main as app_main
47 from google.appengine.api import apiproxy_stub_map
48 from google.appengine.api import datastore_file_stub
49 from google.appengine.api import mail_stub
50 from google.appengine.api import user_service_stub
51 from google.appengine.api import urlfetch_stub
52 from google.appengine.api.memcache import memcache_stub
53 apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
54 apiproxy_stub_map.apiproxy.RegisterStub('urlfetch',
55 urlfetch_stub.URLFetchServiceStub())
56 apiproxy_stub_map.apiproxy.RegisterStub('user',
57 user_service_stub.UserServiceStub())
58 apiproxy_stub_map.apiproxy.RegisterStub('datastore',
59 datastore_file_stub.DatastoreFileStub('your_app_id', None, None))
60 apiproxy_stub_map.apiproxy.RegisterStub('memcache',
61 memcache_stub.MemcacheServiceStub())
62 apiproxy_stub_map.apiproxy.RegisterStub('mail', mail_stub.MailServiceStub())
63 import django.test.utils
64 django.test.utils.setup_test_environment()
65 nose.main(plugins=[AppEngineDatastoreClearPlugin(), ])
68 if __name__ == '__main__':
69 main()