Esempio n. 1
0
 def setup(self):
     super(TestReportIssue, self).setup()
     self.joe_public = factories.User()
     self.owner = factories.User()
     self.org = factories.Organization(user=self.owner)
     self.dataset = factories.Dataset(user=self.owner,
                                      owner_org=self.org['name'])
     self.issue = issue_factories.Issue(user=self.owner,
                                        user_id=self.owner['id'],
                                        dataset_id=self.dataset['id'])
     self.app = self._get_test_app()
Esempio n. 2
0
    def setup(self):
        super(TestEditButton, self).setup()
        # create a test issue, owned by a user/org
        self.owner = factories.User()
        self.org = factories.Organization(user=self.owner)
        self.dataset = factories.Dataset(user=self.owner,
                                         owner_org=self.org['name'])
        self.issue = issue_factories.Issue(user=self.owner,
                                           dataset_id=self.dataset['id'])

        self.app = self._get_test_app()
Esempio n. 3
0
 def setup(self):
     super(TestPagination, self).setup()
     self.owner = factories.User()
     self.org = factories.Organization(user=self.owner)
     self.dataset = factories.Dataset(user=self.owner,
                                      owner_org=self.org['name'])
     self.issues = [
         issue_factories.Issue(user=self.owner,
                               dataset_id=self.dataset['id'])
         for x in range(0, 51)
     ]
     self.app = self._get_test_app()
Esempio n. 4
0
    def setup(self):
        super(TestModeration, self).setup()
        self.user = factories.User()
        self.organization = factories.Organization(user=self.user)

        self.dataset = factories.Dataset(user=self.user,
                                         owner_org=self.organization['name'],
                                         private=True)

        self.issue = issue_factories.Issue(user=self.user,
                                           user_id=self.user['id'],
                                           dataset_id=self.dataset['id'])
Esempio n. 5
0
 def test_list_all_issues(self, user, dataset):
     created_issues = [
         issue_factories.Issue(user=user,
                               user_id=user['id'],
                               dataset_id=dataset['id'],
                               description=i) for i in range(0, 10)
     ]
     issues_list = helpers.call_action('issue_search',
                                       context={'user': user['name']},
                                       sort='oldest')['results']
     assert [i['id'] for i in created_issues] == \
         [i['id'] for i in issues_list]
Esempio n. 6
0
 def issue(self, owner, dataset):
     issue = issue_factories.Issue(user_id=owner['id'],
                                 dataset_id=dataset['id'])
     context = {
         'user': owner['name'],
         'model': model,
     }
     helpers.call_action('issue_report',
                         context=context,
                         dataset_id=dataset['id'],
                         issue_number=issue['number'])
     return issue
Esempio n. 7
0
    def setup(self):
        user = factories.User()
        dataset = factories.Dataset()

        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])
        issue_factories.IssueComment(
            user_id=user['id'],
            issue_number=issue['number'],
            dataset_id=issue['dataset_id'],
        )
Esempio n. 8
0
    def test_cannot_create_empty_comment(self, user, dataset):
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])

        pytest.raises(
            toolkit.ValidationError,
            helpers.call_action,
            'issue_comment_create',
            context={'user': user['name']},
            issue_number=issue['number'],
            dataset_id=issue['dataset_id'],
        )
Esempio n. 9
0
    def test_filter_newest(self, user, dataset):
        issues = [
            issue_factories.Issue(user=user,
                                  user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  description=i) for i in range(0, 10)
        ]

        issues_list = helpers.call_action('issue_search',
                                          context={'user': user['name']},
                                          dataset_id=dataset['id'],
                                          sort='newest')['results']
        assert list(reversed([i['id'] for i in issues])) == \
                      [i['id'] for i in issues_list]
Esempio n. 10
0
    def test_user_cannot_delete_issue_they_do_not_own(self, user, owner):
        org = factories.Organization(user=owner)
        dataset = factories.Dataset(owner_org=org['name'])
        issue = issue_factories.Issue(user_id=owner['id'],
                                      dataset_id=dataset['id'])

        context = {
            'user': user['name'],
            'auth_user_obj': user,
            'model': model,
            'session': model.Session,
        }
        pytest.raises(toolkit.NotAuthorized, helpers.call_auth, 'issue_delete',
                      context, issue_id=issue['id'], dataset_id=dataset['id'])
Esempio n. 11
0
    def test_issue_creator_cannot_assign_if_they_cannot_package_update(self):
        user = factories.User()
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=self.dataset['id'])
        env = {'REMOTE_USER': user['name'].encode('ascii')}
        response = self.app.post(toolkit.url_for('issues_assign',
                                                 dataset_id=self.dataset['id'],
                                                 issue_id=self.issue['id']),
                                 {'assignee': user['name']},
                                 extra_environ=env,
                                 expect_errors=True)

        assert_equals(401, response.status_int)
Esempio n. 12
0
    def test_dataset_owner_can_delete_issue(self, owner):
        org = factories.Organization(user=owner)
        dataset = factories.Dataset(owner_org=org['name'])
        issue = issue_factories.Issue(user=owner,
                                      user_id=owner['id'],
                                      dataset_id=dataset['id'])

        context = {
            'user': owner['name'],
            'auth_user_obj': owner,
            'model': model,
            'session': model.Session,
        }
        assert helpers.call_auth('issue_delete', context, issue_id=issue['id'],
                          dataset_id=dataset['id'])
