Пример #1
0
    def test_clear_as_user(self):
        owner = factories.User()
        org = factories.Organization(user=owner)
        dataset = factories.Dataset(owner_org=org['name'])
        issue = issue_factories.Issue(user_id=owner['id'],
                                      dataset_id=dataset['id'])
        comment = issue_factories.IssueComment(user_id=owner['id'],
                                               dataset_id=dataset['id'],
                                               issue_number=issue['number'])

        user = factories.User()
        model.Session.add(
            IssueComment.Report(user['id'], parent_id=comment['id']))
        model.Session.commit()
        context = {
            'user': user['name'],
            'model': model,
        }
        helpers.call_action('issue_comment_report_clear',
                            context=context,
                            dataset_id=dataset['id'],
                            issue_number=issue['number'],
                            comment_id=comment['id'])

        comment_obj = IssueComment.get(comment['id'])
        assert_equals(len(comment_obj.abuse_reports), 0)
        assert_equals('visible', comment_obj.visibility)
Пример #2
0
 def test_clear_as_publisher(self):
     owner = factories.User()
     org = factories.Organization(user=owner)
     dataset = factories.Dataset(owner_org=org['name'])
     issue = issue_factories.Issue(user_id=owner['id'],
                                   dataset_id=dataset['id'])
     comment = issue_factories.IssueComment(user_id=owner['id'],
                                            dataset_id=dataset['id'],
                                            issue_number=issue['number'],
                                            visibility='hidden')
     context = {
         'user': owner['name'],
         'model': model,
     }
     model.Session.add(
         IssueComment.Report(owner['id'], parent_id=comment['id']))
     model.Session.commit()
     helpers.call_action('issue_comment_report_clear',
                         context=context,
                         dataset_id=dataset['id'],
                         issue_number=issue['number'],
                         comment_id=comment['id'])
     result = helpers.call_action('issue_show',
                                  issue_number=issue['number'],
                                  dataset_id=dataset['id'])
     assert_equals('visible', result['comments'][0]['visibility'])
     comment_obj = IssueComment.get(comment['id'])
     model.Session.refresh(comment_obj)
     assert_equals(len(comment_obj.abuse_reports), 0)
Пример #3
0
    def test_report_clear_state_normal_user(self, app, dataset, issue, comment):
        user = factories.User()
        model.Session.add(IssueComment.Report(user['id'], comment['id']))
        model.Session.commit()
        env = {'REMOTE_USER': user['name'].encode('ascii')}
        response = app.post(
            url=toolkit.url_for('issues.comment_report_clear',
                                dataset_id=dataset['id'],
                                issue_number=issue['number'],
                                comment_id=comment['id']),
            extra_environ=env,
        )

        assert 'Spam/abuse report cleared' in response.body
Пример #4
0
 def test_report_clear_state_normal_user(self):
     user = factories.User()
     model.Session.add(IssueComment.Report(user['id'], self.comment['id']))
     model.Session.commit()
     env = {'REMOTE_USER': user['name'].encode('ascii')}
     response = self.app.post(
         url=toolkit.url_for('issues_comment_report_clear',
                             dataset_id=self.dataset['id'],
                             issue_number=self.issue['number'],
                             comment_id=self.comment['id']),
         extra_environ=env,
     )
     response = response.follow()
     assert_in('Spam/abuse report cleared', response.body)
Пример #5
0
    def test_clear_as_user(self, owner, org, dataset, issue):
        comment = issue_factories.IssueComment(user_id=owner['id'],
                                               dataset_id=dataset['id'],
                                               issue_number=issue['number'])

        user = factories.User()
        model.Session.add(IssueComment.Report(user['id'],
                                              parent_id=comment['id']))
        model.Session.commit()
        context = {
            'user': user['name'],
            'model': model,
        }
        helpers.call_action('issue_comment_report_clear', context=context,
                            dataset_id=dataset['id'],
                            issue_number=issue['number'],
                            comment_id=comment['id'])

        comment_obj = IssueComment.get(comment['id'])
        assert len(comment_obj.abuse_reports) == 0
        assert 'visible' == comment_obj.visibility
Пример #6
0
 def test_clear_as_publisher(self, owner, org, dataset, issue):
     comment = issue_factories.IssueComment(user_id=owner['id'],
                                            dataset_id=dataset['id'],
                                            issue_number=issue['number'],
                                            visibility='hidden')
     context = {
         'user': owner['name'],
         'model': model,
     }
     model.Session.add(IssueComment.Report(owner['id'],
                                           parent_id=comment['id']))
     model.Session.commit()
     helpers.call_action('issue_comment_report_clear', context=context,
                         dataset_id=dataset['id'],
                         issue_number=issue['number'],
                         comment_id=comment['id'])
     result = helpers.call_action('issue_show',
                                  issue_number=issue['number'],
                                  dataset_id=dataset['id'])
     assert 'visible' == result['comments'][0]['visibility']
     comment_obj = IssueComment.get(comment['id'])
     model.Session.refresh(comment_obj)
     assert len(comment_obj.abuse_reports) == 0