def setup_test_environment(self): super(CreateModelsTestRunner, self).setup_test_environment() mgr = TestSettingsManager() INSTALLED_APPS = list(settings.INSTALLED_APPS) INSTALLED_APPS.append(OUR_TESTS) mgr.set(INSTALLED_APPS=INSTALLED_APPS)
def setup_test_environment(self): super(CreateModelsTestRunner, self).setup_test_environment() mgr = TestSettingsManager() INSTALLED_APPS=list(settings.INSTALLED_APPS) INSTALLED_APPS.append(OUR_TESTS) mgr.set(INSTALLED_APPS=INSTALLED_APPS)
from django.test import TestCase from django.conf import settings from utils import TestSettingsManager from models import * from django.contrib.auth.models import User, Permission, Group from guardian.shortcuts import assign_perm mgr = TestSettingsManager() INSTALLED_APPS = list(settings.INSTALLED_APPS) INSTALLED_APPS.append('users.tests') mgr.set(INSTALLED_APPS=INSTALLED_APPS) mgr.set(USERS_BANNED_GROUP='Banned') class RestrictiveBackendTest(TestCase): def setUp(self): self.user = User(username='******', email='*****@*****.**', password='******') self.user.save() self.group = Group.objects.create(name='Cool group') self.user.groups.add(self.group) self.user.save() def tearDown(self): self.user.delete() self.group.delete() def test_inactive_user_blocked(self): t = Thing(name='Test thing') t.save()
from django.test import TestCase from django.conf import settings from django.core.files.base import ContentFile from django import db from utils import TestSettingsManager from models import * from versionutils import diff from versionutils.diff.diffutils import Registry, BaseFieldDiff, BaseModelDiff from versionutils.diff.diffutils import TextFieldDiff from versionutils.diff.diffutils import FileFieldDiff from versionutils.diff.diffutils import ImageFieldDiff from versionutils.diff.diffutils import HtmlFieldDiff mgr = TestSettingsManager() INSTALLED_APPS = list(settings.INSTALLED_APPS) INSTALLED_APPS.append('versionutils.diff.tests') mgr.set(INSTALLED_APPS=INSTALLED_APPS) class ModelDiffTest(TestCase): def setUp(self): self.test_models = TEST_MODELS def tearDown(self): pass def test_identical(self): """ The diff between two identical models, or a model and itself should be
from django.test import TestCase from django.conf import settings from django.contrib.gis.geos import GEOSGeometry from utils import TestSettingsManager from models import * from maps.fields import * mgr = TestSettingsManager() INSTALLED_APPS = list(settings.INSTALLED_APPS) INSTALLED_APPS.append('maps.tests') mgr.set(INSTALLED_APPS=INSTALLED_APPS) class FlatCollectionTest(TestCase): def test_flatten(self): # A geometry collection with a bunch of stuff inside of a # rectangle. And a few items outside of it. geom = GEOSGeometry( """{ "type": "GeometryCollection", "geometries": [ { "type": "Polygon", "coordinates": [ [ [ -122.443056, 37.787064 ], [ -122.443056, 37.758434 ], [ -122.400999, 37.757891 ], [ -122.403402, 37.787742 ], [ -122.443056, 37.787064 ] ] ] }, { "type": "Point", "coordinates": [ -122.434816, 37.784758 ] }, { "type": "Point", "coordinates": [ -122.410612, 37.781909 ] }, { "type": "Point", "coordinates": [ -122.432241, 37.766983 ] }, { "type": "Point", "coordinates": [ -122.409754, 37.768747 ] }, { "type": "LineString", "coordinates": [ [ -122.415075, 37.784351 ], [ -122.425890, 37.765083 ], [ -122.427435, 37.779466 ] ] }, { "type": "Polygon", "coordinates": [ [ [ -122.438765, 37.778788 ], [ -122.439966, 37.763726 ], [ -122.457132, 37.772139 ], [ -122.438765, 37.778788 ] ] ] }, { "type": "Point", "coordinates": [ -122.415762, 37.792762 ] }, { "type": "Point", "coordinates": [ -122.430696, 37.791541 ] }, { "type": "LineString", "coordinates": [ [ -122.397394, 37.790727 ], [ -122.395849, 37.754498 ], [ -122.448549, 37.761962 ] ] } ] }""", srid=4326) # A geometry collection with nothing inside the rectangle and a # few items outside of it. expected_geom = GEOSGeometry( """{ "type": "GeometryCollection", "geometries": [ { "type": "Polygon", "coordinates": [ [ [ -122.443056, 37.765240 ], [ -122.457132, 37.772139 ], [ -122.443056, 37.777235 ], [ -122.443056, 37.787064 ], [ -122.403402, 37.787742 ], [ -122.400999, 37.757891 ], [ -122.443056, 37.758434 ], [ -122.443056, 37.765240 ] ] ] }, { "type": "Point", "coordinates": [ -122.415762, 37.792762 ] }, { "type": "Point", "coordinates": [ -122.430696, 37.791541 ] }, { "type": "LineString", "coordinates": [ [ -122.397394, 37.790727 ], [ -122.395849, 37.754498 ], [ -122.448549, 37.761962 ] ] } ] }""", srid=4326) self.assertTrue( flatten_collection(geom).equals(expected_geom) or flatten_collection(geom).equals_exact(expected_geom, 0.001))
from django.test import TestCase from django.conf import settings from utils import TestSettingsManager from models import * from django.contrib.auth.models import User, Permission, Group from guardian.shortcuts import assign mgr = TestSettingsManager() INSTALLED_APPS = list(settings.INSTALLED_APPS) INSTALLED_APPS.append('users.tests') mgr.set(INSTALLED_APPS=INSTALLED_APPS) mgr.set(USERS_BANNED_GROUP='Banned') class RestrictiveBackendTest(TestCase): def setUp(self): self.user = User(username='******', email='*****@*****.**', password='******') self.user.save() self.group = Group.objects.create(name='Cool group') self.user.groups.add(self.group) self.user.save() def tearDown(self): self.user.delete() self.group.delete() def test_inactive_user_blocked(self): t = Thing(name='Test thing')