Esempio n. 13
0
    def test_deletion(self, user, dataset):
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])

        helpers.call_action('issue_delete',
                            context={'user': user['name']},
                            dataset_id=dataset['id'],
                            issue_number=issue['number'])

        pytest.raises(toolkit.ObjectNotFound,
                      helpers.call_action,
                      'issue_show',
                      dataset_id=dataset['id'],
                      issue_number=issue['number'])
Esempio n. 14
0
    def test_cannot_update_spam_using_update(self):
        '''we don't want users to be able to set their own spam status/count'''
        user = factories.User()
        dataset = factories.Dataset()
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])
        spam = helpers.call_action('issue_update',
                                   context={'user': user['name']},
                                   id=issue['id'],
                                   spam_state='hidden')

        after_update = helpers.call_action('issue_show',
                                           context={'user': user['name']},
                                           id=issue['id'])
        assert_equals('visible', after_update['spam_state'])
Esempio n. 15
0
 def test_limit(self, user, dataset):
     created_issues = [
         issue_factories.Issue(user=user,
                               user_id=user['id'],
                               dataset_id=dataset['id'],
                               description=i) for i in range(0, 10)
     ]
     search_res = helpers.call_action('issue_search',
                                      context={'user': user['name']},
                                      dataset_id=dataset['id'],
                                      sort='oldest',
                                      limit=5)
     issues_list = search_res['results']
     assert [i['id'] for i in created_issues][:5] ==\
          [i['id'] for i in issues_list]
     assert search_res['count'] == 5
Esempio n. 16
0
    def test_issue_creator_cannot_assign_if_they_cannot_package_update(
            self, app, dataset, issue):
        user = factories.User()
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])
        env = {'REMOTE_USER': user['name'].encode('ascii')}
        response = app.post(
            toolkit.url_for('issues.assign',
                            dataset_id=dataset['id'],
                            issue_number=issue['number']),
            params={'assignee': user['name']},
            extra_environ=env,
        )

        assert 401 == response.status_code
Esempio n. 17
0
    def test_list_all_issues_for_organization(self, user):
        org = factories.Organization(user=user)
        dataset = factories.Dataset(owner_org=org['id'])

        created_issues = [
            issue_factories.Issue(user=user,
                                  user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  description=i) for i in range(0, 10)
        ]
        issues_list = helpers.call_action('issue_search',
                                          context={'user': user['name']},
                                          organization_id=org['id'],
                                          sort='oldest')['results']
        assert [i['id']
                for i in created_issues] == [i['id'] for i in issues_list]
Esempio n. 18
0
    def test_list_all_issues_for_dataset(self):
        user = factories.User()
        dataset = factories.Dataset()

        created_issues = [
            issue_factories.Issue(user=user,
                                  user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  description=i) for i in range(0, 10)
        ]
        issues_list = helpers.call_action('issue_search',
                                          context={'user': user['name']},
                                          dataset_id=dataset['id'],
                                          sort='oldest')
        assert_equals([i['id'] for i in created_issues],
                      [i['id'] for i in issues_list])
Esempio n. 19
0
    def test_filter_newest(self):
        user = factories.User()
        dataset = factories.Dataset()

        issues = [
            issue_factories.Issue(user=user,
                                  user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  description=i) for i in range(0, 10)
        ]
        issues_list = helpers.call_action('issue_search',
                                          context={'user': user['name']},
                                          dataset_id=dataset['id'],
                                          sort='newest')
        assert_equals(list(reversed([i['id'] for i in issues])),
                      [i['id'] for i in issues_list])
Esempio n. 20
0
    def test_filter_by_title_string_search(self, user, dataset):
        issues = [
            issue_factories.Issue(user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  title=title)
            for title in ['some title', 'another Title', 'issue']
        ]

        filtered_issues = helpers.call_action('issue_search',
                                              context={'user': user['name']},
                                              dataset_id=dataset['id'],
                                              q='title')['results']

        expected_issue_ids = set([i['id'] for i in issues[:2]])
        assert expected_issue_ids ==\
                set([i['id'] for i in filtered_issues])
Esempio n. 21
0
    def test_org_editor_can_update_an_issue(self, user):
        org = factories.Organization(
            users=[{'name': user['id'], 'capacity': 'editor'}]
        )
        dataset = factories.Dataset(owner_org=org['name'], private=True)
        user = helpers.call_action('get_site_user')
        issue = issue_factories.Issue(user=user, dataset_id=dataset['id'])

        context = {
            'user': user['name'],
            'model': model,
        }
        assert helpers.call_auth('issue_update',
                                context,
                                issue_number=issue['number'],
                                dataset_id=dataset['id'],
                                status='open')
