Beispiel #1
0
    def run_from_argv(self, argv):
        fixtures = []
        for arg in argv[2:]:
            if arg.startswith('-'):
                break
            fixtures.append(arg)
            argv.remove(arg)

        try:
            index = argv.index('--addrport')
            addrport = argv[index + 1]
            del argv[index:index+2]
            argv = argv[:2] + [addrport] + argv[2:index] + argv[index+1:]
        except:
            pass

        # Ensure an on-disk test datastore is used.
        from django.db import connection
        connection.use_test_datastore = True
        connection.test_datastore_inmemory = False

        # Flush any existing test datastore.
        connection.flush()

        # Load the fixtures.
        from django.core.management import call_command
        call_command('loaddata', 'initial_data')
        if fixtures:
            call_command('loaddata', *fixtures)

        # Build new arguments for dev_appserver.
        argv[1] = 'runserver'
        datastore_path, history_path = get_test_datastore_paths(False)
        argv.extend(['--datastore_path', datastore_path])
        argv.extend(['--history_path', history_path])

        start_dev_appserver(argv)
Beispiel #2
0
 def destroy_test_db(self, *args, **kw):
   """Destroys the test datastore files."""
   from django.db.backends.appengine.base import destroy_datastore, \
       get_test_datastore_paths
   destroy_datastore(*get_test_datastore_paths())