def setUp(self): super(TestSpamDetail, self).setUp() self.comment = CommentFactory() self.comment.report_abuse(user=AuthUserFactory(), save=True, category='spam') self.request = RequestFactory().post('/fake_path') self.request.user = UserFactory()
def setup_log_view(view, request, *args, **kwargs): view.request = request try: view.request.user = request.user except AttributeError: view.request.user = UserFactory() view.args = args view.kwargs = kwargs return view
def setup_form_view(view, request, form, *args, **kwargs): """Mimic as_view and with forms to skip some of the context""" view.request = request try: view.request.user = request.user except AttributeError: view.request.user = UserFactory() view.args = args view.kwargs = kwargs view.form = form return view
def setUp(self): super(TestCommentUpdateView, self).setUp() self.user = AuthUserFactory() self.dr1 = DraftRegistrationFactory( initiator=self.user, registration_schema=utils.draft_reg_util(), registration_metadata=utils.SCHEMA_DATA) self.dr1.submit_for_review(self.user, {}, save=True) self.request = RequestFactory().post('/fake_path', data={'blah': 'arg'}) self.request.user = UserFactory() self.view = CommentUpdateView() self.view = setup_view(self.view, self.request, draft_pk=self.dr1._id)
def setUp(self): super(TestEmailFormView, self).setUp() self.comment = CommentFactory() self.comment.report_abuse(user=AuthUserFactory(), save=True, category='spam') self.request = RequestFactory().post('/fake_path') self.request.user = UserFactory() self.view = EmailFormView() self.form = EmailForm(data={ 'author': 'Nemo', 'message': 'A message for spammers.', 'subject': 'stop spamming', 'email': ('*****@*****.**', '*****@*****.**') }) self.view = setup_form_view(self.view, self.request, self.form, spam_id=self.comment._id)
def setUp(self): super(TestDraftFormView, self).setUp() self.user = AuthUserFactory() self.dr1 = DraftRegistrationFactory( initiator=self.user, registration_schema=utils.draft_reg_util(), registration_metadata=utils.SCHEMA_DATA) self.dr1.submit_for_review(self.user, {}, save=True) self.dr1.flags # sets flags if there aren't any yet. self.request = RequestFactory().get('/fake_path') self.view = DraftFormView() self.view = setup_view(self.view, self.request, draft_pk=self.dr1._id) self.post = RequestFactory().post('/fake_path') self.post.user = UserFactory() self.post_view = DraftFormView() self.form_data = { 'notes': 'Far between', 'proof_of_publication': 'approved', }
def setUp(self): super(TestSpamDetail, self).setUp() self.comment = CommentFactory() self.request = RequestFactory().post('/fake_path') self.request.user = UserFactory()