Ejemplo n.º 1
0
  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)
Ejemplo n.º 2
0
  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)
Ejemplo n.º 3
0
 def testTestFilesystemDatastorePath(self):
   """Tests that the test datastore is on the filesystem when requested."""
   td_path, th_path = base.get_test_datastore_paths(False)
   self.assertNotEqual(-1, td_path.find("testdatastore"))
   self.assertNotEqual(-1, th_path.find("testdatastore"))
Ejemplo n.º 4
0
 def testTestInMemoryDatastorePath(self):
   """Tests that the test datastore is using the in-memory datastore."""
   td_path, th_path = base.get_test_datastore_paths()
   self.assertTrue(td_path is None)
   self.assertTrue(th_path is None)
Ejemplo n.º 5
0
def destroy_test_db(*args, **kw):
  """Destroys the test datastore files."""
  destroy_datastore(*get_test_datastore_paths())
  logging.debug("Destroyed test datastore")
Ejemplo n.º 6
0
 def testTestFilesystemDatastorePath(self):
     """Tests that the test datastore is on the filesystem when requested."""
     td_path, th_path = base.get_test_datastore_paths(False)
     self.assertNotEqual(-1, td_path.find("testdatastore"))
     self.assertNotEqual(-1, th_path.find("testdatastore"))
Ejemplo n.º 7
0
 def testTestInMemoryDatastorePath(self):
     """Tests that the test datastore is using the in-memory datastore."""
     td_path, th_path = base.get_test_datastore_paths()
     self.assert_(td_path is None)
     self.assert_(th_path is None)
Ejemplo n.º 8
0
 def destroy_test_db(self, *args, **kw):
   """Destroys the test datastore files."""
   from appengine_django.db.base import destroy_datastore
   from appengine_django.db.base import get_test_datastore_paths
   destroy_datastore(*get_test_datastore_paths())
   logging.debug("Destroyed test datastore")
Ejemplo n.º 9
0
def destroy_test_db(*args, **kw):
    """Destroys the test datastore files."""
    destroy_datastore(*get_test_datastore_paths())
    logging.debug("Destroyed test datastore")
Ejemplo n.º 10
0
 def destroy_test_db(self, *args, **kw):
     """Destroys the test datastore files."""
     from appengine_django.db.base import destroy_datastore
     from appengine_django.db.base import get_test_datastore_paths
     destroy_datastore(*get_test_datastore_paths())
     logging.debug("Destroyed test datastore")