]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/tests/utils.py
Resolve removed 'AUTH_PROFILE_MODULE' setting
[patchwork] / apps / patchwork / tests / utils.py
index 02c4bd498b2a3ae0555f498e9a02e85a8e547f71..782ed369cca0254a80d20abd5a90b7a70c3f614d 100644 (file)
@@ -19,8 +19,9 @@
 
 import os
 import codecs
-from patchwork.models import Project, Person, UserProfile
+from patchwork.models import Project, Person
 from django.contrib.auth.models import User
+from django.forms.fields import EmailField
 
 from email import message_from_file
 try:
@@ -32,15 +33,16 @@ except ImportError:
     from email.MIMEMultipart import MIMEMultipart
 
 # helper functions for tests
-_test_mail_dir  = 'patchwork/tests/mail'
-_test_patch_dir = 'patchwork/tests/patches'
+_test_mail_dir  = os.path.join(os.path.dirname(__file__), 'mail')
+_test_patch_dir = os.path.join(os.path.dirname(__file__), 'patches')
 
 class defaults(object):
-    project = Project(linkname = 'test-project', name = 'Test Project')
+    project = Project(linkname = 'test-project', name = 'Test Project',
+                      listid = 'test.example.com')
 
     patch_author = 'Patch Author <patch-author@example.com>'
     patch_author_person = Person(name = 'Patch Author',
-            email = 'patch-author@example.com')
+        email = 'patch-author@example.com')
 
     comment_author = 'Comment Author <comment-author@example.com>'
 
@@ -56,24 +58,28 @@ class defaults(object):
 +a
 """
 
+error_strings = {
+    'email': 'Enter a valid email address.',
+}
+
 _user_idx = 1
 def create_user():
     global _user_idx
-    userid = 'test-%d' % _user_idx
+    userid = 'test%d' % _user_idx
     email = '%s@example.com' % userid
     _user_idx += 1
 
     user = User.objects.create_user(userid, email, userid)
     user.save()
 
-    profile = UserProfile(user = user)
-    profile.save()
+    person = Person(email = email, name = userid, user = user)
+    person.save()
 
     return user
 
 def create_maintainer(project):
     user = create_user()
-    profile = user.get_profile()
+    profile = user.profile
     profile.maintainer_projects.add(project)
     profile.save()
     return user
@@ -126,7 +132,7 @@ def create_email(content, subject = None, sender = None, multipart = False,
 
     msg['Subject'] = subject
     msg['From'] = sender
-    msg['List-Id'] = project.linkname
+    msg['List-Id'] = project.listid
 
 
     return msg