-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds incomplete User and Room, and a failing test setting some goals.
me = client.get_me() sandbox = client.get_room(11540) with sandbox.messages() as messages: sandbox.send_message("hello worl") for message in messages: if message.owner is me: assert my_message.content == "hello worl" ref #65, ref #52, ref #43
- Loading branch information
1 parent
41cc50d
commit a572d36
Showing
14 changed files
with
138 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
from . import browser | ||
|
||
from . import users | ||
from . import messages | ||
from . import rooms | ||
from . import events | ||
from . import client | ||
|
||
|
||
Browser = browser.Browser | ||
|
||
Client = client.Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import logging | ||
|
||
from . import _utils | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Room(object): | ||
def __init__(self, id, client): | ||
self.logger = logger.getChild('Room') | ||
self.id = id | ||
self.client = client | ||
|
||
name = _utils.LazyFrom('scrape_info') | ||
description = _utils.LazyFrom('scrape_info') | ||
message_count = _utils.LazyFrom('scrape_info') | ||
user_count = _utils.LazyFrom('scrape_info') | ||
parent_site_name = _utils.LazyFrom('scrape_info') | ||
|
||
def scrape_info(self): | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import logging | ||
|
||
from . import _utils | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class User(object): | ||
def __init__(self, id, client): | ||
self.logger = logger.getChild('User') | ||
self.id = id | ||
self.client = client | ||
|
||
name = _utils.LazyFrom('scrape_profile') | ||
about = _utils.LazyFrom('scrape_profile') | ||
is_moderator = _utils.LazyFrom('scrape_profile') | ||
parent_user_url = _utils.LazyFrom('scrape_profile') | ||
|
||
def scrape_profile(self): | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
from getpass import getpass | ||
import logging | ||
|
||
import chatexchange | ||
from chatexchange.events import MessageEdited | ||
|
||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
email = raw_input('Email: ') | ||
password = getpass() | ||
client = chatexchange.Client('stackexchange.com', email, password) | ||
|
||
me = client.get_me() | ||
sandbox = client.get_room(11540) | ||
my_message = None | ||
|
||
with sandbox.messages() as messages: | ||
sandbox.send_message("hello worl") | ||
|
||
for message in messages: | ||
if message.owner is me: | ||
my_message = message | ||
assert my_message.content == "hello worl" | ||
print "message sent successfully" | ||
break | ||
|
||
with sandbox.events(MessageEdited) as edits: | ||
my_message.edit("hello world") | ||
|
||
for edit in edits: | ||
if edit.message is my_message: | ||
assert my_message.content == "hello world" | ||
print "message edited successfully" | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import logging | ||
|
||
from chatexchange import Client | ||
import chatexchange | ||
|
||
import live_testing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import chatexchange | ||
from chatexchange.events import MessageEdited | ||
|
||
import live_testing | ||
|
||
|
||
if live_testing: | ||
def test_room_iterators(): | ||
client = chatexchange.Client( | ||
'stackexchange.com', live_testing.email, live_testing.password) | ||
|
||
me = client.get_me() | ||
sandbox = client.get_room(11540) | ||
my_message = None | ||
|
||
with sandbox.messages() as messages: | ||
sandbox.send_message("hello worl") | ||
|
||
for message in messages: | ||
if message.owner is me: | ||
my_message = message | ||
assert my_message.content == "hello worl" | ||
break | ||
|
||
with sandbox.events(MessageEdited) as edits: | ||
my_message.edit("hello world") | ||
|
||
for edit in edits: | ||
assert isinstance(edit, MessageEdited) | ||
|
||
if edit.message is my_message: | ||
assert my_message.content == "hello world" | ||
break |