class UTF8HeaderPatchViewTest(UTF8PatchViewTest): fixtures = ['default_states', 'default_events'] patch_filename = '0002-utf-8.patch' patch_encoding = 'utf-8' patch_author_name = u'P\xe4tch Author' def setUp(self): defaults.project.save() self.patch_author = Person(name=self.patch_author_name, email=defaults.patch_author_person.email) self.patch_author.save() self.patch_content = read_patch(self.patch_filename, encoding=self.patch_encoding) self.patch = Patch(project=defaults.project, msgid='x', name=defaults.patch_name, submitter=self.patch_author, content=self.patch_content) self.patch.save() self.client = Client() def tearDown(self): self.patch.delete() self.patch_author.delete() defaults.project.delete()
def testSecondaryEmailOptoutForm(self): p = Person(email=self.secondary_email, user=self.user) p.save() form_re = self._form_re(self.optout_url, p.email) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertTrue(form_re.search(response.content.decode()) is not None)
def testCompleteLimit(self): for i in range(3,10): person = Person(email = '*****@*****.**' % i) person.save() response = self.client.get('/submitter/', {'q': 'test', 'l': 5}) self.assertEquals(response.status_code, 200) data = json.loads(response.content) self.assertEquals(len(data), 5)
def setUp(self): # Create a 'chris' User and Person mail = '*****@*****.**' self.user = User.objects.create_user('chris', mail, 'securepass') person = Person(email=mail) person.link_to_user(self.user) person.save() super(EventLogTest, self).setUp()
def setUp(self): defaults.project.save() for (name, email, date) in self.patchmeta: patch_name = 'testpatch' + name person = Person(name = name, email = email) person.save() patch = Patch(project = defaults.project, msgid = patch_name, submitter = person, content = '', date = date) patch.save()
def register_confirm(request, conf): conf.user.is_active = True conf.user.save() conf.deactivate() try: person = Person.objects.get(email__iexact=conf.user.email) except Person.DoesNotExist: person = Person(email=conf.user.email, name=conf.user.profile.name()) person.user = conf.user person.save() return render_to_response('patchwork/registration-confirm.html')
def link_confirm(request, conf): try: person = Person.objects.get(email__iexact=conf.email) except Person.DoesNotExist: person = Person(email=conf.email) person.link_to_user(conf.user) person.save() conf.deactivate() return render(request, 'patchwork/user-link-confirm.html', {'person': person})
def register_confirm(request, conf): conf.user.is_active = True conf.user.save() conf.deactivate() try: person = Person.objects.get(email__iexact = conf.user.email) except Person.DoesNotExist: person = Person(email = conf.user.email, name = conf.user.profile.name()) person.user = conf.user person.save() return render_to_response('patchwork/registration-confirm.html')
def create_user(): global _user_idx userid = "test%d" % _user_idx email = "*****@*****.**" % userid _user_idx += 1 user = User.objects.create_user(userid, email, userid) user.save() person = Person(email=email, name=userid, user=user) person.save() return user
def create_user(): global _user_idx userid = 'test%d' % _user_idx email = '*****@*****.**' % userid _user_idx += 1 user = User.objects.create_user(userid, email, userid) user.save() person = Person(email=email, name=userid, user=user) person.save() return user
def setUp(self): defaults.project.save() for (name, email, date) in self.patchmeta: patch_name = 'testpatch' + name person = Person(name=name, email=email) person.save() patch = Patch(project=defaults.project, msgid=patch_name, submitter=person, content='', date=date) patch.save()
def create_person(**kwargs): """Create a 'Person' object.""" num = Person.objects.count() values = { 'email': '*****@*****.**' % num, 'name': 'test_person_%d' % num, 'user': None, } values.update(kwargs) person = Person(**values) person.save() return person
def link_confirm(request, conf): context = PatchworkRequestContext(request) try: person = Person.objects.get(email__iexact = conf.email) except Person.DoesNotExist: person = Person(email = conf.email) person.link_to_user(conf.user) person.save() conf.deactivate() context['person'] = person return render_to_response('patchwork/user-link-confirm.html', context)
def link_confirm(request, conf): try: person = Person.objects.get(email__iexact=conf.email) except Person.DoesNotExist: person = Person(email=conf.email) person.link_to_user(conf.user) person.save() conf.deactivate() context = { 'person': person, } return render(request, 'patchwork/user-link-confirm.html', context)
def link_confirm(request, conf): context = PatchworkRequestContext(request) try: person = Person.objects.get(email__iexact=conf.email) except Person.DoesNotExist: person = Person(email=conf.email) person.link_to_user(conf.user) person.save() conf.deactivate() context['person'] = person return render_to_response('patchwork/user-link-confirm.html', context)
def test_existing_person_unmodified(self): """Check that an unconfirmed registration can't modify an existing Person object.""" person = Person(name=self.user.fullname, email=self.user.email) person.save() # register data = self.default_data.copy() data['first_name'] = 'invalid' data['last_name'] = 'invalid' self.assertEqual(data['email'], person.email) response = self.client.post('/register/', data) self.assertEqual(response.status_code, 200) self.assertEqual(Person.objects.get(pk=person.pk).name, self.user.fullname)
def test_existing_person_unmodified(self): """Check that an unconfirmed registration can't modify an existing Person object.""" person = Person(name=self.user.fullname, email=self.user.email) person.save() # register data = self.default_data.copy() data['first_name'] = 'invalid' data['last_name'] = 'invalid' self.assertEqual(data['email'], person.email) response = self.client.post('/register/', data) self.assertEqual(response.status_code, 200) self.assertEqual( Person.objects.get(pk=person.pk).name, self.user.fullname)
def test_existing_person_setup(self): """ Check that the person object created after registration has the correct details """ person = Person(name=self.user.fullname, email=self.user.email) person.save() # register self.assertEqual(EmailConfirmation.objects.count(), 0) response = self.client.post('/register/', self.default_data) self.assertEqual(response.status_code, 200) # confirm conf = EmailConfirmation.objects.filter()[0] response = self.client.get(_confirmation_url(conf)) self.assertEqual(response.status_code, 200) person = Person.objects.get(email=self.user.email) self.assertEqual(person.name, self.user.fullname)
def test_existing_person_unmodified(self): """Ensure an existing person is not linked until registration is done. Create an account for a user using an email we've previously seen but don't confirm it. Check that the person object is not updated yet. """ person = Person(name=self.user.fullname, email=self.user.email) person.save() # register data = self.default_data.copy() data['first_name'] = 'invalid' data['last_name'] = 'invalid' self.assertEqual(data['email'], person.email) response = self.client.post('/register/', data) self.assertEqual(response.status_code, 200) self.assertEqual( Person.objects.get(pk=person.pk).name, self.user.fullname)
def testPullRequestEvent(self): submitter = Person() submitter.save() patch = Patch(project=self.project, pull_url="git://foo.bar master", submitter=submitter) patch.save() # n events for n series, +1 for the pull request above events = self.get_json('/projects/%(project_id)s/events/') self.assertEqual(events['count'], self.n_series + 1) prs = filter(lambda r: r['name'] == 'pull-request-new', events['results']) prs = list(prs) self.assertEqual(len(prs), 1) self.assertEqual(prs[0]['patch'], patch.id) self.assertEqual(prs[0]['parameters']['pull_url'], patch.pull_url)
def test_existing_person_setup(self): """Ensure an existing person is linked after account setup. Create an account for a user using an email we've previously seen. Check that the person object is updated after registration with the correct details. """ person = Person(name=self.user.fullname, email=self.user.email) person.save() # register self.assertEqual(EmailConfirmation.objects.count(), 0) response = self.client.post('/register/', self.default_data) self.assertEqual(response.status_code, 200) # confirm conf = EmailConfirmation.objects.filter()[0] response = self.client.get(_confirmation_url(conf)) self.assertEqual(response.status_code, 200) person = Person.objects.get(email=self.user.email) self.assertEqual(person.name, self.user.fullname)
class UTF8HeaderPatchViewTest(UTF8PatchViewTest): patch_filename = '0002-utf-8.patch' patch_encoding = 'utf-8' patch_author_name = u'P\xe4tch Author' def setUp(self): defaults.project.save() self.patch_author = Person(name = self.patch_author_name, email = defaults.patch_author_person.email) self.patch_author.save() self.patch_content = read_patch(self.patch_filename, encoding = self.patch_encoding) self.patch = Patch(project = defaults.project, msgid = 'x', name = defaults.patch_name, submitter = self.patch_author, content = self.patch_content) self.patch.save() self.client = Client() def tearDown(self): self.patch.delete() self.patch_author.delete() defaults.project.delete()