Exemple #1
0
    def main(self):
        bark_consumer = BarkConsumer()
        pin_auth = PinAuthentication()
        bark_config = BarkConfig(None)
        if bark_consumer.CONSUMER_KEY == None:
            CONSUMER_KEY = bark_config.get_value('API', 'consumer_key')
        else:
            CONSUMER_KEY = bark_consumer.CONSUMER_KEY

        if bark_consumer.CONSUMER_SECRET == None:
            CONSUMER_SECRET = bark_config.get_value('API', 'consumer_secret')
        else:
            CONSUMER_SECRET = bark_consumer.CONSUMER_SECRET

        if bark_config.get_value('API', 'access_token') == None:
            #TODO: Request access tokens with pin based auth
            pin_auth.get_access_token(CONSUMER_KEY, CONSUMER_SECRET)
            ACCESS_TOKEN = bark_config.get_value('API', 'access_token')
            ACCESS_TOKEN_SECRET = bark_config.get_value(
                'API', 'access_token_secret')
        else:
            ACCESS_TOKEN = bark_config.get_value('API', 'access_token')
            ACCESS_TOKEN_SECRET = bark_config.get_value(
                'API', 'access_token_secret')

        api = twitter.Api(consumer_key=CONSUMER_KEY,
                          consumer_secret=CONSUMER_SECRET,
                          access_token_key=ACCESS_TOKEN,
                          access_token_secret=ACCESS_TOKEN_SECRET)
        bark = BarkCurses(api)
        curses.wrapper(bark.main)
Exemple #2
0
 def test_init_with_mock(self, mocker):
     mocker.patch.object(twitter, 'Api')
     bark = BarkCurses(twitter.Api())
Exemple #3
0
 def test_handle_command_exit(self, mocker):
     mocker.patch.object(twitter, 'Api')
     bark = BarkCurses(twitter.Api())
     with pytest.raises(SystemExit) as pytest_wrapped_e:
         bark.handle_command('/exit')
     assert pytest_wrapped_e.type == SystemExit
Exemple #4
0
 def test_handle_command_tweet(self, mocker):
     mocker.patch.object(twitter, 'Api')
     bark = BarkCurses(twitter.Api())
     mocker.patch.object(bark, 'do_tweet')
     bark.handle_command('/tweet tweeting message')
     bark.do_tweet.assert_called_with(['tweeting', 'message'])
Exemple #5
0
 def test_handle_command_refresh(self, mocker):
     mocker.patch.object(twitter, 'Api')
     bark = BarkCurses(twitter.Api())
     mocker.patch.object(bark, 'do_refresh')
     bark.handle_command('/refresh')
     bark.do_refresh.assert_called_with()
Exemple #6
0
 def test_validate_do_page_up(self, mocker):
     mocker.patch.object(twitter, 'Api')
     bark = BarkCurses(twitter.Api())
     mocker.patch.object(bark, 'do_page_up')
     bark.validate_input(339)
     bark.do_page_up.assert_called_with()