Exemplo n.º 1
0
    def setup_method_fixture(self, request, tmpdir):
        self.api_key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        self.channel = '#test'
        self.channels = [self.channel]
        self.stocks = [
            ['SPY', 'S&P 500'],
            ['DIA', 'Dow'],
            ['VEU', 'Foreign'],
            ['AGG', 'US Bond'],
        ]
        self.relay_bots = [
            {"nick": "relay.bot", "user": "******", "vhost": "relay"},
        ]

        d = tmpdir.mkdir('storage')

        get_db, self.db = get_mock_db()
        self.mock_cardinal = Mock(spec=CardinalBot)
        self.mock_cardinal.network = self.network = 'irc.darkscience.net'
        self.mock_cardinal.storage_path = str(d.dirpath())
        self.mock_cardinal.get_db.side_effect = get_db

        self.plugin = TickerPlugin(self.mock_cardinal, {
            'api_key': self.api_key,
            'channels': self.channels,
            'stocks': self.stocks,
            'relay_bots': self.relay_bots,
        })
Exemplo n.º 2
0
 def test_config_defaults(self):
     plugin = TickerPlugin(self.mock_cardinal, {
         'api_key': self.api_key,
     })
     assert plugin.config['api_key'] == self.api_key
     assert plugin.config['channels'] == []
     assert plugin.config['stocks'] == []
     assert plugin.config['relay_bots'] == []
Exemplo n.º 3
0
 def test_missing_stocks(self):
     with pytest.raises(ValueError):
         TickerPlugin(self.mock_cardinal, {
             'api_key': self.api_key,
             'stocks': [
                 ['a', 'a'],
                 ['b', 'b'],
                 ['c', 'c'],
                 ['d', 'd'],
                 ['e', 'e'],
                 ['f', 'f'],
             ],
         })
Exemplo n.º 4
0
 def test_missing_stocks(self):
     with pytest.raises(ValueError):
         TickerPlugin(
             self.mock_cardinal, {
                 'api_key': self.api_key,
                 'stocks': {
                     'a': 'a',
                     'b': 'b',
                     'c': 'c',
                     'd': 'd',
                     'e': 'e',
                     'f': 'f',
                 },
             })
Exemplo n.º 5
0
 def test_missing_api_key(self):
     with pytest.raises(KeyError):
         TickerPlugin(self.mock_cardinal, {})