Exemplo n.º 1
0
    def test_recent_tweets(self, _):

        twitter = api.API(self.args)

        self.assertEqual(twitter.last_tweet, 1235)
        assert twitter.last_retweet == 1233
        assert twitter.last_reply == 1234
Exemplo n.º 2
0
 def api(self):
     if not self._api:
         self._api = api.API(config_file=False, **credentials)
         self.assertEqual(self._api.screen_name, credentials['screen_name'])
         self.assertEqual(self._api.auth.get_username(),
                          credentials['screen_name'])
     return self._api
Exemplo n.º 3
0
    def testApiAttributes(self):
        twitter = api.API(screen_name='example_screen_name',
                          config_file=self.yaml,
                          use_env=False)

        assert twitter.config['custom'] == 'user'
        assert twitter.screen_name == 'example_screen_name'
        assert twitter.app == 'example_app_name'
Exemplo n.º 4
0
    def testEnviron(self):
        twitter = self.api()
        self.assertEqual(twitter.screen_name, credentials['screen_name'])
        self.assertEqual(twitter.auth.consumer_key.decode('utf8'), credentials['consumer_key'])
        self.assertEqual(twitter.auth.consumer_secret.decode('utf8'), credentials['consumer_secret'])
        self.assertEqual(twitter.auth.access_token, credentials['token'])
        self.assertEqual(twitter.auth.access_token_secret, credentials['secret'])

        twitter = api.API(screen_name='fake', config_file='.travis.yml')

        # Strange that two of these are bytes and two are str.
        self.assertEqual(twitter.auth.consumer_key.decode('utf8'), os.environ['TWITTER_CONSUMER_KEY'])
        assert twitter.auth.consumer_secret.decode('utf8') == os.environ['TWITTER_CONSUMER_SECRET']
Exemplo n.º 5
0
    def test_api_attributes(self):
        twitter = api.API(**vars(self.args))
        self.assertEqual(twitter.config['custom'], 'user')

        try:
            key = twitter.config['key']
        except KeyError:
            key = False

        assert key is False

        assert twitter.screen_name == 'example_screen_name'
        assert twitter.app == 'example_app_name'
Exemplo n.º 6
0
 def test_api_creation_ns(self):
     args = argparse.Namespace(**credentials)
     twitter = api.API(args, config_file=self.yaml)
     assert isinstance(twitter, api.API)
Exemplo n.º 7
0
    def test_recent_tweets_no_rts(self, _):
        twitter = api.API(self.args)

        self.assertEqual(twitter.last_tweet, 1235)
        assert twitter.last_retweet is None
        assert twitter.last_reply is None
Exemplo n.º 8
0
    def testApiAttributesNamespace(self):
        twitter = api.API(self.args)

        assert twitter.config['custom'] == 'user'
        assert twitter.screen_name == 'example_screen_name'
        assert twitter.app == 'example_app_name'
Exemplo n.º 9
0
    def test_api_creation(self):
        twitter = api.API(**vars(self.args))
        assert isinstance(twitter, api.API)

        twitter = api.API(self.args, config_file=self.yaml)
        assert isinstance(twitter, api.API)