Ejemplo n.º 1
0
 def test_inconsistent_engines_for_read_and_write(self):
     with helpers.changed_config(u"ckan.datastore.write_url",
                                 u"sqlite://x"):
         with pytest.raises(AssertionError):
             DatastoreBackend.set_active_backend(config)
     with helpers.changed_config(u"ckan.datastore.read_url", u"sqlite://x"):
         with pytest.raises(AssertionError):
             DatastoreBackend.set_active_backend(config)
Ejemplo n.º 2
0
 def test_inconsistent_engines_for_read_and_write(self):
     with helpers.changed_config(u'ckan.datastore.write_url',
                                 u'sqlite://x'):
         assert_raises(AssertionError, DatastoreBackend.set_active_backend,
                       config)
     with helpers.changed_config(u'ckan.datastore.read_url', u'sqlite://x'):
         assert_raises(AssertionError, DatastoreBackend.set_active_backend,
                       config)
Ejemplo n.º 3
0
 def test_inconsistent_engines_for_read_and_write(self):
     with helpers.changed_config(u'ckan.datastore.write_url', u'sqlite://x'):
         assert_raises(
             AssertionError,
             DatastoreBackend.set_active_backend, config)
     with helpers.changed_config(u'ckan.datastore.read_url', u'sqlite://x'):
         assert_raises(
             AssertionError,
             DatastoreBackend.set_active_backend, config)
def test_get_public_key(app):
    url = toolkit.url_for('authz_service.public_key')
    with temporary_file(RSA_PUB_KEY) as pub_key_file, \
            helpers.changed_config('ckanext.authz_service.jwt_public_key_file', pub_key_file):
        response = app.get(url, status=200)

    assert response.headers['content-type'] == 'application/x-pem-file'
    assert response.body == RSA_PUB_KEY.decode('ascii')
Ejemplo n.º 5
0
    def test_public_key_is_available(self):
        """Test that public key is returned properly
        """
        with temporary_file(RSA_PUB_KEY) as pub_key_file, \
                helpers.changed_config('ckanext.authz_service.jwt_public_key_file', pub_key_file):
            result = helpers.call_action('authz_public_key', {})

        assert RSA_PUB_KEY == result['public_key']
 def test_format_is_an_xloader_format(self):
     formats = u'csv tsv'
     with helpers.changed_config(u'ckanext.xloader.formats', formats):
         for res_format in DEFAULT_FORMATS:
             is_valid_format = XLoaderFormats.is_it_an_xloader_format(
                 res_format)
             if res_format in formats.split():
                 assert is_valid_format
             else:
                 assert not is_valid_format
Ejemplo n.º 7
0
 def test_foreign_queues_are_ignored(self):
     u"""
     Test that foreign RQ-queues are ignored.
     """
     # Create queues for this CKAN instance
     self.enqueue(queue=u"q1")
     self.enqueue(queue=u"q2")
     # Create queue for another CKAN instance
     with changed_config(u"ckan.site_id", u"some-other-ckan-instance"):
         self.enqueue(queue=u"q2")
     # Create queue not related to CKAN
     rq.Queue(u"q4").enqueue_call(jobs.test_job)
     all_queues = jobs.get_all_queues()
     names = {jobs.remove_queue_name_prefix(q.name) for q in all_queues}
     assert names == {u"q1", u"q2"}
Ejemplo n.º 8
0
 def test_foreign_queues_are_ignored(self):
     u'''
     Test that foreign RQ-queues are ignored.
     '''
     # Create queues for this CKAN instance
     self.enqueue(queue=u'q1')
     self.enqueue(queue=u'q2')
     # Create queue for another CKAN instance
     with changed_config(u'ckan.site_id', u'some-other-ckan-instance'):
         self.enqueue(queue=u'q2')
     # Create queue not related to CKAN
     rq.Queue(u'q4').enqueue_call(jobs.test_job)
     all_queues = jobs.get_all_queues()
     names = {jobs.remove_queue_name_prefix(q.name) for q in all_queues}
     assert_equal(names, {u'q1', u'q2'})
Ejemplo n.º 9
0
 def test_foreign_queues_are_ignored(self):
     u'''
     Test that foreign RQ-queues are ignored.
     '''
     # Create queues for this CKAN instance
     self.enqueue(queue=u'q1')
     self.enqueue(queue=u'q2')
     # Create queue for another CKAN instance
     with changed_config(u'ckan.site_id', u'some-other-ckan-instance'):
         self.enqueue(queue=u'q2')
     # Create queue not related to CKAN
     rq.Queue(u'q4').enqueue_call(jobs.test_job)
     all_queues = jobs.get_all_queues()
     names = {jobs.remove_queue_name_prefix(q.name) for q in all_queues}
     assert_equal(names, {u'q1', u'q2'})
Ejemplo n.º 10
0
 def test_foreign_queues_are_ignored(self):
     u"""
     Test that foreign RQ-queues are ignored.
     """
     # Create queues for this CKAN instance
     self.enqueue(queue=u"q1")
     self.enqueue(queue=u"q2")
     # Create queue for another CKAN instance
     with changed_config(u"ckan.site_id", u"some-other-ckan-instance"):
         self.enqueue(queue=u"q2")
     # Create queue not related to CKAN
     rq.Queue(u"q4").enqueue_call(jobs.test_job)
     all_queues = jobs.get_all_queues()
     names = {jobs.remove_queue_name_prefix(q.name) for q in all_queues}
     assert_equal(names, {u"q1", u"q2"})
Ejemplo n.º 11
0
 def test_format_is_a_default_xloader_format(self):
     formats = u'csv tsv'
     with helpers.changed_config(u'ckanext.xloader.formats', formats):
         for res_format in DEFAULT_FORMATS:
             assert XLoaderFormats.is_it_a_default_xloader_format(
                 res_format)
Ejemplo n.º 12
0
 def test_formats_config_exist(self):
     formats = u'csv tsv'
     with helpers.changed_config(u'ckanext.xloader.formats', formats):
         # Reread data from config
         XLoaderFormats.setup_formats()
         assert XLoaderFormats.get_xloader_formats() == formats.split()