def test_default_keymaker_apikeys_env(self):
        """
        Test ability to create single key using consumer token from environment vars
        """
        keymaker = rmm.TwitterKeymaker()

        # Set application API keys
        os.environ['CONSUMER_TOKEN'] = 'AAAAA'
        os.environ['CONSUMER_TOKEN_SECRET'] = 'BBBBB'
        keymaker.set_apikeys_env()

        # Create bot API keys
        with captured_output() as (out, err):
            keymaker.make_a_key(
                name='test_default_keymaker_apikeys_env',
                json_target='test_default_keymaker_apikeys_env.json',
                keys_out_dir=self.keys_dir,
                interactive=False)

        # Clean up
        os.environ['CONSUMER_TOKEN'] = ''
        os.environ['CONSUMER_TOKEN_SECRET'] = ''

        # Assert
        output = out.getvalue().strip()
        self.assertIn('Creating fake Twitter key', output)
Пример #2
0
def setup():
    k = rmm.TwitterKeymaker()
    k.set_apikeys_file('apikeys.json')
    k.make_a_key(
        **{
            'name': 'math_tripos',
            'json_target': 'math_tripos.json',
            'keys_out_dir': KEYSDIR
        })
Пример #3
0
def setup():
    k = rmm.TwitterKeymaker()

    # This will look for OAuth app keys in apikeys.json
    # These are OAuth app credentials only, no bots.
    k.set_apikeys_file('apikeys.json')

    # This will create a bot key in lucky_penny.json
    # containing the credentials for the bot.
    k.make_a_key(name='lucky penny',
                 json_target='lucky_penny.json',
                 keys_out_dir='keys')
    def test_default_keymaker_apikeys_file(self):
        """
        Test ability to create single key using consumer token/secret from JSON file
        """
        keymaker = rmm.TwitterKeymaker()

        # Set application API keys
        keymaker.set_apikeys_file(self.api_keys)

        # Create bot API keys
        with captured_output() as (out, err):
            keymaker.make_a_key(
                name='test_default_keymaker_apikeys_file',
                json_target='test_default_keymaker_apikeys_file.json',
                keys_out_dir=self.keys_dir,
                interactive=False)

        # Assert
        output = out.getvalue().strip()
        self.assertIn('Creating fake Twitter key', output)
Пример #5
0
def setup():
    k = rmm.TwitterKeymaker()
    k.set_apikeys_file('apikeys.json')
    k.make_a_key(name='social_bot',
                 json_target='social_bot.json',
                 keys_out_dir='keys')