Пример #1
0
    def test_index_page_is_rendered(self, app):

        source1 = harvest_factories.HarvestSource()
        source2 = harvest_factories.HarvestSource()

        response = app.get(u'/harvest')

        _assert_in_body(source1['title'], response)
        _assert_in_body(source2['title'], response)
 def test_harvester_autocomplete(self):
     source1 = harvest_factories.HarvestSource(title='First test harvester')
     harvest_factories.HarvestSource(title='Second test harvester')
     response = self.app.get(u'/search/autocomplete?q=first')
     assert len(response.json['Harvesters']) == 1, 'Expected 1 harvester'
     assert response.json['Harvesters'][0]['title'] == source1['title'], \
         'Invalid search result returned'
     response = self.app.get(u'/search/autocomplete?q=test')
     assert len(response.json['Harvesters']) == 2, 'Expected 2 harvesters'
Пример #3
0
    def test_index_page_is_rendered(self):

        source1 = harvest_factories.HarvestSource()
        source2 = harvest_factories.HarvestSource()

        app = self._get_test_app()

        response = app.get(u'/harvest')

        assert_in(source1['title'], response.unicode_body)
        assert_in(source2['title'], response.unicode_body)
Пример #4
0
    def test_source_page_rendered(self):

        source = harvest_factories.HarvestSource()
        app = self._get_test_app()
        url = url_for('harvest_read', id=source['name'])

        response = app.get(url, extra_environ=self.extra_environ)

        assert_in(source['name'], response.unicode_body)
Пример #5
0
    def test_about_page_rendered(self, app):

        source = harvest_factories.HarvestSource()

        url = url_for('harvest_about', id=source['name'])

        response = app.get(url, extra_environ=self.extra_environ)

        _assert_in_body(source['name'], response)
Пример #6
0
    def test_edit_form_is_rendered(self, app):

        source = harvest_factories.HarvestSource()

        url = url_for('harvest_edit', id=source['id'])

        response = app.get(url, extra_environ=self.extra_environ)

        _assert_in_body('<form id="source-new"', response)
Пример #7
0
    def setUp(self):
        super(self.__class__, self).setUp()

        harvest_model.setup()

        self.env = {
            'REMOTE_USER': factories.Sysadmin()['name'].encode('ascii')
        }
        self.source = harvest_factories.HarvestSource()
        self.app = self._get_test_app()
Пример #8
0
    def test_edit_form_is_rendered(self):

        source = harvest_factories.HarvestSource()

        app = self._get_test_app()

        url = url_for('harvest_edit', id=source['id'])

        response = app.get(url, extra_environ=self.extra_environ)

        assert_in('<form id="source-new"', response.unicode_body)
Пример #9
0
 def _get_source_dict(self):
     '''Not only returns a source_dict, but creates the HarvestSource object
     as well - suitable for testing update actions.
     '''
     source = HarvestSourceActionBase._get_source_dict(self)
     source = factories.HarvestSource(**source)
     # delete status because it gets in the way of the status supplied to
     # helpers.call_action later on. It is only a generated value, not affecting
     # the update/patch anyway.
     del source['status']
     return source
Пример #10
0
    def test_harvest_job_create_as_sysadmin(self):
        source = factories.HarvestSource(**SOURCE_DICT.copy())

        site_user = get_action('get_site_user')({
            'ignore_auth': True
        }, {})['name']
        data_dict = {'source_id': source['id'], 'run': True}
        job = get_action('harvest_job_create')({'user': site_user}, data_dict)

        assert job['source_id'] == source['id']
        assert job['status'] == 'Running'
        assert job['gather_started'] is None
        assert 'stats' in job.keys()
Пример #11
0
    def test_edit_form_is_rendered(self):

        source = harvest_factories.HarvestSource()

        app = self._get_test_app()

        if hasattr(app, 'flask_app'):
            with app.flask_app.test_request_context():
                url = url_for('harvest_edit', id=source['id'])
        else:
            url = url_for('harvest_edit', id=source['id'])

        response = app.get(url, extra_environ=self.extra_environ)

        assert_in('<form id="source-new"', response.body)
Пример #12
0
    def test_harvest_job_create_as_admin(self):
        # as if an admin user presses 'refresh'
        user = ckan_factories.User()
        user['capacity'] = 'admin'
        org = ckan_factories.Organization(users=[user])
        source_dict = SOURCE_DICT.copy()
        source_dict['publisher_id'] = org['id']

        source = factories.HarvestSource(**source_dict)

        data_dict = {'source_id': source['id'], 'run': True}
        job = get_action('harvest_job_create')({
            'user': user['name']
        }, data_dict)

        assert job['source_id'] == source['id']
        assert job['status'] == 'Running'
        assert job['gather_started'] is None
        assert 'stats' in job.keys()