Skip to content

Commit

Permalink
Add official Twitter api
Browse files Browse the repository at this point in the history
  • Loading branch information
natehaas authored and tswicegood committed Nov 8, 2009
1 parent 4e67691 commit 9943c4a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Empty file added dolt/apis/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions dolt/apis/twitter.py
@@ -0,0 +1,7 @@
from dolt import Dolt

class Twitter(Dolt):
def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
self._api_url = "https://twitter.com"
self._url_template = '%(domain)s/%(generated_url)s.json'
19 changes: 19 additions & 0 deletions tests/unit_tests.py
Expand Up @@ -2,6 +2,7 @@
sys.path[0:0] = os.path.join(os.path.dirname(__file__), '..')
import unittest, mox
from dolt import Dolt
from dolt.apis.twitter import Twitter
from httplib2 import Http

def random_attribute():
Expand All @@ -17,6 +18,24 @@ def verify_all(*args):

def replay_all(*args):
[mox.Replay(arg) for arg in args]

class TestOfTwitterAPI(unittest.TestCase):
def test_subclasses_dolt(self):
twitter = Twitter()
self.assert_(isinstance(twitter, Dolt))

def test_contains_proper_api_url(self):
twitter = Twitter()
self.assertEqual(twitter._api_url, "https://twitter.com")

def test_contains_proper_url_template(self):
twitter = Twitter()
self.assertEqual(twitter._url_template, '%(domain)s/%(generated_url)s.json')

def test_http_can_be_passed_in(self):
http = "http-%s" % random.randint(1, 10)
twitter = Twitter(http=http)
self.assertEqual(twitter._http, http)

class TestOfDolt(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 9943c4a

Please sign in to comment.