-def read_patch(filename):
- return file(os.path.join(_test_patch_dir, filename)).read()
+ person = Person(email = email, name = userid, user = user)
+ person.save()
+
+ return user
+
+def create_maintainer(project):
+ user = create_user()
+ profile = user.profile
+ profile.maintainer_projects.add(project)
+ profile.save()
+ return user
+
+def find_in_context(context, key):
+ if isinstance(context, list):
+ for c in context:
+ v = find_in_context(c, key)
+ if v is not None:
+ return v
+ else:
+ if key in context:
+ return context[key]
+ return None
+
+def read_patch(filename, encoding = None):
+ file_path = os.path.join(_test_patch_dir, filename)
+ if encoding is not None:
+ f = codecs.open(file_path, encoding = encoding)
+ else:
+ f = file(file_path)
+
+ return f.read()
+
+def read_mail(filename, project = None):
+ file_path = os.path.join(_test_mail_dir, filename)
+ mail = message_from_file(open(file_path))
+ if project is not None:
+ mail['List-Id'] = project.listid
+ return mail