-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RENAME sensor_id -> device_id in code #84
Conversation
@@ -34,7 +34,7 @@ class TestIotaManager(unittest.TestCase): | |||
def test_send_http_success(self): | |||
"""A success message should be displayed when | |||
HTTP request is executed successfully.""" | |||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key') | |||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key') |
@@ -45,15 +45,15 @@ def test_send_http_success(self): | |||
|
|||
def test_send_http_connection_error(self): | |||
"""Should raise an exception when there is a server connection error.""" | |||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key') | |||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key') |
with patch('requests.post') as mock_post: | ||
mock_post.side_effect = requests.exceptions.ConnectionError() | ||
with pytest.raises(requests.exceptions.ConnectionError): | ||
iot.send_http(data={"key": "value"}) | ||
|
||
def test_send_http_invalid_data_type(self): | ||
"""Should raise an exception when the data type is incorrect.""" | ||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key') | ||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key') |
@@ -62,7 +62,7 @@ def test_send_http_invalid_data_type(self): | |||
|
|||
def test_send_http_set_not_unique(self): | |||
"""Should raise an exception if the data is an array of dictionaries.""" | |||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key') | |||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key') |
@@ -73,7 +73,7 @@ def test_send_http_set_not_unique(self): | |||
|
|||
def test_send_http_unauthorized(self): | |||
"""Should raise an exception when the request is unauthorized.""" | |||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key') | |||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key') | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key') |
@@ -109,13 +109,13 @@ def test_send_http_server_error(self): | |||
def test_send_batch_http_dict_success(self): | |||
"""send_http should be called twice when we send an array with 2 dictionaries.""" | |||
with patch('tc_etl_lib.iota.iotaManager.send_http') as mock_send_http: | |||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | |||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key', sleep_send_batch=0.25) |
iot.send_batch_http(data=[{'key1': 'value1'}, {'key2': 'value2'}]) | ||
self.assertEqual(mock_send_http.call_count, 2) | ||
|
||
def test_send_batch_http_dict_value_error(self): | ||
"""Should raise TypeError and then raise SendBatchError with the index that failed.""" | ||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | ||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key', sleep_send_batch=0.25) |
@@ -128,7 +128,7 @@ def test_send_batch_http_dict_value_error(self): | |||
|
|||
def test_send_batch_http_connection_error(self): | |||
"""Should raise a ConnectionError exception and then raise SedBatchError with the index that failed.""" | |||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | |||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key', sleep_send_batch=0.25) |
@@ -150,10 +150,10 @@ def test_send_batch_http_connection_error(self): | |||
def test_send_batch_http_data_frame_success(self): | |||
"""send_http should be called 3 times when we send a DataFrame with 3 rows.""" | |||
with patch('tc_etl_lib.iota.iotaManager.send_http') as mock_send_http: | |||
iot = iotaManager(endpoint='http://fakeurl.com', sensor_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | |||
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_sensor_id', api_key='fake_api_key', sleep_send_batch=0.25) | |
iot = iotaManager(endpoint='http://fakeurl.com', device_id='fake_device_id', api_key='fake_api_key', sleep_send_batch=0.25) |
…asc/etl-framework into hardening/77_sensor_id
Co-authored-by: Alberto Arcos <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue #77