Skip postgresql and mysql tests.
Gbp-Pq: Name 0001-Skip-postgresql-and-mysql-tests.patch
This commit is contained in:
parent
cbad914fe4
commit
ac62f49bc2
|
@ -1,3 +1,4 @@
|
||||||
|
import unittest
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -12,6 +13,16 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
|
|
||||||
|
try:
|
||||||
|
import psycopg2
|
||||||
|
except ImportError:
|
||||||
|
psycopg2 = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
import MySQLdb
|
||||||
|
except ImportError:
|
||||||
|
MySQLdb = None
|
||||||
|
|
||||||
|
|
||||||
class SaveTest(TestModelMixin, TestBase):
|
class SaveTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@ -159,6 +170,8 @@ class CreateRevisionManageManuallyTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class CreateRevisionDbTest(TestModelMixin, TestBase):
|
class CreateRevisionDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testCreateRevisionMultiDb(self):
|
def testCreateRevisionMultiDb(self):
|
||||||
with reversion.create_revision(using="mysql"), reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="mysql"), reversion.create_revision(using="postgres"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
@ -319,6 +332,8 @@ class AddMetaTest(TestModelMixin, TestBase):
|
||||||
with self.assertRaises(reversion.RevisionManagementError):
|
with self.assertRaises(reversion.RevisionManagementError):
|
||||||
reversion.add_meta(TestMeta, name="meta v1")
|
reversion.add_meta(TestMeta, name="meta v1")
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testAddMetaMultDb(self):
|
def testAddMetaMultDb(self):
|
||||||
with reversion.create_revision(using="mysql"), reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="mysql"), reversion.create_revision(using="postgres"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import unittest
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from django.core.management import CommandError
|
from django.core.management import CommandError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -5,6 +6,16 @@ import reversion
|
||||||
from test_app.models import TestModel
|
from test_app.models import TestModel
|
||||||
from test_app.tests.base import TestBase, TestModelMixin
|
from test_app.tests.base import TestBase, TestModelMixin
|
||||||
|
|
||||||
|
try:
|
||||||
|
import psycopg2
|
||||||
|
except ImportError:
|
||||||
|
psycopg2 = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
import MySQLdb
|
||||||
|
except ImportError:
|
||||||
|
MySQLdb = None
|
||||||
|
|
||||||
|
|
||||||
class CreateInitialRevisionsTest(TestModelMixin, TestBase):
|
class CreateInitialRevisionsTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@ -52,12 +63,14 @@ class CreateInitialRevisionsAppLabelTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class CreateInitialRevisionsDbTest(TestModelMixin, TestBase):
|
class CreateInitialRevisionsDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testCreateInitialRevisionsDb(self):
|
def testCreateInitialRevisionsDb(self):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
self.callCommand("createinitialrevisions", using="postgres")
|
self.callCommand("createinitialrevisions", using="postgres")
|
||||||
self.assertNoRevision()
|
self.assertNoRevision()
|
||||||
self.assertSingleRevision((obj,), comment="Initial version.", using="postgres")
|
self.assertSingleRevision((obj,), comment="Initial version.", using="postgres")
|
||||||
|
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testCreateInitialRevisionsDbMySql(self):
|
def testCreateInitialRevisionsDbMySql(self):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
self.callCommand("createinitialrevisions", using="mysql")
|
self.callCommand("createinitialrevisions", using="mysql")
|
||||||
|
@ -67,6 +80,7 @@ class CreateInitialRevisionsDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class CreateInitialRevisionsModelDbTest(TestModelMixin, TestBase):
|
class CreateInitialRevisionsModelDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testCreateInitialRevisionsModelDb(self):
|
def testCreateInitialRevisionsModelDb(self):
|
||||||
obj = TestModel.objects.db_manager("postgres").create()
|
obj = TestModel.objects.db_manager("postgres").create()
|
||||||
self.callCommand("createinitialrevisions", model_db="postgres")
|
self.callCommand("createinitialrevisions", model_db="postgres")
|
||||||
|
@ -125,18 +139,21 @@ class DeleteRevisionsAppLabelTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class DeleteRevisionsDbTest(TestModelMixin, TestBase):
|
class DeleteRevisionsDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testDeleteRevisionsDb(self):
|
def testDeleteRevisionsDb(self):
|
||||||
with reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="postgres"):
|
||||||
TestModel.objects.create()
|
TestModel.objects.create()
|
||||||
self.callCommand("deleterevisions", using="postgres")
|
self.callCommand("deleterevisions", using="postgres")
|
||||||
self.assertNoRevision(using="postgres")
|
self.assertNoRevision(using="postgres")
|
||||||
|
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testDeleteRevisionsDbMySql(self):
|
def testDeleteRevisionsDbMySql(self):
|
||||||
with reversion.create_revision(using="mysql"):
|
with reversion.create_revision(using="mysql"):
|
||||||
TestModel.objects.create()
|
TestModel.objects.create()
|
||||||
self.callCommand("deleterevisions", using="mysql")
|
self.callCommand("deleterevisions", using="mysql")
|
||||||
self.assertNoRevision(using="mysql")
|
self.assertNoRevision(using="mysql")
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testDeleteRevisionsDbNoMatch(self):
|
def testDeleteRevisionsDbNoMatch(self):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
@ -146,6 +163,7 @@ class DeleteRevisionsDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class DeleteRevisionsModelDbTest(TestModelMixin, TestBase):
|
class DeleteRevisionsModelDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testDeleteRevisionsModelDb(self):
|
def testDeleteRevisionsModelDb(self):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
TestModel.objects.db_manager("postgres").create()
|
TestModel.objects.db_manager("postgres").create()
|
||||||
|
|
|
@ -1,9 +1,20 @@
|
||||||
|
import unittest
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
import reversion
|
import reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
from test_app.models import TestModel, TestModelRelated, TestModelParent
|
from test_app.models import TestModel, TestModelRelated, TestModelParent
|
||||||
from test_app.tests.base import TestBase, TestModelMixin, TestModelParentMixin
|
from test_app.tests.base import TestBase, TestModelMixin, TestModelParentMixin
|
||||||
|
|
||||||
|
try:
|
||||||
|
import psycopg2
|
||||||
|
except ImportError:
|
||||||
|
psycopg2 = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
import MySQLdb
|
||||||
|
except ImportError:
|
||||||
|
MySQLdb = None
|
||||||
|
|
||||||
|
|
||||||
class GetForModelTest(TestModelMixin, TestBase):
|
class GetForModelTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@ -15,11 +26,13 @@ class GetForModelTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class GetForModelDbTest(TestModelMixin, TestBase):
|
class GetForModelDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetForModelDb(self):
|
def testGetForModelDb(self):
|
||||||
with reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="postgres"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
self.assertEqual(Version.objects.using("postgres").get_for_model(obj.__class__).count(), 1)
|
self.assertEqual(Version.objects.using("postgres").get_for_model(obj.__class__).count(), 1)
|
||||||
|
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testGetForModelDbMySql(self):
|
def testGetForModelDbMySql(self):
|
||||||
with reversion.create_revision(using="mysql"):
|
with reversion.create_revision(using="mysql"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
@ -57,12 +70,14 @@ class GetForObjectTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class GetForObjectDbTest(TestModelMixin, TestBase):
|
class GetForObjectDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetForObjectDb(self):
|
def testGetForObjectDb(self):
|
||||||
with reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="postgres"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
self.assertEqual(Version.objects.get_for_object(obj).count(), 0)
|
self.assertEqual(Version.objects.get_for_object(obj).count(), 0)
|
||||||
self.assertEqual(Version.objects.using("postgres").get_for_object(obj).count(), 1)
|
self.assertEqual(Version.objects.using("postgres").get_for_object(obj).count(), 1)
|
||||||
|
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testGetForObjectDbMySql(self):
|
def testGetForObjectDbMySql(self):
|
||||||
with reversion.create_revision(using="mysql"):
|
with reversion.create_revision(using="mysql"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
@ -72,6 +87,7 @@ class GetForObjectDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class GetForObjectModelDbTest(TestModelMixin, TestBase):
|
class GetForObjectModelDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetForObjectModelDb(self):
|
def testGetForObjectModelDb(self):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
obj = TestModel.objects.db_manager("postgres").create()
|
obj = TestModel.objects.db_manager("postgres").create()
|
||||||
|
@ -128,6 +144,7 @@ class GetForObjectReferenceTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class GetForObjectReferenceDbTest(TestModelMixin, TestBase):
|
class GetForObjectReferenceDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetForObjectReferenceModelDb(self):
|
def testGetForObjectReferenceModelDb(self):
|
||||||
with reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="postgres"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
@ -137,12 +154,14 @@ class GetForObjectReferenceDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class GetForObjectReferenceModelDbTest(TestModelMixin, TestBase):
|
class GetForObjectReferenceModelDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetForObjectReferenceModelDb(self):
|
def testGetForObjectReferenceModelDb(self):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
obj = TestModel.objects.db_manager("postgres").create()
|
obj = TestModel.objects.db_manager("postgres").create()
|
||||||
self.assertEqual(Version.objects.get_for_object_reference(TestModel, obj.pk).count(), 0)
|
self.assertEqual(Version.objects.get_for_object_reference(TestModel, obj.pk).count(), 0)
|
||||||
self.assertEqual(Version.objects.get_for_object_reference(TestModel, obj.pk, model_db="postgres").count(), 1)
|
self.assertEqual(Version.objects.get_for_object_reference(TestModel, obj.pk, model_db="postgres").count(), 1)
|
||||||
|
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testGetForObjectReferenceModelDbMySql(self):
|
def testGetForObjectReferenceModelDbMySql(self):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
obj = TestModel.objects.db_manager("mysql").create()
|
obj = TestModel.objects.db_manager("mysql").create()
|
||||||
|
@ -177,6 +196,7 @@ class GetDeletedTest(TestModelMixin, TestBase):
|
||||||
self.assertEqual(Version.objects.get_deleted(TestModel)[0].object_id, force_text(pk_2))
|
self.assertEqual(Version.objects.get_deleted(TestModel)[0].object_id, force_text(pk_2))
|
||||||
self.assertEqual(Version.objects.get_deleted(TestModel)[1].object_id, force_text(pk_1))
|
self.assertEqual(Version.objects.get_deleted(TestModel)[1].object_id, force_text(pk_1))
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetDeletedPostgres(self):
|
def testGetDeletedPostgres(self):
|
||||||
with reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="postgres"):
|
||||||
obj = TestModel.objects.using("postgres").create()
|
obj = TestModel.objects.using("postgres").create()
|
||||||
|
@ -185,6 +205,7 @@ class GetDeletedTest(TestModelMixin, TestBase):
|
||||||
obj.delete()
|
obj.delete()
|
||||||
self.assertEqual(Version.objects.using("postgres").get_deleted(TestModel, model_db="postgres").count(), 1)
|
self.assertEqual(Version.objects.using("postgres").get_deleted(TestModel, model_db="postgres").count(), 1)
|
||||||
|
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testGetDeletedMySQL(self):
|
def testGetDeletedMySQL(self):
|
||||||
with reversion.create_revision(using="mysql"):
|
with reversion.create_revision(using="mysql"):
|
||||||
obj = TestModel.objects.using("mysql").create()
|
obj = TestModel.objects.using("mysql").create()
|
||||||
|
@ -196,6 +217,7 @@ class GetDeletedTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class GetDeletedDbTest(TestModelMixin, TestBase):
|
class GetDeletedDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetDeletedDb(self):
|
def testGetDeletedDb(self):
|
||||||
with reversion.create_revision(using="postgres"):
|
with reversion.create_revision(using="postgres"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
@ -203,6 +225,7 @@ class GetDeletedDbTest(TestModelMixin, TestBase):
|
||||||
self.assertEqual(Version.objects.get_deleted(TestModel).count(), 0)
|
self.assertEqual(Version.objects.get_deleted(TestModel).count(), 0)
|
||||||
self.assertEqual(Version.objects.using("postgres").get_deleted(TestModel).count(), 1)
|
self.assertEqual(Version.objects.using("postgres").get_deleted(TestModel).count(), 1)
|
||||||
|
|
||||||
|
@unittest.skipIf(not MySQLdb, "MySQLdb not installed")
|
||||||
def testGetDeletedDbMySql(self):
|
def testGetDeletedDbMySql(self):
|
||||||
with reversion.create_revision(using="mysql"):
|
with reversion.create_revision(using="mysql"):
|
||||||
obj = TestModel.objects.create()
|
obj = TestModel.objects.create()
|
||||||
|
@ -213,6 +236,7 @@ class GetDeletedDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
class GetDeletedModelDbTest(TestModelMixin, TestBase):
|
class GetDeletedModelDbTest(TestModelMixin, TestBase):
|
||||||
|
|
||||||
|
@unittest.skipIf(not psycopg2, "psycopg2 not installed")
|
||||||
def testGetDeletedModelDb(self):
|
def testGetDeletedModelDb(self):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
obj = TestModel.objects.db_manager("postgres").create()
|
obj = TestModel.objects.db_manager("postgres").create()
|
||||||
|
|
|
@ -13,6 +13,17 @@ https://docs.djangoproject.com/en/dev/ref/settings/
|
||||||
import os
|
import os
|
||||||
import getpass
|
import getpass
|
||||||
|
|
||||||
|
try:
|
||||||
|
import psycopg2
|
||||||
|
except ImportError:
|
||||||
|
psycopg2 = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
import MySQLdb
|
||||||
|
except ImportError:
|
||||||
|
MySQLdb = None
|
||||||
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
@ -80,20 +91,24 @@ DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.sqlite3",
|
"ENGINE": "django.db.backends.sqlite3",
|
||||||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
||||||
},
|
}
|
||||||
"postgres": {
|
}
|
||||||
|
|
||||||
|
if psycopg2:
|
||||||
|
DATABASES["postgres"] = {
|
||||||
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
||||||
"NAME": os.environ.get("DJANGO_DATABASE_NAME_POSTGRES", "test_project"),
|
"NAME": os.environ.get("DJANGO_DATABASE_NAME_POSTGRES", "test_project"),
|
||||||
"USER": os.environ.get("DJANGO_DATABASE_USER_POSTGRES", getpass.getuser()),
|
"USER": os.environ.get("DJANGO_DATABASE_USER_POSTGRES", getpass.getuser()),
|
||||||
"PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD_POSTGRES", ""),
|
"PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD_POSTGRES", ""),
|
||||||
},
|
}
|
||||||
"mysql": {
|
|
||||||
|
if MySQLdb:
|
||||||
|
DATABASES["mysql"] = {
|
||||||
"ENGINE": "django.db.backends.mysql",
|
"ENGINE": "django.db.backends.mysql",
|
||||||
"NAME": os.environ.get("DJANGO_DATABASE_NAME_MYSQL", "test_project"),
|
"NAME": os.environ.get("DJANGO_DATABASE_NAME_MYSQL", "test_project"),
|
||||||
"USER": os.environ.get("DJANGO_DATABASE_USER_MYSQL", getpass.getuser()),
|
"USER": os.environ.get("DJANGO_DATABASE_USER_MYSQL", getpass.getuser()),
|
||||||
"PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD_MYSQL", ""),
|
"PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD_MYSQL", ""),
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
|
|
Loading…
Reference in New Issue