Пример #1
0
 def test_stacking_wees_collapses_them(self):
     app = Mock()
     wee1 = wee(app, a='a1')
     wee2 = wee(wee1, b='b')
     wee3 = wee(wee2, a='a2', c='c')
     self.assertIs(wee3.app, app)
     self.assertEqual(wee3.kw, dict(a='a2', b='b', c='c'))
Пример #2
0
 def test_wee_calls_pass_through_with_bindings(self, bind):
     bind.return_value = {'a': sentinel.a}
     app = Mock()
     wee_app = wee(app)
     self.assertIs(
         wee_app(sentinel.environ),
         app.return_value
     )
     app.assert_called_once_with(sentinel.environ, **bind.return_value)
Пример #3
0
 def test_changes_wsgi_call_to_wee_call(self, bind):
     bind.return_value = {'a': sentinel.a}
     start_response = Mock()
     app = Mock()
     app.return_value = sentinel.status, sentinel.headers, sentinel.body
     wee_app = wee(app, a='a', b='b')
     self.assertIs(
         wee_app(sentinel.environ, start_response),
         sentinel.body
     )
     bind.assert_called_once_with(sentinel.environ, dict(a='a', b='b'))
     app.assert_called_once_with(sentinel.environ, **bind.return_value)
     start_response.assert_called_once_with(
         sentinel.status, sentinel.headers)
Пример #4
0
 def test_when_called_without_app_it_is_a_decorator(self, bind):
     bind.return_value = {'a': sentinel.a}
     start_response = Mock()
     app = Mock()
     app.return_value = sentinel.status, sentinel.headers, sentinel.body
     wee_app = wee(a='a', b='b')(app)
     self.assertIs(
         wee_app(sentinel.environ, start_response),
         sentinel.body
     )
     bind.assert_called_once_with(sentinel.environ, dict(a='a', b='b'))
     app.assert_called_once_with(sentinel.environ, **bind.return_value)
     start_response.assert_called_once_with(
         sentinel.status, sentinel.headers)