Esempio n. 1
0
    def test_NoNetwork(self):
        import socket

        oldSocket = socket.socket
        def guard(*args, **kwargs):
            raise Exception("I told you not to use the Internet!")
        socket.socket = guard
        result = stooq.checkStock('stock|AMZN.US|main')
        socket.socket = oldSocket
        self.assertEqual(result, 'ERR: I told you not to use the Internet!')
Esempio n. 2
0
def callback(ch, method, properties, body):
    data = body.decode("utf-8")
    res = stooq.checkStock(data)
    channel.basic_publish(exchange='my_exchange2',
                          routing_key='test2',
                          body=res)
Esempio n. 3
0
def stock():
    data = flask.request.args.get('ticker')
    return stooq.checkStock(data)
Esempio n. 4
0
 def test_TSLAStock(self):
     self.assertRegex(stooq.checkStock('stock|TSLA.US|main'), r'\w*.\w* quote is \$\d*.\d* per share')
Esempio n. 5
0
 def test_EmptyStock(self):
     self.assertEqual(stooq.checkStock('||main|'), 'ERR: Wrong No of parameters')        
Esempio n. 6
0
 def test_EmptyMessage(self):
     self.assertEqual(stooq.checkStock(''), 'ERR: Input is missing')