def create_test_db(*args, **kw): """Destroys the test datastore. A new store will be recreated on demand""" destroy_test_db() # Ensure the new store that is created uses the test datastore. from django.db import connection connection.use_test_datastore = True connection.flush()
def run_from_argv(self, argv): fixtures = argv[2:] # 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. datastore_path, history_path = get_test_datastore_paths(False) new_args = argv[0:1] new_args.extend(['--datastore_path', datastore_path]) new_args.extend(['--history_path', history_path]) new_args.extend([os.getcwdu()]) # Add email settings from django.conf import settings new_args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Start the test dev_appserver. from google.appengine.tools import dev_appserver_main dev_appserver_main.main(new_args)
def run_from_argv(self, argv): from django.db import connection connection.flush() from django.core.management import call_command call_command("loaddata", "initial_data")
def run_from_argv(self, argv): fixtures = argv[2:] # 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. datastore_path, history_path = get_test_datastore_paths(False) new_args = argv[0:1] new_args.extend(['--datastore_path', datastore_path]) new_args.extend(['--history_path', history_path]) new_args.extend([os.getcwdu()]) # Add email settings from django.conf import settings new_args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Start the test dev_appserver. from google.appengine.tools import dev_appserver_main dev_appserver_main.main(new_args)
def v096_command(*args): """Clears the current datastore. """ # This wrapper function is used instead of passing the real function directly # to Django because Django 0.96 wants to read its docstring and args # attribute for commandline help. from django.db import connection connection.flush()
def v096_command(*args): """Clears the current datastore. """ # This wrapper function is used instead of passing the real function directly # to Django because Django 0.96 wants to read its docstring and args # attribute for commandline help. from django.db import connection connection.flush()
def create_test_db(*args, **kw): """Destroys the test datastore. A new store will be recreated on demand""" destroy_test_db() # Ensure the new store that is created uses the test datastore. from django.db import connection connection.use_test_datastore = True connection.flush()
def v096_command(*args): """Clears the current datastore and loads the initial fixture data. """ # This wrapper function is used instead of passing the real function directly # to Django because Django 0.96 wants to read its docstring and args # attribute for commandline help. from django.db import connection connection.flush() from django.core.management import load_data load_data(['initial_data'])
def v096_command(*args): """Clears the current datastore and loads the initial fixture data. """ # This wrapper function is used instead of passing the real function directly # to Django because Django 0.96 wants to read its docstring and args # attribute for commandline help. from django.db import connection connection.flush() from django.core.management import load_data load_data(['initial_data'])
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)
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)
def run_from_argv(self, argv): from django.db import connection connection.flush()
def populate_datastore(request): """ Populate the datastore with the functional test data. """ if not users.is_current_user_admin(): return HttpResponseRedirect('/?auth=False') # Flush the datastore before starting to make sure that the datastore is # exactly as we want it to be, without duplicate entries, etc., when # testing on the local development server. # (Based on appengine_django.management.commands.flush.py). # Note: requires hack from http://aralbalkan.com/1440 to re-enable os.remove on the local SDK. if IS_DEV: os.remove = os.old_remove connection.flush() del os.remove user = users.get_current_user() stephanie = app1_models.Profile(key_name="stephalicious") stephanie.full_name = "Stephanie King" stephanie.put() paul = app1_models.Profile() paul.full_name = "Paul Booth" paul.put() # Test reference properties with named keys, and ListProperty of Keys: aral = app1_models.Profile() aral.in_relationship_with = stephanie aral.friends = [stephanie.key(), paul.key()] aral.put() # Test reference properties with regular keys stephanie.in_relationship_with = aral stephanie.put() # Test db.UserProperty and db.ReferenceProperty with regular keys. # Also tests required ReferenceProperty instances. google_account_1 = app1_models.GoogleAccount(profile=aral) google_account_1.user = user google_account_1.put() # Test db.UserProperty and db.ReferenceProperty with regular keys. # Also tests required ReferenceProperty instances. google_account_2 = app1_models.GoogleAccount(profile=stephanie) google_account_2.user = user google_account_2.put() # To test all other properties and required properties. all_types_1 = app1_models.AllOtherTypes(string_property=consts.STRING_PROPERTY) all_types_1.put() # To test Expando. plasticMan = app1_models.PlasticMan() plasticMan.secret_identity = "Eel O'Brian" plasticMan.put() # To test ancestors grandFather = app1_models.GrandFather() grandFather.put() father = app1_models.Father(parent=grandFather) father.put() child = app1_models.Child(parent=father) child.put() # Populate app2_models simple = app2_models.Simple() simple.put() return HttpResponse('<p>Successfully populated the datastore.</p><p><a href="/">Home</a></p>')
def run_from_argv(self, argv): from django.db import connection connection.flush()
def run_from_argv(self, argv): from django.db import connection connection.flush() from django.core.management import call_command call_command('loaddata', 'initial_data')