def test_getEventData(): pin = "12345" deviceId = "dev:864475044207255" sinceEvent = "3a531360-577c-447f-b01f-d902014e6a36" with patch('requests.get') as mock_request: # set fake content mock_request.return_value.content = getTestResponse() d = notehub.getEventData(pin, deviceId, since=sinceEvent) assert d == json.loads(getTestResponse())
def test_getEventData_numericPin(): pin = 12345 deviceId = "dev:864475044207255" with patch('requests.get') as mock_request: # set fake content mock_request.return_value.content = '{"abc":"def"}' d = notehub.getEventData(pin, deviceId) header = mock_request.call_args[1]['headers'] assert '12345' in header.values()
def test_getEventData_deviceIdIsAppendedToQueryString(): pin = 12345 deviceId = "dev:864475044207255" pageSize = 17 with patch('requests.get') as mock_request: # set fake content mock_request.return_value.content = '{"abc":"def"}' d = notehub.getEventData(pin, deviceId, pageSize=pageSize) urlUsed = mock_request.call_args[0][0] assert 'deviceUIDs=dev:864475044207255' in urlUsed
def test_getEventData_sinceIsAppendedToQueryString(): pin = 12345 deviceId = "dev:864475044207255" since = 'abcd' with patch('requests.get') as mock_request: # set fake content mock_request.return_value.content = '{"abc":"def"}' d = notehub.getEventData(pin, deviceId, since=since) urlUsed = mock_request.call_args[0][0] assert '&since=abcd' in urlUsed