Skip to content

Commit 5834a12

Browse files
committed
add tests for streaming over https
1 parent ce54830 commit 5834a12

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

plotly/tests/test_core/test_stream/test_stream.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import time
1111

1212
from nose.plugins.attrib import attr
13-
from nose.tools import raises
13+
from nose.tools import raises, eq_
1414

1515
import plotly.plotly as py
1616
from plotly.graph_objs import (Layout, Scatter, Stream)
@@ -123,3 +123,63 @@ def test_stream_unstreamable():
123123
my_stream.open()
124124
my_stream.write(Scatter(x=1, y=10, name='nope'))
125125
my_stream.close()
126+
127+
128+
def test_stream_no_scheme():
129+
130+
# If no scheme is used in the plotly_streaming_domain, port 80
131+
# should be used for streaming and ssl_enabled should be False
132+
133+
py.sign_in(un, ak, **{'plotly_streaming_domain': 'stream.plot.ly'})
134+
my_stream = py.Stream(tk)
135+
expected_streaming_specs = {
136+
'server': 'stream.plot.ly',
137+
'port': 80,
138+
'ssl_enabled': False,
139+
'headers': {
140+
'Host': 'stream.plot.ly',
141+
'plotly-streamtoken': tk
142+
}
143+
}
144+
actual_streaming_specs = my_stream.get_streaming_specs()
145+
eq_(expected_streaming_specs, actual_streaming_specs)
146+
147+
148+
def test_stream_http():
149+
150+
# If the http scheme is used in the plotly_streaming_domain, port 80
151+
# should be used for streaming and ssl_enabled should be False
152+
153+
py.sign_in(un, ak, **{'plotly_streaming_domain': 'http://stream.plot.ly'})
154+
my_stream = py.Stream(tk)
155+
expected_streaming_specs = {
156+
'server': 'stream.plot.ly',
157+
'port': 80,
158+
'ssl_enabled': False,
159+
'headers': {
160+
'Host': 'stream.plot.ly',
161+
'plotly-streamtoken': tk
162+
}
163+
}
164+
actual_streaming_specs = my_stream.get_streaming_specs()
165+
eq_(expected_streaming_specs, actual_streaming_specs)
166+
167+
168+
def test_stream_https():
169+
170+
# If the https scheme is used in the plotly_streaming_domain, port 443
171+
# should be used for streaming and ssl_enabled should be True
172+
173+
py.sign_in(un, ak, **{'plotly_streaming_domain': 'https://stream.plot.ly'})
174+
my_stream = py.Stream(tk)
175+
expected_streaming_specs = {
176+
'server': 'stream.plot.ly',
177+
'port': 443,
178+
'ssl_enabled': True,
179+
'headers': {
180+
'Host': 'stream.plot.ly',
181+
'plotly-streamtoken': tk
182+
}
183+
}
184+
actual_streaming_specs = my_stream.get_streaming_specs()
185+
eq_(expected_streaming_specs, actual_streaming_specs)

0 commit comments

Comments
 (0)