import mock
import unittest

from resto.wsgi import Middleware


class AppTestCase(unittest.TestCase):

    def setUp(self):
        self.environ = {
            'wsgi.version': (1, 0),
            'wsgi.multithread': False,
            'wsgi.multiprocess': False,
            'wsgi.run_once': True,
        }
        self.mock_start = mock.Mock()

    def test_application_init(self):
        result = Middleware(self.environ, self.mock_start)
        content = ''
        for data in result:
            content += data
        self.assertGreater(content, '')


if __name__ == '__main__':
    unittest.main()

import mock
import unittest

from resto.wsgi import Middleware


class AppTestCase(unittest.TestCase):

    def setUp(self):
        self.environ = {
            'wsgi.version': (1, 0),
            'wsgi.multithread': False,
            'wsgi.multiprocess': False,
            'wsgi.run_once': True,
        }
        self.mock_start = mock.Mock()

    def test_application_init(self):
        result = Middleware(self.environ, self.mock_start)
        content = ''
        for data in result:
            content += data
        self.assertGreater(content, '')
        self.assertTrue(self.mock_start.called)


if __name__ == '__main__':
    unittest.main()

Test WSGI start_response is called
Test WSGI start_response is called

  import mock
  import unittest
  
  from resto.wsgi import Middleware
  
  
  class AppTestCase(unittest.TestCase):
  
      def setUp(self):
          self.environ = {
              'wsgi.version': (1, 0),
              'wsgi.multithread': False,
              'wsgi.multiprocess': False,
              'wsgi.run_once': True,
          }
          self.mock_start = mock.Mock()
  
      def test_application_init(self):
          result = Middleware(self.environ, self.mock_start)
          content = ''
          for data in result:
              content += data
          self.assertGreater(content, '')
+         self.assertTrue(self.mock_start.called)
  
  
  if __name__ == '__main__':
      unittest.main()
  
Test WSGI start_response is called
## Code Before:
import mock
import unittest

from resto.wsgi import Middleware


class AppTestCase(unittest.TestCase):

    def setUp(self):
        self.environ = {
            'wsgi.version': (1, 0),
            'wsgi.multithread': False,
            'wsgi.multiprocess': False,
            'wsgi.run_once': True,
        }
        self.mock_start = mock.Mock()

    def test_application_init(self):
        result = Middleware(self.environ, self.mock_start)
        content = ''
        for data in result:
            content += data
        self.assertGreater(content, '')


if __name__ == '__main__':
    unittest.main()

## Instruction:
Test WSGI start_response is called
## Code After:
import mock
import unittest

from resto.wsgi import Middleware


class AppTestCase(unittest.TestCase):

    def setUp(self):
        self.environ = {
            'wsgi.version': (1, 0),
            'wsgi.multithread': False,
            'wsgi.multiprocess': False,
            'wsgi.run_once': True,
        }
        self.mock_start = mock.Mock()

    def test_application_init(self):
        result = Middleware(self.environ, self.mock_start)
        content = ''
        for data in result:
            content += data
        self.assertGreater(content, '')
        self.assertTrue(self.mock_start.called)


if __name__ == '__main__':
    unittest.main()
