Permalink
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (21 sloc) 1.42 KB
#-*- coding:utf-8 -*-
import unittest
from simple_db_migrate.core.exceptions import MigrationException
class MigrationExceptionTest(unittest.TestCase):
def test_it_should_use_default_message(self):
exception = MigrationException()
self.assertEqual('error executing migration', str(exception))
def test_it_should_use_custom_message(self):
exception = MigrationException('custom error message')
self.assertEqual('custom error message', str(exception))
def test_it_should_use_default_message_and_sql_command(self):
exception = MigrationException(sql='sql command executed')
self.assertEqual('error executing migration\n\n[ERROR DETAILS] SQL command was:\nsql command executed', str(exception))
def test_it_should_use_custom_message_and_sql_command(self):
exception = MigrationException(sql='sql command executed', msg='custom error message')
self.assertEqual('custom error message\n\n[ERROR DETAILS] SQL command was:\nsql command executed', str(exception))
def test_it_should_encode_error_message(self):
exception = MigrationException(sql=u'sql command executed with special chars çõá', msg=u'custom error message with special chars öá')
self.assertEqual('custom error message with special chars öá\n\n[ERROR DETAILS] SQL command was:\nsql command executed with special chars çõá', str(exception))
if __name__ == '__main__':
unittest.main()