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

[BUG FIX]: Update ModemReporter #18

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ModemReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def report_events(self, events):
try:
self.connect_database()
sql = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES "
value_string = '(%s, %s, %s, %s)'
value_string = '("%s", %s, "%s", %s)'

event_datetime = None
value_list = []
Expand Down
10 changes: 5 additions & 5 deletions src/tests/ModemReporter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_report_events(self, connect_mock):
['Wed Sep 09 11:00:00 2020', 'Error (4)', 'The description'],
['Thu Sep 10 09:00:00 2020', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-10 09:00:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand All @@ -161,7 +161,7 @@ def test_report_events_when_no_times_have_been_established(self, connect_mock):
['Time Not Established', 'Error (4)', 'The description'],
['Time Not Established', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-15 13:05:00, False), (The description, 4, 2020-09-15 13:05:00, False), (The description, 4, 2020-09-15 13:05:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-15 13:05:00", False), ("The description", 4, "2020-09-15 13:05:00", False), ("The description", 4, "2020-09-15 13:05:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand All @@ -182,7 +182,7 @@ def test_report_events_when_an_earlier_event_has_no_time_established(self, conne
['Wed Sep 09 11:00:00 2020', 'Error (4)', 'The description'],
['Thu Sep 10 09:00:00 2020', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-10 09:00:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand All @@ -197,13 +197,13 @@ def test_report_events_when_an_earlier_event_has_no_time_established(self, conne
CONNECTION_MOCK.close.assert_called_once()

@patch('mysql.connector.connect')
def test_report_events_when_an_later_event_has_no_time_established(self, connect_mock):
def test_report_events_when_a_later_event_has_no_time_established(self, connect_mock):
EVENTS = [
['Wed Sep 09 11:00:00 2020', 'Error (4)', 'The description'],
['Thu Sep 10 09:00:00 2020', 'Error (4)', 'The description'],
['Time Not Established', 'Error (4)', 'The description']
]
SQL_QUERY = "INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES (The description, 4, 2020-09-09 11:00:00, False), (The description, 4, 2020-09-10 09:00:00, False), (The description, 4, 2020-09-10 09:00:00, False)"
SQL_QUERY = 'INSERT INTO `modem_events` (`description`, `priority`, `created_at`, `maintenance`) VALUES ("The description", 4, "2020-09-09 11:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False), ("The description", 4, "2020-09-10 09:00:00", False)'
cursor_mock = MagicMock()
CONNECTION_MOCK.cursor.return_value = cursor_mock
connect_mock.return_value = CONNECTION_MOCK
Expand Down