from ckan.lib.helpers import url_for from ckantoolkit.tests import helpers, factories from ckanext.harvest.tests import factories as harvest_factories from nose.tools import assert_in import ckanext.harvest.model as harvest_model class TestController(helpers.FunctionalTestBase): @classmethod def setup_class(cls): helpers.reset_db() super(TestController, cls).setup_class() harvest_model.setup() sysadmin = factories.Sysadmin() cls.extra_environ = {'REMOTE_USER': sysadmin['name'].encode('ascii')} @classmethod def teardown_class(cls): super(TestController, cls).teardown_class() helpers.reset_db() def setup(self): super(TestController, self).setup() sysadmin = factories.Sysadmin() self.extra_environ = {'REMOTE_USER': sysadmin['name'].encode('ascii')} 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) def test_new_form_is_rendered(self): app = self._get_test_app() url = url_for('harvest_new') response = app.get(url, extra_environ=self.extra_environ) assert_in('