Hi Django Gurus,

I am trying to execute a transactional test and I see this problem:

Error: Database moglog couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL
this command wasn't able to run.
The full error: (1146, "Table 'moglog.south_migrationhistory' doesn't
exist")

I am trying to update one column (source code/unit tests given below).
Hopefully after the test has been executed, all changes would be
rolled back. Is there a way to avoid flushing the database before
executing the test. Any assistance would be appreciated.

I have a source code that runs updates one column in the table. I am
trying to test this code.

def SoftDeleteExistingRackTypes(attributes):
  soft_delete_count = 0  # number of soft deletes.
  rack_type_name = attributes.get('name')
  fetched_rack_types = \
 
models.RackType.objects.filter(name__iexact=rack_type_name).distinct()
  for fetched_rack_type in fetched_rack_types:
    fetched_rack_type.delete_flag=True
    soft_delete_count+=1
    fetched_rack_type.save()
  return soft_delete_count

My unit test is given below:

class TransactionalTest(test.TransactionTestCase):
  """Test actual database calls.

  This call leverages django's transaction api.
  """

  def setUp(self):
    super(TransactionalTest, self).setUp()
    transaction.enter_transaction_management()
    transaction.managed(True)

  def testSoftDeleteExistingRackTypes(self):
    """Test soft delete of rack type."""
    # Just take the first one.
    attributes = FAKE_ATTRIBUTE_LIST[0]
    count =
rack_type_dimension_update.SoftDeleteExistingRackTypes(attributes)
    self.assertTrue(count > 0, 'Should have atleast one valid value')


  def tearDown(self):
    super(TransactionalTest, self).tearDown()
    if transaction.is_dirty():
      transaction.rollback()
    transaction.leave_transaction_management()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to