Ejemplo 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!')
Ejemplo 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)
Ejemplo n.º 3
0
def stock():
    data = flask.request.args.get('ticker')
    return stooq.checkStock(data)
Ejemplo n.º 4
0
 def test_TSLAStock(self):
     self.assertRegex(stooq.checkStock('stock|TSLA.US|main'), r'\w*.\w* quote is \$\d*.\d* per share')
Ejemplo n.º 5
0
 def test_EmptyStock(self):
     self.assertEqual(stooq.checkStock('||main|'), 'ERR: Wrong No of parameters')        
Ejemplo n.º 6
0
 def test_EmptyMessage(self):
     self.assertEqual(stooq.checkStock(''), 'ERR: Input is missing')