def test_get_info_2(self):
        """get_info('now') assuming server is not running right now ussing 
        fake server like www.google.es"""

        c = ServiceConsumer('es', 'seville', 'www.google.es', '5000')

        with self.assertRaises(Exception):
            result = c.get_info('tomorrow');
Ejemplo n.º 2
0
    parser = ArgumentParser()

    parser.add_argument('--city', dest='city', type=str, required=True )

    parser.add_argument('--country', dest='country', type=str, required=False, default="es")

    parser.add_argument('--host', dest='host', type=str, default="localhost")

    parser.add_argument('--port', dest='port', type=str, default="5000")

    parser.add_argument('--when', dest='when', type=str, default="tomorrow")
    
    return parser.parse_args()

if __name__ == "__main__":

    #logging.basicConfig(level=logging.DEBUG)
    
    options = parse_args()

    service_consumer = ServiceConsumer(options.country, options.city, options.host,
        options.port)

    try:
        info = service_consumer.get_info(options.when)
    except Exception as e:
        print e.message
        sys.exit(1)
    print info
    sys.exit(0)