tests/run.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Sat, 22 Nov 2008 22:44:02 +0000
changeset 568 6713617751b4
parent 421 11aa742bf1dc
child 780 042aafcd7dce
permissions -rw-r--r--
Remove inheritance from PolyModel in Answer and Linkable model. Replace PolyModel inheritance with base.ModelWithFieldAttributes. A little explanation why we are trying to get rid of PolyModel. We decided to use PolyModel in order to get support for model inheritance in App Engine, however as we know this was a hacky workaround which added inheritance_line property to each model. Recent commits which added Linkable model caused our data viewer in admin console to show only one model "Linkable" since all of the classes inherited from it. Basically datastore viewer was useless plus we had a really big mess in datastore since everything was of one kind (Linkable). It's almost like creating one huge table in SQL database. Upcoming commits will eliminate all usage of PolyModel and finally remove PolyModel from our repository. We are still using inheritance however this doesn't modify how models are saved in data store so basically it's like copy and paste of properties from parent models. Patch by: Pawel Solyga, Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
419
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/env python
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     2
import sys
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     3
import os
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     4
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     5
HERE = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     6
                                     '..'))
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     7
appengine_location = os.path.join(HERE, 'thirdparty', 'google_appengine')
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     8
extra_paths = [HERE,
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
     9
               os.path.join(appengine_location, 'lib', 'django'),
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    10
               os.path.join(appengine_location, 'lib', 'webob'),
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    11
               os.path.join(appengine_location, 'lib', 'yaml', 'lib'),
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    12
               appengine_location,
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    13
               os.path.join(HERE, 'app'),
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    14
              ]
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    15
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    16
import nose
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    17
from nose import config
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    18
from nose.plugins import manager
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    19
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    20
def main():
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    21
  sys.path = extra_paths + sys.path
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    22
  os.environ['SERVER_SOFTWARE'] = 'Development via nose'
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    23
  os.environ['SERVER_NAME'] = 'Foo'
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    24
  os.environ['SERVER_PORT'] = '8080'
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    25
  os.environ['APPLICATION_ID'] = 'test-app-run'
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    26
  import main as app_main
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    27
  from google.appengine.api import apiproxy_stub_map
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    28
  from google.appengine.api import datastore_file_stub
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    29
  from google.appengine.api import mail_stub
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    30
  from google.appengine.api import user_service_stub
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    31
  from google.appengine.api import urlfetch_stub
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    32
  apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    33
  apiproxy_stub_map.apiproxy.RegisterStub('urlfetch',
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    34
                                          urlfetch_stub.URLFetchServiceStub())
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    35
  apiproxy_stub_map.apiproxy.RegisterStub('user',
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    36
                                          user_service_stub.UserServiceStub())
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    37
  apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3',
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    38
    datastore_file_stub.DatastoreFileStub('your_app_id', '/dev/null',
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    39
                                          '/dev/null'))
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    40
  apiproxy_stub_map.apiproxy.RegisterStub('mail', mail_stub.MailServiceStub())
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    41
  nose.main(config=config.Config(files=config.all_config_files()))
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    42
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    43
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    44
if __name__ == '__main__':
e9280ea935e4 Start a test system for the webapp itself.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
    45
  main()