Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix for handling not-yet-looked-up tweeters

  • Loading branch information...
commit f7207110972c0c8ad8105fd92a1ab7f869c87f5e 1 parent 8834f88
Peter Bengtsson authored
Showing with 39 additions and 12 deletions.
  1. +1 −1  handlers.py
  2. +1 −1  tests/base.py
  3. +37 −10 tests/test_handlers.py
2  handlers.py
View
@@ -683,7 +683,7 @@ def get(self, username, compared_to):
access_token=current_user['access_token'])
compared_tweeter = self.save_tweeter_user(result)
- elif not tweeter and not compared_tweeter:
+ elif not tweeter or not compared_tweeter:
options = {
'page_title': 'Comparing %s to %s' % (username, compared_to)
}
2  tests/base.py
View
@@ -48,7 +48,7 @@ def setUp(self):
super(BaseHTTPTestCase, self).setUp()
self._app.settings['email_backend'] = \
- 'utils.send_mail.backends.locmem.EmailBackend'
+ 'tornado_utils.send_mail.backends.locmem.EmailBackend'
self._app.settings['email_exceptions'] = False
self.client = TestClient(self)
47 tests/test_handlers.py
View
@@ -624,6 +624,33 @@ def test_following_compared_to_not_logged_in(self):
self.assertTrue('href="%s?next=%s"' % (login_url, url)
in response.body)
+ def test_following_compared_to_not_logged_in_one_tweeter_known(self):
+ obama = self.db.Tweeter()
+ obama['user_id'] = 12345
+ obama['username'] = u'obama'
+ obama['name'] = u'Barak Obama'
+ obama['followers'] = 12350
+ obama['following'] = 100
+ obama.save()
+
+ url = self.reverse_url('following_compared', 'obama', 'peterbe')
+ response = self.client.get(url)
+ self.assertEqual(response.code, 200)
+ self.assertTrue('Sorry' in response.body)
+
+ login_url = self.reverse_url('auth_twitter')
+ self.assertTrue('href="%s?next=%s"' % (login_url, url)
+ in response.body)
+
+ url = self.reverse_url('following_compared', 'peterbe', 'obama')
+ response = self.client.get(url)
+ self.assertEqual(response.code, 200)
+ self.assertTrue('Sorry' in response.body)
+
+ login_url = self.reverse_url('auth_twitter')
+ self.assertTrue('href="%s?next=%s"' % (login_url, url)
+ in response.body)
+
def test_following_compared_logged_in_self(self):
url = self.reverse_url('following_compared', 'obama', 'peterbe')
self._login()
@@ -722,10 +749,10 @@ def test_suggest_tweet(self):
self.assertEqual(response.code, 200)
struct = json.loads(response.body)
- self.assertTrue(len(struct['tweet']) <= 140)
- self.assertTrue(struct['tweet'].endswith('#toocool'))
- self.assertTrue('@obama' in struct['tweet'])
- self.assertTrue('66 times cooler' in struct['tweet'])
+ self.assertTrue(len(struct['text']) <= 140)
+ #self.assertTrue(struct['text'].endswith('#toocool'))
+ self.assertTrue('@obama' in struct['text'])
+ self.assertTrue('66 times cooler' in struct['text'])
billy = self.db.Tweeter()
billy['username'] = u'Mr_Billy_Nomates'
@@ -740,9 +767,9 @@ def test_suggest_tweet(self):
self.assertEqual(response.code, 200)
struct = json.loads(response.body)
- self.assertTrue(len(struct['tweet']) <= 140)
- self.assertTrue(struct['tweet'].endswith('#toocool'))
- self.assertTrue('@Mr_Billy_Nomates' in struct['tweet'])
+ self.assertTrue(len(struct['text']) <= 140)
+ #self.assertTrue(struct['text'].endswith('#toocool'))
+ self.assertTrue('@Mr_Billy_Nomates' in struct['text'])
peterbe = self.db.Tweeter.find_one({'username': 'peterbe'})
twin = self.db.Tweeter()
@@ -758,9 +785,9 @@ def test_suggest_tweet(self):
self.assertEqual(response.code, 200)
struct = json.loads(response.body)
- self.assertTrue(len(struct['tweet']) <= 140)
- self.assertTrue(struct['tweet'].endswith('#toocool'))
- self.assertTrue('@peterbestwin' in struct['tweet'])
+ self.assertTrue(len(struct['text']) <= 140)
+ #self.assertTrue(struct['text'].endswith('#toocool'))
+ self.assertTrue('@peterbestwin' in struct['text'])
def make_twitter_get_authenticated_user_callback(struct):
def twitter_get_authenticated_user(self, callback, **kw):
Please sign in to comment.
Something went wrong with that request. Please try again.