Skip to content
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

Merged
merged 7 commits into from
Feb 6, 2024
Merged

Conversation

fgalan
Copy link
Contributor

@fgalan fgalan commented Feb 6, 2024

Issue #77

@fgalan fgalan changed the title [WIP] RENAME sensor_id -> device_id in code RENAME sensor_id -> device_id in code Feb 6, 2024
@@ -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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

python-lib/tc_etl_lib/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@arcosa arcosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@mapedraza mapedraza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mapedraza mapedraza merged commit 334c48a into master Feb 6, 2024
1 check passed
@mapedraza mapedraza deleted the hardening/77_sensor_id branch February 6, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants