Esempio n. 1
0
 def test_get_message_with_multiline(self):
     event_source = eventsource_connect(url=self.get_url('/multi_line'),
                                        callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, None)
     self.assertEqual(event.data, 'such Wow\\nmuch multi')
Esempio n. 2
0
 def test_get_message_with_url_params(self):
     event_source = eventsource_connect(url=self.get_url('/param/42'),
                                        callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, 'doge_source')
     self.assertEqual(event.data, 'such Wow 42')
Esempio n. 3
0
 def test_get_message_without_name(self):
     event_source = eventsource_connect(url=self.get_url('/no_name'),
                                        callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, None)
     self.assertEqual(event.data, 'such Wow')
Esempio n. 4
0
 def test_get_message_on_open(self):
     event_source = eventsource_connect(url=self.get_url('/'),
                                        callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, 'doge_source')
     self.assertEqual(event.data, 'much connection')
 def test_get_message_with_retry_on_open(self):
     event_source = eventsource_connect(url=self.get_url('/retry'), callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, 'doge_source')
     self.assertEqual(event.data, 'such Wow')
     self.assertEqual(event.retry, 300)
Esempio n. 6
0
 def test_get_message_with_retry_on_open(self):
     event_source = eventsource_connect(url=self.get_url('/retry'),
                                        callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, 'doge_source')
     self.assertEqual(event.data, 'such Wow')
     self.assertEqual(event.retry, 300)
    def test_should_set_custom_headers(self):
        event_source = eventsource_connect(url=self.get_url('/'), callback=self.stop)
        self.wait()
        headers = event_source.result().headers

        self.assertEqual(headers['Transfer-Encoding'], 'identity')
        self.assertEqual(headers['Connection'], 'keep-alive')
        self.assertEqual(headers['Access-Control-Allow-Origin'], '*')
        self.assertEqual(headers['Content-Type'], 'text/event-stream')
        self.assertEqual(headers['X-doge-header'], 'much head')
Esempio n. 8
0
    def test_should_set_custom_headers(self):
        event_source = eventsource_connect(url=self.get_url('/'),
                                           callback=self.stop)
        self.wait()
        headers = event_source.result().headers

        self.assertEqual(headers['Transfer-Encoding'], 'identity')
        self.assertEqual(headers['Connection'], 'keep-alive')
        self.assertEqual(headers['Access-Control-Allow-Origin'], '*')
        self.assertEqual(headers['Content-Type'], 'text/event-stream')
        self.assertEqual(headers['X-doge-header'], 'much head')
Esempio n. 9
0
 def test_stream_closed_error(self, write_mock):
     write_mock.side_effect = StreamClosedError
     event_source = eventsource_connect(url=self.get_url('/'),
                                        callback=self.stop)
     self.wait()
     self.assertRaises(Exception, event_source.result)
 def test_get_message_with_multiline(self):
     event_source = eventsource_connect(url=self.get_url('/multi_line'), callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, None)
     self.assertEqual(event.data, 'such Wow\nmuch multi')
 def test_get_message_without_name(self):
     event_source = eventsource_connect(url=self.get_url('/no_name'), callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, None)
     self.assertEqual(event.data, 'such Wow')
 def test_get_message_with_url_params(self):
     event_source = eventsource_connect(url=self.get_url('/param/42'), callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, 'doge_source')
     self.assertEqual(event.data, 'such Wow 42')
 def test_get_message_on_open(self):
     event_source = eventsource_connect(url=self.get_url('/'), callback=self.stop)
     self.wait()
     event = event_source.result().events[0]
     self.assertEqual(event.name, 'doge_source')
     self.assertEqual(event.data, 'much connection')
 def test_stream_closed_error(self, write_mock):
     write_mock.side_effect = StreamClosedError
     event_source = eventsource_connect(url=self.get_url('/'), callback=self.stop)
     self.wait()
     self.assertRaises(Exception, event_source.result)