Luke Plant avatar Luke Plant committed d720b9e

Removed layer of nesting for test models

Comments (0)

Files changed (5)

anonymizer/tests/__init__.py

 from django.test import TestCase
 
 from anonymizer import Anonymizer, introspect
-from anonymizer.tests import testapp
+from anonymizer.tests import models as test_models
 
 
 class TestIntrospect(TestCase):
 
     def test_eveything(self):
-        mod = introspect.create_anonymizers_module(testapp.models)
+        mod = introspect.create_anonymizers_module(test_models)
         expected = """
-from anonymizer.tests.testapp.models import Other, EverythingModel
+from anonymizer.tests.models import Other, EverythingModel
 from anonymizer import Anonymizer
 
 class OtherAnonymizer(Anonymizer):
     NUM_ITEMS = 1000
 
     def setUp(self):
-        self.o1 = testapp.models.Other.objects.create()
+        self.o1 = test_models.Other.objects.create()
         for x in xrange(0, self.NUM_ITEMS):
             d = datetime.now() + timedelta(365*x)
-            testapp.models.EverythingModel.objects.create(o1=self.o1,
-                                                          username="intial%d" % x,
-                                                          birthday=d,
-                                                          age=x,
-                                                          some_datetime=datetime.now(),
-                                                          some_date=date.today(),
-                                                          sex='X',
-                                                          )
+            test_models.EverythingModel.objects.create(o1=self.o1,
+                                                       username="intial%d" % x,
+                                                       birthday=d,
+                                                       age=x,
+                                                       some_datetime=datetime.now(),
+                                                       some_date=date.today(),
+                                                       sex='X',
+                                                       )
 
     def test_eveything(self):
         # Test for as much as possible in one test.
-        assert testapp.models.EverythingModel.objects.count() == self.NUM_ITEMS
-        assert testapp.models.EverythingModel._meta.get_field_by_name('username')[0].unique == True
+        assert test_models.EverythingModel.objects.count() == self.NUM_ITEMS
+        assert test_models.EverythingModel._meta.get_field_by_name('username')[0].unique == True
 
         class EverythingAnonmyizer(Anonymizer):
-            model = testapp.models.EverythingModel
+            model = test_models.EverythingModel
 
             attributes = [
                 ('username', 'username'),
             ]
 
         EverythingAnonmyizer().run()
-        objs = testapp.models.EverythingModel.objects.all()
+        objs = test_models.EverythingModel.objects.all()
         self.assertEqual(len(objs), self.NUM_ITEMS)
         for o in objs:
             # check everything has been changed

anonymizer/tests/models.py

+from django.db import models
+
+
+class Other(models.Model):
+    pass
+
+
+class EverythingModel(models.Model):
+    name = models.CharField(max_length=30)
+    email = models.EmailField()
+    username = models.CharField(max_length=20, unique=True)
+    address_city = models.CharField(max_length=50)
+    address_post_code = models.CharField(max_length=10)
+    address = models.TextField()
+    o1 = models.ForeignKey(Other)
+    something = models.TextField()
+    something_else = models.TextField()
+    some_varchar = models.CharField(max_length=5)
+    birthday = models.DateTimeField()
+    age = models.PositiveSmallIntegerField()
+    icon = models.ImageField(upload_to='.')
+    some_datetime = models.DateTimeField()
+    some_date = models.DateField()
+    sex = models.CharField(max_length=1, choices=[('M', 'Male'),
+                                                  ('F', 'Female')])
Add a comment to this file

anonymizer/tests/testapp/__init__.py

Empty file removed.

anonymizer/tests/testapp/models.py

-from django.db import models
-
-
-class Other(models.Model):
-    pass
-
-
-class EverythingModel(models.Model):
-    name = models.CharField(max_length=30)
-    email = models.EmailField()
-    username = models.CharField(max_length=20, unique=True)
-    address_city = models.CharField(max_length=50)
-    address_post_code = models.CharField(max_length=10)
-    address = models.TextField()
-    o1 = models.ForeignKey(Other)
-    something = models.TextField()
-    something_else = models.TextField()
-    some_varchar = models.CharField(max_length=5)
-    birthday = models.DateTimeField()
-    age = models.PositiveSmallIntegerField()
-    icon = models.ImageField(upload_to='.')
-    some_datetime = models.DateTimeField()
-    some_date = models.DateField()
-    sex = models.CharField(max_length=1, choices=[('M', 'Male'),
-                                                  ('F', 'Female')])
 
 INSTALLED_APPS = [
     'anonymizer',
-    'anonymizer.tests.testapp',
+    'anonymizer.tests',
 ]
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.