How to use the pyramid.testing.DummyRequest 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 eucalyptus / eucaconsole / tests / stacks / test_aws_convert.py View on Github external
def test_url_for_resource(self):
        from eucaconsole.views.stacks import StackStateView
        _register_routes(self.config)
        request = testing.DummyRequest()
        
        url = StackStateView.get_url_for_resource(request, 'AWS::ElasticLoadBalancing::LoadBalancer', 'lb-1234')
        self.assertEqual(url, '/elbs/lb-1234')

        url = StackStateView.get_url_for_resource(request, 'AWS::EC2::SecurityGroup', 'sg-1234')
        self.assertEqual(url, '/securitygroups/sg-1234')

        url = StackStateView.get_url_for_resource(request, 'AWS::EC2::EIP', '1.2.3.4')
        self.assertEqual(url, '/ipaddresses/1.2.3.4')

        url = StackStateView.get_url_for_resource(request, 'AWS::EC2::Instance', 'i-1234')
        self.assertEqual(url, '/instances/i-1234')

        url = StackStateView.get_url_for_resource(request, 'AWS::EC2::Volume', 'vol-1234')
        self.assertEqual(url, '/volumes/vol-1234')
github wylee / pyramid_restler / pyramid_restler / tests.py View on Github external
session = Session(bind=engine)
        Base = declarative_base()
        class Entity(Base):
            __tablename__ = 'entity'
            id = Column(Integer, primary_key=True)
            value = Column(String)
        Base.metadata.create_all(bind=engine)
        session.add_all([
            Entity(id=1, value='one'),
            Entity(id=2, value='two'),
            Entity(id=3, value='three'),
        ])
        session.commit()
        class ContextFactory(SQLAlchemyORMContext):
            entity = Entity
        request = DummyRequest()
        request.db_session = session
        self.context = ContextFactory(request)
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / schema / test_init.py View on Github external
def request_(self, context):
        request = testing.DummyRequest()
        request.root = context
        return request
github GoogleCloudPlatform / google-cloud-python-expenses-demo / gcloud_expenses / test_views.py View on Github external
def test_home_page(self):
        from pyramid import testing
        from .views import home_page
        request = testing.DummyRequest()
        info = home_page(request)
        self.assertEqual(info, {})
github Pylons / pyramid_cookbook / getting_started / 07-viewclasses / tutorial / tests.py View on Github external
def test_wiki_view(self):
        from tutorial.views import WikiViews

        request = testing.DummyRequest()
        inst = WikiViews(request)
        response = inst.wiki_view()
        self.assertEqual(response['title'], 'Welcome to the Wiki')
github hypothesis / h / tests / unit / test_notification.py View on Github external
def test_reply_query_match():
    """Test if the notifier.send_notifications is called
    """
    annotation = {
        'user': 'acct:testuser@testdomain',
        'permissions': {'read': ["group:__world__"]}
    }
    request = DummyRequest()
    event = events.AnnotationEvent(request, annotation, 'create')

    with patch('h.notification.notifier.AnnotationNotifier') as mock_notif:
        with patch('h.notification.notifier.parent_values') as mock_parent:
            with patch('h.notification.notifier.Subscriptions.get_active_subscriptions') as mock_subs:
                mock_subs.return_value = [
                    Mock(uri='acct:parent@testdomain',
                         template=types.REPLY_TEMPLATE)
                ]
                mock_parent.return_value = {'user': 'acct:parent@testdomain'}
                notifier.send_notifications(event)
                assert mock_notif().send_notification_to_owner.call_count == 1
github ramses-tech / nefertari / tests / test_resource.py View on Github external
def test_resources_with_name_prefix(self):
        from nefertari.resource import add_resource_routes
        add_resource_routes(
            self.config,
            DummyCrudView,
            'message',
            'messages',
            name_prefix="special_"
        )

        self.assertEqual(
            '/messages/1',
            route_path('special_message', testing.DummyRequest(), id=1)
        )
github Pylons / pyramid_cookbook / humans / resources / step03 / tests.py View on Github external
def test_site_view(self):
        request = DummyRequest()
        context = DummySite()
        inst = self._makeOne(context, request)
        result = inst.site_view()
        self.assertEqual(len(result['children']), 5)
github Pylons / pyramid_cookbook / docs / traversal_tutorial / hierarchy / tutorial / tests.py View on Github external
def test_home_view(self):
        from .views import TutorialViews

        request = DummyRequest()
        title = 'Dummy Context'
        context = DummyResource(title=title, __name__='dummy')
        inst = TutorialViews(context, request)
        result = inst.home()
        self.assertIn('Home', result['page_title'])