BrianMitchL / weatherBot

⛈ A Twitter bot for weather

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test.py

tomlear opened this issue · comments

This is what I get when I run test.py any ideas? The main program runs in terminal but won't tweet?

FF...........ERROR:root:Tweet failed: [{'code': 186, 'message': 'Status is over 140 characters.'}]
WARNING:root:Tweet skipped due to error: This tweet is over 140 characters.
This tweet is over 140 characters.
This tweet is over 140 characters.
This tweet is over 140 characters.
This tweet is over 140 characters.
4519
.
Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 760
    self._tunnel_headers = {}
ResourceWarning: unclosed <ssl.SSLSocket fd=11, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=(‘IP Address’, 58307), raddr=(‘IP Address’, 443)>
..ERROR:root:400 Client Error: Bad Request for url: https://api.darksky.net/forecast/87e6e57f74628921d8f1d26397be733f/345.5,123.45?units=us&lang=en
ERROR:root:Error when getting Forecast object
Traceback (most recent call last):
  File "/Users/Tom/Documents/weatherBot-master/weatherBot.py", line 154, in get_forecast_object
    return forecastio.manual(url)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/forecastio/api.py", line 51, in manual
    return get_forecast(requestURL)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/forecastio/api.py", line 60, in get_forecast
    forecastio_reponse.raise_for_status()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/models.py", line 862, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.darksky.net/forecast/87e6e57f74628921d8f1d26397be733f/345.5,123.45?units=us&lang=en

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1076
    for i, one_value in enumerate(values):
ResourceWarning: unclosed <ssl.SSLSocket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=(‘IP Address’, 58310), raddr=(‘IP Address’, 443)>
.WARNING:root:Could not find tweet with location, falling back to hardcoded location
.2016-11-29 19:18:22,394 INFO     Starting weatherBot with Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
2016-11-29 19:18:22,505 DEBUG    debug
2016-11-29 19:18:22,569 WARNING  uh oh

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/testfixtures/logcapture.py", line 122
    logger.handlers = self.old['handlers'][name]
ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/Tom/Documents/weatherBot-master/weatherBotTest.log' mode='a' encoding='US-ASCII'>
....
Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yaml/scanner.py", line 1311
    return ScalarToken(''.join(chunks), True, start_mark, end_mark)
ResourceWarning: unclosed <ssl.SSLSocket fd=13, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=(‘IP Address’, 58315), raddr=('IP Address.130', 443)>

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yaml/error.py", line 7
    self.name = name
ResourceWarning: unclosed <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('IP Address', 58305), raddr=(‘IP Address.130', 443)>

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yaml/error.py", line 7
    self.name = name
ResourceWarning: unclosed <ssl.SSLSocket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('IP Address', 58306), raddr=('IP Address', 443)>

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yaml/error.py", line 7
    self.name = name
ResourceWarning: unclosed <ssl.SSLSocket fd=11, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('IP Address', 58308), raddr=('IP Address', 443)>

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yaml/error.py", line 7
    self.name = name
ResourceWarning: unclosed <ssl.SSLSocket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('IP Address', 58314), raddr=('IP Address', 443)>
................
======================================================================
FAIL: test_set_darksky_env_vars (__main__.TestKeys)
Test that the Dark Sky environmental variable is set to value in keys.py
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Tom/Documents/weatherBot-master/test.py", line 871, in test_set_darksky_env_vars
    self.assertEqual(os.getenv('WEATHERBOT_DARKSKY_KEY'), 'xxx')
AssertionError: '87e6e57f74628921d8f1d26397be733f' != 'xxx'
- 87e6e57f74628921d8f1d26397be733f
+ xxx


======================================================================
FAIL: test_set_twitter_env_vars (__main__.TestKeys)
Test that Twitter environmental variables are set to values in keys.py
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Tom/Documents/weatherBot-master/test.py", line 860, in test_set_twitter_env_vars
    self.assertEqual(os.getenv('WEATHERBOT_CONSUMER_KEY'), 'xxx')
AssertionError: 'jtLQOSlkGIvYxnKRyl6MnkTO4' != 'xxx'
- jtLQOSlkGIvYxnKRyl6MnkTO4
+ xxx


----------------------------------------------------------------------
Ran 38 tests in 6.650s

FAILED (failures=2)
>>> 

The tests are written to pass when the keys.py file is unmodified. Since you have your keys in there, the tests will fail. You will have to run the tests using environmental variables. It should look something like this:

WEATHERBOT_CONSUMER_KEY=xxx WEATHERBOT_CONSUMER_SECRET=xxx WEATHERBOT_ACCESS_TOKEN=xxx WEATHERBOT_ACCESS_TOKEN_SECRET=xxx WEATHERBOT_DARKSKY_KEY=xxx python3 test.py