Esempio n. 22
0
    def test_issue_owner_can_update_issue(self, owner):
        issue_owner = owner
        org = factories.Organization()
        dataset = factories.Dataset(owner_org=org['name'])
        issue = issue_factories.Issue(user=issue_owner,
                                      user_id=issue_owner['id'],
                                      dataset_id=dataset['id'])

        context = {
            'user': issue_owner['name'],
            'model': model,
        }
        assert helpers.call_auth('issue_update',
                                context,
                                issue_number=issue['number'],
                                dataset_id=dataset['id'],
                                status='open')
Esempio n. 23
0
    def test_deletion(self):
        user = factories.User()
        dataset = factories.Dataset()
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])

        helpers.call_action('issue_delete',
                            context={'user': user['name']},
                            dataset_id=dataset['id'],
                            issue_id=issue['id'])

        assert_raises(toolkit.ObjectNotFound,
                      helpers.call_action,
                      'issue_show',
                      dataset_id=dataset['id'],
                      id=issue['id'])
Esempio n. 24
0
    def test_pagination(self):
        user = factories.User()
        dataset = factories.Dataset()

        created_issues = [
            issue_factories.Issue(user=user,
                                  user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  description=i) for i in range(0, 10)
        ]
        issues_list = helpers.call_action('issue_search',
                                          context={'user': user['name']},
                                          dataset_id=dataset['id'],
                                          sort='oldest',
                                          offset=5,
                                          limit=3)['results']
        assert_equals([i['id'] for i in created_issues][5:8],
                      [i['id'] for i in issues_list])
Esempio n. 25
0
    def test_filter_by_title_string_search(self):
        user = factories.User()
        dataset = factories.Dataset()

        issues = [
            issue_factories.Issue(user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  title=title)
            for title in ['some title', 'another Title', 'issue']
        ]

        filtered_issues = helpers.call_action('issue_search',
                                              context={'user': user['name']},
                                              dataset_id=dataset['id'],
                                              q='title')

        expected_issue_ids = [i['id'] for i in issues[:2]]
        assert_equals(expected_issue_ids, [i['id'] for i in filtered_issues])
Esempio n. 26
0
    def test_cannot_update_visiblity_using_update(self, user, dataset):
        '''we don't want users to be able to set their own abuse status'''
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])
        helpers.call_action('issue_update',
                            context={'user': user['name']},
                            dataset_id=dataset['id'],
                            issue_number=issue['number'],
                            visibility='hidden')

        after_update = helpers.call_action(
            'issue_show',
            context={'user': user['name']},
            issue_number=issue['number'],
            dataset_id=dataset['id'],
        )
        assert 'visible' == after_update['visibility']
Esempio n. 27
0
 def setup(self):
     super(TestDatasetList, self).setup()
     self.owner = factories.User()
     self.org = factories.Organization(user=self.owner)
     self.dataset = factories.Dataset(user=self.owner,
                                      owner_org=self.org['name'],
                                      name='test-dataset',
                                      )
     self.dataset_1 = factories.Dataset(user=self.owner,
                                      extras=[{
                                          'key': 'issues_enabled',
                                          'value': True
                                          }],
                                      owner_org=self.org['name'])
     self.issue = issue_factories.Issue(user=self.owner,
                                        user_id=self.owner['id'],
                                        dataset_id=self.dataset['id'],
                                        spam_state='hidden')
     self.app = self._get_test_app()
Esempio n. 28
0
    def test_user_cannot_edit_another_users_issue(self):
        owner = factories.User()
        user = factories.User()
        org = factories.Organization(user=owner)
        dataset = factories.Dataset(user=owner, owner_org=org['name'])
        issue = issue_factories.Issue(user=owner, dataset_id=dataset['id'])

        app = self._get_test_app()
        env = {'REMOTE_USER': user['name'].encode('ascii')}

        response = app.post(
            url=toolkit.url_for('issues_edit',
                                package_id=dataset['id'],
                                id=issue['id']),
            params={'title': 'edit', 'description': 'edited description'},
            extra_environ=env,
            expect_errors=True
        )
        assert_equals(response.status_int, 401)
Esempio n. 29
0
    def test_limit(self):
        user = factories.User()
        dataset = factories.Dataset()

        created_issues = [
            issue_factories.Issue(user=user,
                                  user_id=user['id'],
                                  dataset_id=dataset['id'],
                                  description=i) for i in range(0, 10)
        ]
        search_res = helpers.call_action('issue_search',
                                         context={'user': user['name']},
                                         dataset_id=dataset['id'],
                                         sort='oldest',
                                         limit=5)
        issues_list = search_res['results']
        assert_equals([i['id'] for i in created_issues][:5],
                      [i['id'] for i in issues_list])
        assert_equals(search_res['count'], 5)
Esempio n. 30
0
    def test_update_an_issue(self, user, dataset):
        issue = issue_factories.Issue(user=user,
                                      user_id=user['id'],
                                      dataset_id=dataset['id'])

        helpers.call_action('issue_update',
                            context={'user': user['name']},
                            issue_number=issue['number'],
                            dataset_id=dataset['id'],
                            title='new title',
                            description='new description')

        updated = helpers.call_action(
            'issue_show',
            dataset_id=dataset['id'],
            issue_number=issue['number'],
        )
        assert 'new title' == updated['title']
        assert 'new description' == updated['description']