Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
8e181580
Commit
8e181580
authored
Jun 22, 2014
by
Aaron1011
Browse files
Merge pull request #350 from Aaron1011/sitestream
Added sitestream endpoint
parents
7b61a6b7
55a774d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/test_streaming.py
View file @
8e181580
...
...
@@ -45,15 +45,23 @@ class TweepyStreamTests(unittest.TestCase):
def
tearDown
(
self
):
self
.
stream
.
disconnect
()
def
on_connect
():
API
(
self
.
auth
).
update_status
(
mock_tweet
())
def
test_userstream
(
self
):
# Generate random tweet which should show up in the stream.
def
on_connect
():
API
(
self
.
auth
).
update_status
(
mock_tweet
())
self
.
listener
.
connect_cb
=
on_connect
self
.
listener
.
connect_cb
=
self
.
on_connect
self
.
listener
.
status_stop_count
=
1
self
.
stream
.
userstream
()
self
.
assertEqual
(
self
.
listener
.
status_count
,
1
)
def
test_sitestream
(
self
):
self
.
listener
.
connect_cb
=
self
.
on_connect
self
.
listener
.
status_stop_count
=
1
self
.
sitestream
(
follow
=
[
self
.
auth
.
get_username
()])
self
.
assertEqual
(
self
.
listener
.
status_count
,
1
)
def
test_userstream_with_params
(
self
):
# Generate random tweet which should show up in the stream.
...
...
tweepy/streaming.py
View file @
8e181580
...
...
@@ -313,6 +313,22 @@ class Stream(object):
self
.
host
=
'stream.twitter.com'
self
.
_start
(
async
)
def
sitestream
(
self
,
follow
,
stall_warnings
=
False
,
with_
=
'user'
,
replies
=
False
,
async
=
False
):
self
.
parameters
=
{}
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
self
.
url
=
'/%s/site.json'
%
STREAM_VERSION
self
.
parameters
[
'follow'
]
=
','
.
join
(
map
(
str
,
follow
))
self
.
parameters
[
'delimited'
]
=
'length'
if
stall_warnings
:
self
.
parameters
[
'stall_warnings'
]
=
stall_warnings
if
with_
:
self
.
parameters
[
'with'
]
=
with_
if
replies
:
self
.
parameters
[
'replies'
]
=
replies
self
.
body
=
urlencode_noplus
(
self
.
parameters
)
self
.
_start
(
async
)
def
disconnect
(
self
):
if
self
.
running
is
False
:
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment