-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,10 +35,7 @@ class TwitterSearchException(Exception): | |
|
|
||
| def __init__(self, code, msg=None): | ||
| self.code = code | ||
| if msg: | ||
| self.message = msg | ||
| else: | ||
| self.message = self._error_codes.get(code) | ||
| self.message = msg if msg else self._error_codes.get(code) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def __str__(self): | ||
| return "Error %i: %s" % (self.code, self.message) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,7 @@ def readme(): | |
| return f.read() | ||
|
|
||
| def requirements(): | ||
| req = [] | ||
| for line in open('requirements.txt','r'): | ||
| req.append(line.split()[0]) | ||
| return req | ||
| return [line.split()[0] for line in open('requirements.txt','r')] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| setup(name='TwitterSearch', | ||
| version='1.0.1', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,7 @@ def createTS(self): | |
| def apiAnsweringMachine(self, filename): | ||
| """ Generates faked API responses by returing content of a given file """ | ||
| f = open(filename, 'r') | ||
| for line in f: | ||
| yield line | ||
| yield from f | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| f.close() | ||
|
|
||
| def setUp(self): | ||
|
|
@@ -116,7 +115,7 @@ def test_TS_search_usertimeline_iterable(self): | |
| tuo = self.createTUO() | ||
| tweet_cnt = 0 | ||
|
|
||
| for tweet in ts.search_tweets_iterable(tuo): | ||
| for _ in ts.search_tweets_iterable(tuo): | ||
|
Comment on lines
-119
to
+118
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| tweet_cnt += 1 | ||
|
|
||
| # test statistics | ||
|
|
@@ -176,7 +175,7 @@ def test_TS_search_tweets_iterable(self): | |
| ts = self.createTS() | ||
|
|
||
| tweet_cnt = 0 | ||
| for tweet in ts.search_tweets_iterable(tso): | ||
| for _ in ts.search_tweets_iterable(tso): | ||
|
Comment on lines
-179
to
+178
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| tweet_cnt += 1 | ||
|
|
||
| self.assertEqual( (cnt*4-1), tweet_cnt, "Wrong amount of tweets") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,7 @@ def test_TSO_maxID(self): | |
| """ Tests TwitterSearchOrder.set_max_id() """ | ||
|
|
||
| tso = self.getCopy() | ||
| correct_values = [ self.generateInt(1,999999999) for x in range(0,10) ] | ||
| correct_values = [self.generateInt(1,999999999) for x in range(10)] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| for value in correct_values: | ||
| tso.set_max_id(value) | ||
|
|
@@ -121,7 +121,7 @@ def test_TSO_sinceID(self): | |
| """ Tests TwitterSearchOrder.set_since_id() """ | ||
|
|
||
| tso = self.getCopy() | ||
| correct_values = [ self.generateInt(1,999999999) for x in range(0,10) ] | ||
| correct_values = [self.generateInt(1,999999999) for x in range(10)] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| for value in correct_values: | ||
| tso.set_since_id(value) | ||
|
|
@@ -162,7 +162,7 @@ def test_TSO_geo(self): | |
| tso.set_geocode( value, value, radius, imperial_metric=unit) | ||
| self.assertTrue(False, "Not raising exception for lat %s, lon %s, radius %s and metric %s" % (value,value,radius,unit)) | ||
| except TwitterSearchException as e: | ||
| self.assertTrue((e.code == 1004 or e.code == 1005), "Wrong exception code") | ||
| self.assertTrue(e.code in [1004, 1005], "Wrong exception code") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| try: | ||
| tso.set_geocode(2.0,1.0,10, imperial_metric='foo') | ||
|
|
@@ -178,7 +178,7 @@ def test_TSO_count(self): | |
| """ Tests TwitterSearchOrder.set_count() """ | ||
|
|
||
| tso = self.getCopy() | ||
| correct_values = [ self.generateInt(minimum=1,maximum=100) for x in range(0,10) ] | ||
| correct_values = [self.generateInt(minimum=1,maximum=100) for x in range(10)] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| for value in correct_values: | ||
| tso.set_count(value) | ||
|
|
@@ -198,7 +198,7 @@ def test_TSO_callback(self): | |
| """ Tests TwitterSearchOrder.set_callback() """ | ||
|
|
||
| tso = self.getCopy() | ||
| correct_values = [ self.generateString() for x in range(0,10) ] | ||
| correct_values = [self.generateString() for x in range(10)] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| for value in correct_values: | ||
| tso.set_callback(value) | ||
|
|
@@ -417,10 +417,10 @@ def test_TSO_setURL(self): | |
| def test_TO_exceptions(self): | ||
| """ Tests unimplemented TwitterOrder functions aiming for exceptions """ | ||
|
|
||
| value = "foo" | ||
| exc_class = NotImplementedError | ||
| to = TwitterOrder() | ||
| with self.assertRaises(exc_class): | ||
| value = "foo" | ||
|
Comment on lines
-420
to
+423
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| to.set_search_url(value) | ||
| to.create_search_url() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,11 +31,10 @@ def _get_results(self): | |
| return response.json()['results'] | ||
|
|
||
| def _prepare_request_data(self): | ||
| data = { | ||
| return { | ||
| 'query': self.movie, | ||
| 'api-key': self.api_key | ||
| } | ||
| return data | ||
|
Comment on lines
-34
to
-38
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| class Review(BaseReview): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
TwitterSearch.getSearchResultsrefactored with the following changes:inline-immediately-returned-variable)