示例#1
0
class Bike:
    def __init__(self):
        self.http_service = HttpService()
        self.producer = Producer()

    def get_bikes_station_information(self, url, params):
        res = self.http_service.get(url, params).json()
        for msg in res['data']['stations']:
            print('bikes_station_information ==>  ', msg)
            self.producer.data_producer(BIKES_STATION_INFORMATION_TOPIC, msg)

    def get_bikes_station_status(self, url, params):
        res = self.http_service.get(url, params).json()
        for msg in res['data']['stations']:
            print('bikes_station_status ==>  ', msg)
            self.producer.data_producer(BIKES_STATION_INFORMATION_TOPIC, msg)
示例#2
0
 def __init__(self):
     self.http_service = HttpService()
     self.producer = Producer()
示例#3
0
文件: tests.py 项目: storecast/holon
 def test_call_without_user_agent(self):
     s = HttpService('host', 42, 'path')
     s._call = Mock(return_value=(200, 'data', 3))
     s.call('body')
     s._call.assert_called_with('body', {})
示例#4
0
文件: tests.py 项目: storecast/holon
 def test_call_with_user_agent(self):
     s = HttpService('host', 42, 'path', user_agent='test agent')
     s._call = Mock(return_value=(200, 'data', 3))
     s.call('body')
     s._call.assert_called_with('body', {'User-Agent': 'test agent'})
示例#5
0
文件: tests.py 项目: storecast/holon
 def test_call_helper_not_implemented(self):
     s = HttpService()
     with self.assertRaises(NotImplementedError):
         s._call('whatever', {})