How to use the pyramid.testing.DummyResource function in pyramid

To help you get started, we’ve selected a few pyramid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pylons / substanced / substanced / dump / tests.py View on Github external
def test_load(self):
        context = testing.DummyResource()
        resource = testing.DummyResource()
        context.exists = lambda *arg: True
        def _p_activate():
            pass # this will not be covered if not run
        context.resource = resource
        resource._p_activate = _p_activate
        def load_yaml(fn):
            self.assertEqual(fn, 'name.yaml')
            return {'a':1}
        context.load_yaml = load_yaml
        inst = self._makeOne('name', None)
        inst.load(context)
        self.assertTrue(resource._p_changed)
        self.assertEqual(resource.a, 1)
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / schema / test_init.py View on Github external
def test_deserialize_value_url_valid_path(self, context, request_, node, rest_url):
        inst = self.make_one()
        context['child'] = testing.DummyResource()
        node = node.bind(request=request_,
                         context=context)
        result = inst.deserialize(node, rest_url + '/child')
        assert result == context['child']
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / schema / test_init.py View on Github external
def setUp(self):
        self.context = testing.DummyResource()
        self.target = testing.DummyResource()
        self.child = testing.DummyResource()
        request = testing.DummyRequest()
        request.root = self.context
        self.request = request
github Pylons / substanced / substanced / util / tests.py View on Github external
def test_one_found(self):
        from ..interfaces import IFolder
        from ..interfaces import IService
        site = testing.DummyResource(__provides__=IFolder)
        catalog = testing.DummyResource(__provides__=IService)
        site['catalog'] = catalog
        self.assertEqual(self._callFUT(site, 'catalog'), [catalog])
github Pylons / substanced / substanced / jsonapi / tests.py View on Github external
def test_call_function(self):
        decorator = self._makeOne()
        venusian = DummyVenusian()
        decorator.venusian = venusian
        def foo(): pass
        wrapped = decorator(foo)
        self.assertTrue(wrapped is foo)
        context = testing.DummyResource()
        context.config = DummyConfigurator()
        venusian.callback(context, None, 'abc')
        self.assertEqual(context.config.view, 'abc')
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / graph / test_init.py View on Github external
def call_fut(self, descendant, ancestors):
        from adhocracy_core.graph import Graph
        context = testing.DummyResource(__objectmap__=self.context.__objectmap)
        graph = Graph(context)
        return Graph.is_in_subtree(graph, descendant, ancestors)
github Pylons / substanced / substanced / util / tests.py View on Github external
def _makeTree(self):
        from substanced.interfaces import IFolder
        from substanced.interfaces import IService
        root = testing.DummyResource(__provides__=IFolder)
        catalogs1 = root['catalogs'] = testing.DummyResource(
            __provides__=IService)
        catalog1 = testing.DummyResource()
        catalogs1['catalog1'] = catalog1
        sub = testing.DummyResource(__provides__=IFolder)
        root['sub'] = sub
        catalogs2 = sub['catalogs'] = testing.DummyResource(
                                            __provides__=IService)
        catalog2 = testing.DummyResource()
        catalog1_2 = testing.DummyResource()
        sub['catalogs'] = catalogs2
        catalogs2['catalog2'] = catalog2
        catalogs2['catalog1'] = catalog1_2
        return root
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / rest / test_views.py View on Github external
def test_valid(self, request, context):
        user = testing.DummyResource(active=True)
        request.validated['user'] = user
        self._call_fut(context, request)
        assert not request.errors
github hypothesis / h / tests / unit / test_api.py View on Github external
def test_index():
    """Get the API descriptor"""

    result = api.index(DummyResource(), DummyRequest())

    # Pyramid's host url defaults to http://example.com
    host = 'http://example.com'
    links = result['links']
    assert links['annotation']['create']['method'] == 'POST'
    assert links['annotation']['create']['url'] == host + '/annotations'
    assert links['annotation']['delete']['method'] == 'DELETE'
    assert links['annotation']['delete']['url'] == host + '/annotations/:id'
    assert links['annotation']['read']['method'] == 'GET'
    assert links['annotation']['read']['url'] == host + '/annotations/:id'
    assert links['annotation']['update']['method'] == 'PUT'
    assert links['annotation']['update']['url'] == host + '/annotations/:id'
    assert links['search']['method'] == 'GET'
    assert links['search']['url'] == host + '/search'
github Pylons / substanced / substanced / editable / tests.py View on Github external
def test_it_with_registration(self):
        from zope.interface import Interface
        from . import IEditable
        request = testing.DummyRequest()
        context = testing.DummyResource()
        class adapter(object):
            def __init__(self, context, request):
                pass
        request.registry.registerAdapter(adapter, (Interface, Interface),
                                         IEditable)
        result = self._callFUT(context, request)
        self.assertEqual(result.__class__, adapter)