Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(184)  |  Call(184)  |  Derive(0)  |  Import(0)

src/p/y/pyramid-views-1.0.3/tests/test_list.py   pyramid-views(Download)
    def test_items(self):
        # res = self.client.get('/list/dict/')
        view = views.DictList.as_view()
        res = view(DummyRequest())
        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(res, 'tests:templates/list.html')
        self.assertEqual(res.context['object_list'][0]['first'], 'John')
    def test_query(self):
        view = views.AuthorList.as_view()
        res = view(DummyRequest())
        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(res, 'tests:templates/author_list.html')
        self.assertEqual(list(res.context['object_list']), list(Session.query(Author).all()))
    def test_paginated_query(self):
        self._make_authors(100)
        view = views.AuthorList.as_view(paginate_by=30)
        res = view(DummyRequest())
        self.assertEqual(res.status_code, 200)

src/p/y/pyramid-views-1.0.3/tests/test_edit.py   pyramid-views(Download)
 
        default_kwargs = TestFormMixin().get_form_kwargs()
        self.assertEqual('', default_kwargs.get('prefix'))
 
        set_mixin = TestFormMixin()
        set_mixin.prefix = test_string
        set_kwargs = set_mixin.get_form_kwargs()
        self.assertEqual(test_string, set_kwargs.get('prefix'))
    def test_post_data(self):
        view = views.ContactView.as_view()
        res = view(DummyRequest(method='POST', params=MultiDict(name='Me', message='Hello')))
        self.assertEqual(res.status_code, 302)
        self.assertEqual(res.headers['Location'], '/list/authors/')
    def test_get_form(self):
        form_class = views.AuthorGetQueryFormView().get_form_class()
        self.assertEqual(form_class.Meta.model, Author)
 
    def test_get_form_checks_for_object(self):

src/p/y/pyramid-views-1.0.3/tests/test_detail.py   pyramid-views(Download)
    def test_simple_object(self):
        view = views.ObjectDetail.as_view()
        res = view(DummyRequest())
        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.context['object'], {'foo': 'bar'})
    def test_detail_by_pk(self):
        self.author()
        view = views.AuthorDetail.as_view()
        res = view(DummyRequest(), pk=1)
        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.context['object'], Session.query(Author).filter(Author.id==1).one())
        self.assertEqual(res.context['author'], Session.query(Author).filter(Author.id==1).one())

src/p/y/pyramid-views-1.0.3/tests/test_base.py   pyramid-views(Download)
    def _assert_simple(self, response):
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.body, b'This is a simple view')
 
    def test_no_init_kwargs(self):
    def test_pathological_http_method(self):
        """
        The edge case of a http request that spoofs an existing method name is caught.
        """
        self.assertEqual(SimpleView.as_view()(
            DummyRequest(path='/', method='GET')
        ))
        self.assertEqual(SimpleView.as_view()(
            DummyRequest(path='/', method='POST')
        ).status_code, 405)
        self.assertEqual(SimpleView.as_view()(