def test_write_header(self, write_method): writer = HttpWriter(None, None, None, None) writer.write_status(b'200 OK') writer.write_header(b'foo', b'bar') writer.flush() write_method.assert_called_with(b'HTTP/1.1 200 OK\r\nfoo: bar\r\n\r\n')
def test_write_header(self, write_method): writer = HttpWriter(None, None, None, None) writer.status = 200 writer['foo'] = 'bar' writer.flush() write_method.assert_called_with(b'HTTP/1.1 200 OK\r\nfoo: bar\r\n\r\n')
def test_write_status(self, write_method): writer = HttpWriter(None, None, None, None) writer.write_status(b'200 OK') self.assertFalse(writer._headers_sent) writer.flush() self.assertTrue(writer._headers_sent) write_method.assert_called_with(b'HTTP/1.1 200 OK\r\n\r\n')