Ejemplo n.º 1
0
    def test_twitter_user_streaming(self):
        arguments = MockArgumentParser()
        client = TwitterBotClient(arguments)
        self.assertIsNotNone(client)

        with self.assertRaises(Exception):
            client._use_streaming()
Ejemplo n.º 2
0
    def test_message_ids_save_load(self):
        arguments = MockArgumentParser()
        client = TwitterBotClient(arguments)
        self.assertIsNotNone(client)

        client.configuration.client_configuration._storage = 'file'
        if os.name == 'posix':
            client.configuration.client_configuration._storage_location = "/tmp/twitter.txt"
        else:
            client.configuration.client_configuration._storage_location = "C:\Windows\Temp/twitter.txt"

        if os.path.exists(
                client.configuration.client_configuration.storage_location):
            os.remove(
                client.configuration.client_configuration.storage_location)
        self.assertFalse(
            os.path.exists(
                client.configuration.client_configuration.storage_location))

        client._store_last_message_ids(666, 667)

        self.assertTrue(
            os.path.exists(
                client.configuration.client_configuration.storage_location))

        ids = client._get_last_message_ids()
        self.assertEquals(ids[0], 666)
        self.assertEquals(ids[1], 667)
Ejemplo n.º 3
0
    def test_twitter_get_username(self):
        arguments = MockArgumentParser()
        client = TwitterBotClient(arguments)
        self.assertIsNotNone(client)

        bot = MockBot()
        bot.license_keys = MockLicenseKeys({"TWITTER_USERNAME": "******"})

        client._get_username(bot)
        self.assertEquals("Username", client._username)
        self.assertEquals(8, client._username_len)
Ejemplo n.º 4
0
    def test_twitter_get_consumer_secrets(self):
        arguments = MockArgumentParser()
        client = TwitterBotClient(arguments)
        self.assertIsNotNone(client)

        bot = MockBot()
        bot.license_keys = MockLicenseKeys({
            "TWITTER_CONSUMER_KEY": "Key",
            "TWITTER_CONSUMER_SECRET": "Secret"
        })

        consumer_key, consumer_secret = client._get_consumer_secrets(bot)
        self.assertIsNotNone(consumer_key)
        self.assertEquals("Key", consumer_key)
        self.assertIsNotNone(consumer_secret)
        self.assertEquals("Secret", consumer_secret)
Ejemplo n.º 5
0
    def test_twitter_get_access_secrets(self):
        arguments = MockArgumentParser()
        client = TwitterBotClient(arguments)
        self.assertIsNotNone(client)

        bot = MockBot()
        bot.license_keys = MockLicenseKeys({
            "TWITTER_ACCESS_TOKEN":
            "Access",
            "TWITTER_ACCESS_TOKEN_SECRET":
            "Secret"
        })

        access_token, access_token_secret = client._get_access_secrets(bot)
        self.assertIsNotNone(access_token)
        self.assertEquals("Access", access_token)
        self.assertIsNotNone(access_token_secret)
        self.assertEquals("Secret", access_token_secret)
Ejemplo n.º 6
0
    def test_twitter_client(self):
        arguments = MockArgumentParser()
        client = TwitterBotClient(arguments)
        self.assertIsNotNone(client)

        self.assertIsNotNone(client.get_client_configuration())
        self.assertIsInstance(client.get_client_configuration(),
                              TwitterConfiguration)

        client.set_environment()
        self.assertEquals("Twitter",
                          client.bot.brain.properties.property("env"))
Ejemplo n.º 7
0
 def __init__(self, argument_parser=None):
     TwitterBotClient.__init__(self, argument_parser)
     self._use_polling_real = True
     self._polled = False
Ejemplo n.º 8
0
 def test_twitter_client(self):
     arguments = MockArgumentParser()
     client = TwitterBotClient(arguments)
     self.assertIsNotNone(client)